浏览代码

[jwplatform] Extract height from label

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

+ 8 - 1
youtube_dl/extractor/jwplatform.py

@@ -63,10 +63,17 @@ class JWPlatformBaseIE(InfoExtractor):
                         'ext': ext,
                     })
                 else:
+                    height = int_or_none(source.get('height'))
+                    if height is None:
+                        # Often no height is provided but there is a label in
+                        # format like 1080p.
+                        height = int_or_none(self._search_regex(
+                            r'^(\d{3,})[pP]$', source.get('label') or '',
+                            'height', default=None))
                     a_format = {
                         'url': source_url,
                         'width': int_or_none(source.get('width')),
-                        'height': int_or_none(source.get('height')),
+                        'height': height,
                         'ext': ext,
                     }
                     if source_url.startswith('rtmp'):