1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2025-02-06 18:20:02 +00:00

[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'
This commit is contained in:
John Hawkinson 2016-10-10 02:07:34 -04:00
parent c1ce8deed8
commit 00253f8312

View File

@ -50,7 +50,11 @@ class JWPlatformBaseIE(InfoExtractor):
# JWPlayer backward compatibility: flattened sources # JWPlayer backward compatibility: flattened sources
# https://github.com/jwplayer/jwplayer/blob/v7.4.3/src/js/playlist/item.js#L29-L35 # https://github.com/jwplayer/jwplayer/blob/v7.4.3/src/js/playlist/item.js#L29-L35
if 'sources' not in video_data: 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'] this_video_id = video_id or video_data['mediaid']
@ -78,9 +82,10 @@ class JWPlatformBaseIE(InfoExtractor):
height = int_or_none(source.get('height')) height = int_or_none(source.get('height'))
if height is None: if height is None:
# Often no height is provided but there is a label in # 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( 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)) 'height', default=None))
a_format = { a_format = {
'url': source_url, 'url': source_url,