]> git.bitcoin.ninja Git - youtube-dl/commitdiff
The 'format' field now defaults to '{format_id} - {width}x{height}{format_note}'
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Mon, 21 Oct 2013 12:09:38 +0000 (14:09 +0200)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Mon, 21 Oct 2013 12:42:06 +0000 (14:42 +0200)
Following the YoutubeIE format. The 'format_note' gives additional info about the format, for example '3D' or 'DASH video'.

youtube_dl/YoutubeDL.py
youtube_dl/extractor/common.py

index a837971b0c7db8e19bc42e68fb177ecfc3e59b6f..5f70b6dac727cdc4ff521a3381c2e2d610c483c7 100644 (file)
@@ -473,17 +473,14 @@ class YoutubeDL(object):
 
         # We check that all the formats have the format and format_id fields
         for (i, format) in enumerate(formats):
-            if format.get('format') is None:
-                if format.get('height') is not None:
-                    if format.get('width') is not None:
-                        format_desc = u'%sx%s' % (format['width'], format['height'])
-                    else:
-                        format_desc = u'%sp' % format['height']
-                else:
-                    format_desc = '???'
-                format['format'] = format_desc
             if format.get('format_id') is None:
                 format['format_id'] = compat_str(i)
+            if format.get('format') is None:
+                format['format'] = u'{id} - {res}{note}'.format(
+                    id=format['format_id'],
+                    res=self.format_resolution(format),
+                    note = u' ({})'.format(format['format_note']) if format.get('format_note') is not None else '',
+                )
 
         if self.params.get('listformats', None):
             self.list_formats(info_dict)
@@ -753,16 +750,31 @@ class YoutubeDL(object):
         with locked_file(fn, 'a', encoding='utf-8') as archive_file:
             archive_file.write(vid_id + u'\n')
 
+    @staticmethod
+    def format_resolution(format):
+        if format.get('height') is not None:
+            if format.get('width') is not None:
+                res = u'%sx%s' % (format['width'], format['height'])
+            else:
+                res = u'%sp' % format['height']
+        else:
+            res =  '???'
+        return res
+
     def list_formats(self, info_dict):
         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', '???'),
-                                                )
-                            )
+            formats_s.append(u'%-15s: %-5s     %-15s[%s]' % (
+                format['format_id'],
+                format['ext'],
+                format.get('format_note') or '-',
+                self.format_resolution(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)) 
+        self.to_screen(u'[info] Available formats for %s:\n'
+            u'format code    extension   note           resolution\n%s' % (
+                info_dict['id'], formats_s))
index d4af3b5ebf119ef6612093bd6a5c03d1cc6cc380..7d7ce5d98a7ef21ccb1fe6897ebad9dd996cc649 100644 (file)
@@ -61,9 +61,12 @@ class InfoExtractor(object):
                     * ext       Will be calculated from url if missing
                     * format    A human-readable description of the format
                                 ("mp4 container with h264/opus").
-                                Calculated from width and height if missing.
+                                Calculated from the format_id, width, height 
+                                and format_note fields if missing.
                     * format_id A short description of the format
                                 ("mp4_h264_opus" or "19")
+                    * format_note Additional info about the format
+                                ("3D" or "DASH video")
                     * width     Width of the video, if known
                     * height    Height of the video, if known