]> git.bitcoin.ninja Git - youtube-dl/commitdiff
Add automatic generation of format note based on bitrate and codecs
authorPhilipp Hagemeister <phihag@phihag.de>
Sat, 16 Nov 2013 00:08:43 +0000 (01:08 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Sat, 16 Nov 2013 00:08:43 +0000 (01:08 +0100)
youtube_dl/YoutubeDL.py
youtube_dl/extractor/common.py
youtube_dl/extractor/vevo.py

index b5c670dd475b9f7081470cd60209bde5d4aabf8e..9c79af1f24f8343d7d0804cfbb4600f0031d0e4e 100644 (file)
@@ -781,12 +781,28 @@ class YoutubeDL(object):
         return res
 
     def list_formats(self, info_dict):
+        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 += fdict['vcodec']
+            if fdict.get('vbr') is not None:
+                res += u'@%4dk' % fdict['vbr']
+            if fdict.get('acodec') is not None:
+                if res:
+                    res += u', '
+                res += fdict['acodec']
+            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.get('format_note', ''),
+                format_note(format),
                 )
             )
 
index 45dd01789b786da425545a528edc4838cb91de19..f787d0a3c0b3afd47f38ddbb09eab8476126516d 100644 (file)
@@ -71,6 +71,10 @@ class InfoExtractor(object):
                                 ("3D" or "DASH video")
                     * width     Width of the video, if known
                     * height    Height of the video, if known
+                    * abr       Average audio bitrate in KBit/s
+                    * acodec    Name of the audio codec in use
+                    * vbr       Average video bitrate in KBit/s
+                    * vcodec    Name of the video codec in use
     webpage_url:    The url to the video webpage, if given to youtube-dl it
                     should allow to get the same result again. (It will be set
                     by YoutubeDL if it's missing)
index 3f6020f74ec9eeefbddafc184d3f48cf5e436adb..4378b17800f1df78275d68a9525ca95585dc8b9d 100644 (file)
@@ -78,12 +78,13 @@ class VevoIE(InfoExtractor):
                 continue
 
             format_url = self._SMIL_BASE_URL + m.group('path')
-            format_note = ('%(vcodec)s@%(vbr)4sk, %(acodec)s@%(abr)3sk' %
-                           m.groupdict())
             formats.append({
                 'url': format_url,
                 'format_id': u'SMIL_' + m.group('cbr'),
-                'format_note': format_note,
+                'vcodec': m.group('vcodec'),
+                'acodec': m.group('acodec'),
+                'vbr': int(m.group('vbr')),
+                'abr': int(m.group('abr')),
                 'ext': m.group('ext'),
                 'width': int(m.group('width')),
                 'height': int(m.group('height')),