- formats_s = []
- for format in info_dict.get('formats', [info_dict]):
- formats_s.append("%s\t:\t%s\t[%s]" % (format['format_id'],
- format['ext'],
- format.get('format', '???'),
- )
- )
- if len(formats_s) != 1:
- formats_s[0] += ' (worst)'
- formats_s[-1] += ' (best)'
- formats_s = "\n".join(formats_s)
- self.to_screen(u"[info] Available formats for %s:\nformat code\textension\n%s" % (info_dict['id'], formats_s))
+ def format_note(fdict):
+ if fdict.get('format_note') is not None:
+ return fdict['format_note']
+ res = u''
+ if fdict.get('vcodec') is not None:
+ res += u'%-5s' % fdict['vcodec']
+ elif fdict.get('vbr') is not None:
+ res += u'video'
+ if fdict.get('vbr') is not None:
+ res += u'@%4dk' % fdict['vbr']
+ if fdict.get('acodec') is not None:
+ if res:
+ res += u', '
+ res += u'%-5s' % fdict['acodec']
+ elif fdict.get('abr') is not None:
+ if res:
+ res += u', '
+ res += 'audio'
+ if fdict.get('abr') is not None:
+ res += u'@%3dk' % fdict['abr']
+ return res
+
+ def line(format):
+ return (u'%-20s%-10s%-12s%s' % (
+ format['format_id'],
+ format['ext'],
+ self.format_resolution(format),
+ format_note(format),
+ )
+ )
+
+ formats = info_dict.get('formats', [info_dict])
+ formats_s = list(map(line, formats))
+ if len(formats) > 1:
+ formats_s[0] += (' ' if format_note(formats[0]) else '') + '(worst)'
+ formats_s[-1] += (' ' if format_note(formats[-1]) else '') + '(best)'
+
+ header_line = line({
+ 'format_id': u'format code', 'ext': u'extension',
+ '_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)))