[6play] Extract subtitles (closes #15541)

This commit is contained in:
Sergey M․ 2018-02-10 00:04:08 +07:00
parent 042968ff31
commit ff873b5777
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D

View file

@ -52,6 +52,7 @@ def _real_extract(self, url):
urls = [] urls = []
quality_key = qualities(['lq', 'sd', 'hq', 'hd']) quality_key = qualities(['lq', 'sd', 'hq', 'hd'])
formats = [] formats = []
subtitles = {}
for asset in clip_data['assets']: for asset in clip_data['assets']:
asset_url = asset.get('full_physical_path') asset_url = asset.get('full_physical_path')
protocol = asset.get('protocol') protocol = asset.get('protocol')
@ -60,6 +61,9 @@ def _real_extract(self, url):
urls.append(asset_url) urls.append(asset_url)
container = asset.get('video_container') container = asset.get('video_container')
ext = determine_ext(asset_url) ext = determine_ext(asset_url)
if protocol == 'http_subtitle' or ext == 'vtt':
subtitles.setdefault('fr', []).append({'url': asset_url})
continue
if container == 'm3u8' or ext == 'm3u8': if container == 'm3u8' or ext == 'm3u8':
if protocol == 'usp' and not compat_parse_qs(compat_urllib_parse_urlparse(asset_url).query).get('token', [None])[0]: if protocol == 'usp' and not compat_parse_qs(compat_urllib_parse_urlparse(asset_url).query).get('token', [None])[0]:
asset_url = re.sub(r'/([^/]+)\.ism/[^/]*\.m3u8', r'/\1.ism/\1.m3u8', asset_url) asset_url = re.sub(r'/([^/]+)\.ism/[^/]*\.m3u8', r'/\1.ism/\1.m3u8', asset_url)
@ -102,4 +106,5 @@ def get(getter):
'duration': int_or_none(clip_data.get('duration')), 'duration': int_or_none(clip_data.get('duration')),
'series': get(lambda x: x['program']['title']), 'series': get(lambda x: x['program']['title']),
'formats': formats, 'formats': formats,
'subtitles': subtitles,
} }