aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/youtube.py
diff options
context:
space:
mode:
authorremitamine <remitamine@gmail.com>2016-03-02 17:52:13 +0100
committerremitamine <remitamine@gmail.com>2016-03-02 17:52:13 +0100
commit3318832e9d42e85160ff2dab01d0f52ed739fbd6 (patch)
tree76d9b4f3678a079a5167af6f7ec604b45be30c10 /youtube_dl/extractor/youtube.py
parente7d20845686e0a35fc386238713ea4bdde89bdcf (diff)
downloadyoutube-dl-3318832e9d42e85160ff2dab01d0f52ed739fbd6.tar.xz
[youtube] improve width and height extraction from fmt_list
Diffstat (limited to 'youtube_dl/extractor/youtube.py')
-rw-r--r--youtube_dl/extractor/youtube.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index 56e6bd096..e4bef8f2f 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -1399,16 +1399,19 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
encoded_url_map = video_info.get('url_encoded_fmt_stream_map', [''])[0] + ',' + video_info.get('adaptive_fmts', [''])[0]
if 'rtmpe%3Dyes' in encoded_url_map:
raise ExtractorError('rtmpe downloads are not supported, see https://github.com/rg3/youtube-dl/issues/343 for more information.', expected=True)
+ formats_spec = {}
fmt_list = video_info.get('fmt_list', [''])[0]
if fmt_list:
for fmt in fmt_list.split(','):
spec = fmt.split('/')
- width, height = spec[1].split('x')
- self._formats[spec[0]].update({
- 'resolution': spec[1],
- 'width': int_or_none(width),
- 'height': int_or_none(height),
- })
+ if len(spec) > 1:
+ width_height = spec[1].split('x')
+ if len(width_height) == 2:
+ formats_spec[spec[0]] = {
+ 'resolution': spec[1],
+ 'width': int_or_none(width_height[0]),
+ 'height': int_or_none(width_height[1]),
+ }
formats = []
for url_data_str in encoded_url_map.split(','):
url_data = compat_parse_qs(url_data_str)
@@ -1477,6 +1480,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
}
if format_id in self._formats:
dct.update(self._formats[format_id])
+ if format_id in formats_spec:
+ dct.update(formats_spec[format_id])
# Some itags are not included in DASH manifest thus corresponding formats will
# lack metadata (see https://github.com/rg3/youtube-dl/pull/5993).