浏览代码

[extractor/common] Auto calculate tbr when missing

Sergey M․ 9 年之前
父节点
当前提交
b0d21deda9
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      youtube_dl/extractor/common.py

+ 6 - 0
youtube_dl/extractor/common.py

@@ -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