|
|
@ -1139,57 +1139,57 @@ class YoutubeDL(object):
|
|
|
|
res = default
|
|
|
|
res = default
|
|
|
|
return res
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
|
|
def list_formats(self, info_dict):
|
|
|
|
def _format_note(self, fdict):
|
|
|
|
def format_note(fdict):
|
|
|
|
res = ''
|
|
|
|
res = ''
|
|
|
|
if fdict.get('ext') in ['f4f', 'f4m']:
|
|
|
|
if fdict.get('ext') in ['f4f', 'f4m']:
|
|
|
|
res += '(unsupported) '
|
|
|
|
res += '(unsupported) '
|
|
|
|
if fdict.get('format_note') is not None:
|
|
|
|
if fdict.get('format_note') is not None:
|
|
|
|
res += fdict['format_note'] + ' '
|
|
|
|
res += fdict['format_note'] + ' '
|
|
|
|
if fdict.get('tbr') is not None:
|
|
|
|
if fdict.get('tbr') is not None:
|
|
|
|
res += '%4dk ' % fdict['tbr']
|
|
|
|
res += '%4dk ' % fdict['tbr']
|
|
|
|
if fdict.get('container') is not None:
|
|
|
|
if fdict.get('container') is not None:
|
|
|
|
if res:
|
|
|
|
if res:
|
|
|
|
res += ', '
|
|
|
|
res += ', '
|
|
|
|
res += '%s container' % fdict['container']
|
|
|
|
res += '%s container' % fdict['container']
|
|
|
|
if (fdict.get('vcodec') is not None and
|
|
|
|
if (fdict.get('vcodec') is not None and
|
|
|
|
fdict.get('vcodec') != 'none'):
|
|
|
|
fdict.get('vcodec') != 'none'):
|
|
|
|
if res:
|
|
|
|
if res:
|
|
|
|
res += ', '
|
|
|
|
res += ', '
|
|
|
|
res += fdict['vcodec']
|
|
|
|
res += fdict['vcodec']
|
|
|
|
|
|
|
|
if fdict.get('vbr') is not None:
|
|
|
|
|
|
|
|
res += '@'
|
|
|
|
|
|
|
|
elif fdict.get('vbr') is not None and fdict.get('abr') is not None:
|
|
|
|
|
|
|
|
res += 'video@'
|
|
|
|
|
|
|
|
if fdict.get('vbr') is not None:
|
|
|
|
if fdict.get('vbr') is not None:
|
|
|
|
res += '%4dk' % fdict['vbr']
|
|
|
|
res += '@'
|
|
|
|
if fdict.get('acodec') is not None:
|
|
|
|
elif fdict.get('vbr') is not None and fdict.get('abr') is not None:
|
|
|
|
if res:
|
|
|
|
res += 'video@'
|
|
|
|
res += ', '
|
|
|
|
if fdict.get('vbr') is not None:
|
|
|
|
if fdict['acodec'] == 'none':
|
|
|
|
res += '%4dk' % fdict['vbr']
|
|
|
|
res += 'video only'
|
|
|
|
if fdict.get('acodec') is not None:
|
|
|
|
else:
|
|
|
|
if res:
|
|
|
|
res += '%-5s' % fdict['acodec']
|
|
|
|
res += ', '
|
|
|
|
elif fdict.get('abr') is not None:
|
|
|
|
if fdict['acodec'] == 'none':
|
|
|
|
if res:
|
|
|
|
res += 'video only'
|
|
|
|
res += ', '
|
|
|
|
else:
|
|
|
|
res += 'audio'
|
|
|
|
res += '%-5s' % fdict['acodec']
|
|
|
|
if fdict.get('abr') is not None:
|
|
|
|
elif fdict.get('abr') is not None:
|
|
|
|
res += '@%3dk' % fdict['abr']
|
|
|
|
if res:
|
|
|
|
if fdict.get('asr') is not None:
|
|
|
|
res += ', '
|
|
|
|
res += ' (%5dHz)' % fdict['asr']
|
|
|
|
res += 'audio'
|
|
|
|
if fdict.get('filesize') is not None:
|
|
|
|
if fdict.get('abr') is not None:
|
|
|
|
if res:
|
|
|
|
res += '@%3dk' % fdict['abr']
|
|
|
|
res += ', '
|
|
|
|
if fdict.get('asr') is not None:
|
|
|
|
res += format_bytes(fdict['filesize'])
|
|
|
|
res += ' (%5dHz)' % fdict['asr']
|
|
|
|
return res
|
|
|
|
if fdict.get('filesize') is not None:
|
|
|
|
|
|
|
|
if res:
|
|
|
|
|
|
|
|
res += ', '
|
|
|
|
|
|
|
|
res += format_bytes(fdict['filesize'])
|
|
|
|
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def list_formats(self, info_dict):
|
|
|
|
def line(format, idlen=20):
|
|
|
|
def line(format, idlen=20):
|
|
|
|
return (('%-' + compat_str(idlen + 1) + 's%-10s%-12s%s') % (
|
|
|
|
return (('%-' + compat_str(idlen + 1) + 's%-10s%-12s%s') % (
|
|
|
|
format['format_id'],
|
|
|
|
format['format_id'],
|
|
|
|
format['ext'],
|
|
|
|
format['ext'],
|
|
|
|
self.format_resolution(format),
|
|
|
|
self.format_resolution(format),
|
|
|
|
format_note(format),
|
|
|
|
self._format_note(format),
|
|
|
|
))
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
formats = info_dict.get('formats', [info_dict])
|
|
|
|
formats = info_dict.get('formats', [info_dict])
|
|
|
@ -1197,8 +1197,8 @@ class YoutubeDL(object):
|
|
|
|
max(len(f['format_id']) for f in formats))
|
|
|
|
max(len(f['format_id']) for f in formats))
|
|
|
|
formats_s = [line(f, idlen) for f in formats]
|
|
|
|
formats_s = [line(f, idlen) for f in formats]
|
|
|
|
if len(formats) > 1:
|
|
|
|
if len(formats) > 1:
|
|
|
|
formats_s[0] += (' ' if format_note(formats[0]) else '') + '(worst)'
|
|
|
|
formats_s[0] += (' ' if self._format_note(formats[0]) else '') + '(worst)'
|
|
|
|
formats_s[-1] += (' ' if format_note(formats[-1]) else '') + '(best)'
|
|
|
|
formats_s[-1] += (' ' if self._format_note(formats[-1]) else '') + '(best)'
|
|
|
|
|
|
|
|
|
|
|
|
header_line = line({
|
|
|
|
header_line = line({
|
|
|
|
'format_id': 'format code', 'ext': 'extension',
|
|
|
|
'format_id': 'format code', 'ext': 'extension',
|
|
|
|