mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-02 01:02:48 +01:00
Nicer --list-formats output
This commit is contained in:
parent
912cbf5d4e
commit
57dd9a8f2f
@ -759,6 +759,8 @@ def record_download_archive(self, info_dict):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def format_resolution(format, default='unknown'):
|
def format_resolution(format, default='unknown'):
|
||||||
|
if format.get('_resolution') is not None:
|
||||||
|
return format['_resolution']
|
||||||
if format.get('height') is not None:
|
if format.get('height') is not None:
|
||||||
if format.get('width') is not None:
|
if format.get('width') is not None:
|
||||||
res = u'%sx%s' % (format['width'], format['height'])
|
res = u'%sx%s' % (format['width'], format['height'])
|
||||||
@ -769,19 +771,22 @@ def format_resolution(format, default='unknown'):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def list_formats(self, info_dict):
|
def list_formats(self, info_dict):
|
||||||
formats_s = []
|
def line(format):
|
||||||
for format in info_dict.get('formats', [info_dict]):
|
return (u'%-15s%-10s%-12s%s' % (
|
||||||
formats_s.append(u'%-15s%-7s %-15s%s' % (
|
|
||||||
format['format_id'],
|
format['format_id'],
|
||||||
format['ext'],
|
format['ext'],
|
||||||
format.get('format_note', ''),
|
|
||||||
self.format_resolution(format),
|
self.format_resolution(format),
|
||||||
|
format.get('format_note', ''),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
formats_s = list(map(line, info_dict.get('formats', [info_dict])))
|
||||||
if len(formats_s) != 1:
|
if len(formats_s) != 1:
|
||||||
formats_s[0] += ' (worst)'
|
formats_s[0] += (' ' if formats_s[0] else '') + '(worst)'
|
||||||
formats_s[-1] += ' (best)'
|
formats_s[-1] += (' ' if formats_s[-1] else '') + '(best)'
|
||||||
formats_s = "\n".join(formats_s)
|
|
||||||
self.to_screen(u'[info] Available formats for %s:\n'
|
header_line = line({
|
||||||
u'format code extension note resolution\n%s' % (
|
'format_id': u'format code', 'ext': u'extension',
|
||||||
info_dict['id'], formats_s))
|
'_resolution': u'resolution', 'format_note': u'note'})
|
||||||
|
self.to_screen(u'[info] Available formats for %s:\n%s\n%s' %
|
||||||
|
(info_dict['id'], header_line, u"\n".join(formats_s)))
|
||||||
|
Loading…
Reference in New Issue
Block a user