[extractor/common] Auto calculate tbr when missing
authorSergey M․ <dstftw@gmail.com>
Wed, 27 Jan 2016 15:11:17 +0000 (21:11 +0600)
committerSergey M․ <dstftw@gmail.com>
Wed, 27 Jan 2016 15:11:17 +0000 (21:11 +0600)
youtube_dl/extractor/common.py

index 2f574054d7bb17f6f71745d2b045ee8f8df81f40..f5a35838886e718d1c0064c28783ff8fb0f3e928 100644 (file)
@@ -825,6 +825,12 @@ class InfoExtractor(object):
         if not formats:
             raise ExtractorError('No video formats found')
 
+        for f in formats:
+            # Automatically determine tbr when missing based on abr and vbr (improves
+            # formats sorting in some cases)
+            if 'tbr' not in f and 'abr' in f and 'vbr' in f:
+                f['tbr'] = f['abr'] + f['vbr']
+
         def _formats_key(f):
             # TODO remove the following workaround
             from ..utils import determine_ext