|
|
@ -23,23 +23,27 @@ class SVTBaseIE(InfoExtractor):
|
|
|
|
is_live = dict_get(video_info, ('live', 'simulcast'), default=False)
|
|
|
|
is_live = dict_get(video_info, ('live', 'simulcast'), default=False)
|
|
|
|
m3u8_protocol = 'm3u8' if is_live else 'm3u8_native'
|
|
|
|
m3u8_protocol = 'm3u8' if is_live else 'm3u8_native'
|
|
|
|
formats = []
|
|
|
|
formats = []
|
|
|
|
|
|
|
|
subtitles = {}
|
|
|
|
for vr in video_info['videoReferences']:
|
|
|
|
for vr in video_info['videoReferences']:
|
|
|
|
player_type = vr.get('playerType') or vr.get('format')
|
|
|
|
player_type = vr.get('playerType') or vr.get('format')
|
|
|
|
vurl = vr['url']
|
|
|
|
vurl = vr['url']
|
|
|
|
ext = determine_ext(vurl)
|
|
|
|
ext = determine_ext(vurl)
|
|
|
|
if ext == 'm3u8':
|
|
|
|
if ext == 'm3u8':
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
|
|
|
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
|
|
|
vurl, video_id,
|
|
|
|
vurl, video_id,
|
|
|
|
ext='mp4', entry_protocol=m3u8_protocol,
|
|
|
|
ext='mp4', entry_protocol=m3u8_protocol,
|
|
|
|
m3u8_id=player_type, fatal=False))
|
|
|
|
m3u8_id=player_type, fatal=False)
|
|
|
|
|
|
|
|
formats.extend(fmts)
|
|
|
|
|
|
|
|
self._merge_subtitles(subs, target=subtitles)
|
|
|
|
elif ext == 'f4m':
|
|
|
|
elif ext == 'f4m':
|
|
|
|
formats.extend(self._extract_f4m_formats(
|
|
|
|
formats.extend(self._extract_f4m_formats(
|
|
|
|
vurl + '?hdcore=3.3.0', video_id,
|
|
|
|
vurl + '?hdcore=3.3.0', video_id,
|
|
|
|
f4m_id=player_type, fatal=False))
|
|
|
|
f4m_id=player_type, fatal=False))
|
|
|
|
elif ext == 'mpd':
|
|
|
|
elif ext == 'mpd':
|
|
|
|
if player_type == 'dashhbbtv':
|
|
|
|
fmts, subs = self._extract_mpd_formats_and_subtitles(
|
|
|
|
formats.extend(self._extract_mpd_formats(
|
|
|
|
vurl, video_id, mpd_id=player_type, fatal=False)
|
|
|
|
vurl, video_id, mpd_id=player_type, fatal=False))
|
|
|
|
formats.extend(fmts)
|
|
|
|
|
|
|
|
self._merge_subtitles(subs, target=subtitles)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
formats.append({
|
|
|
|
formats.append({
|
|
|
|
'format_id': player_type,
|
|
|
|
'format_id': player_type,
|
|
|
@ -52,18 +56,19 @@ class SVTBaseIE(InfoExtractor):
|
|
|
|
countries=self._GEO_COUNTRIES, metadata_available=True)
|
|
|
|
countries=self._GEO_COUNTRIES, metadata_available=True)
|
|
|
|
self._sort_formats(formats)
|
|
|
|
self._sort_formats(formats)
|
|
|
|
|
|
|
|
|
|
|
|
subtitles = {}
|
|
|
|
|
|
|
|
subtitle_references = dict_get(video_info, ('subtitles', 'subtitleReferences'))
|
|
|
|
subtitle_references = dict_get(video_info, ('subtitles', 'subtitleReferences'))
|
|
|
|
if isinstance(subtitle_references, list):
|
|
|
|
if isinstance(subtitle_references, list):
|
|
|
|
for sr in subtitle_references:
|
|
|
|
for sr in subtitle_references:
|
|
|
|
subtitle_url = sr.get('url')
|
|
|
|
subtitle_url = sr.get('url')
|
|
|
|
subtitle_lang = sr.get('language', 'sv')
|
|
|
|
subtitle_lang = sr.get('language', 'sv')
|
|
|
|
if subtitle_url:
|
|
|
|
if subtitle_url:
|
|
|
|
|
|
|
|
sub = {
|
|
|
|
|
|
|
|
'url': subtitle_url,
|
|
|
|
|
|
|
|
}
|
|
|
|
if determine_ext(subtitle_url) == 'm3u8':
|
|
|
|
if determine_ext(subtitle_url) == 'm3u8':
|
|
|
|
# TODO(yan12125): handle WebVTT in m3u8 manifests
|
|
|
|
# XXX: no way of testing, is it ever hit?
|
|
|
|
continue
|
|
|
|
sub['ext'] = 'vtt'
|
|
|
|
|
|
|
|
subtitles.setdefault(subtitle_lang, []).append(sub)
|
|
|
|
subtitles.setdefault(subtitle_lang, []).append({'url': subtitle_url})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
title = video_info.get('title')
|
|
|
|
title = video_info.get('title')
|
|
|
|
|
|
|
|
|
|
|
|