From 00253f8312b0860fef8d9178d03fcb39cef6e0cd Mon Sep 17 00:00:00 2001 From: John Hawkinson Date: Mon, 10 Oct 2016 02:07:34 -0400 Subject: [PATCH] [JWPlatformBase] handle a few more cases * If our parsed JSON ends up as a list, rather than a dict, then store it in ['sources'] as that list, rather than trying to wrap it in an array, which leads to type errors. (Such a list indicates multiple file formats/sources, rather than a playlist.) * Allow format labels like 'SD 480' and 'HD 720' in addition to '1080p' --- youtube_dl/extractor/jwplatform.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/jwplatform.py b/youtube_dl/extractor/jwplatform.py index 5d56e0a28..ff7097160 100644 --- a/youtube_dl/extractor/jwplatform.py +++ b/youtube_dl/extractor/jwplatform.py @@ -50,7 +50,11 @@ class JWPlatformBaseIE(InfoExtractor): # JWPlayer backward compatibility: flattened sources # https://github.com/jwplayer/jwplayer/blob/v7.4.3/src/js/playlist/item.js#L29-L35 if 'sources' not in video_data: - video_data['sources'] = [video_data] + if isinstance(video_data, list): + video_data = {'sources': video_data } + video_data['tracks'] = video_data['sources'][0].get('tracks') + else: + video_data['sources'] = [video_data] this_video_id = video_id or video_data['mediaid'] @@ -78,9 +82,10 @@ class JWPlatformBaseIE(InfoExtractor): 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. + # format like 1080p or 'SD 480' height = int_or_none(self._search_regex( - r'^(\d{3,})[pP]$', source.get('label') or '', + [r'^(\d{3,})[pP]$', r'^[SH]D (\d{3,})$'], + source.get('label') or '', 'height', default=None)) a_format = { 'url': source_url,