mirror of https://github.com/yt-dlp/yt-dlp.git
[canvas] Extract subtitles from streaming manifests
This commit is contained in:
parent
ec4f374c05
commit
e0e624ca7f
|
@ -83,24 +83,31 @@ class CanvasIE(InfoExtractor):
|
||||||
description = data.get('description')
|
description = data.get('description')
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
|
subtitles = {}
|
||||||
for target in data['targetUrls']:
|
for target in data['targetUrls']:
|
||||||
format_url, format_type = url_or_none(target.get('url')), str_or_none(target.get('type'))
|
format_url, format_type = url_or_none(target.get('url')), str_or_none(target.get('type'))
|
||||||
if not format_url or not format_type:
|
if not format_url or not format_type:
|
||||||
continue
|
continue
|
||||||
format_type = format_type.upper()
|
format_type = format_type.upper()
|
||||||
if format_type in self._HLS_ENTRY_PROTOCOLS_MAP:
|
if format_type in self._HLS_ENTRY_PROTOCOLS_MAP:
|
||||||
formats.extend(self._extract_m3u8_formats(
|
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
||||||
format_url, video_id, 'mp4', self._HLS_ENTRY_PROTOCOLS_MAP[format_type],
|
format_url, video_id, 'mp4', self._HLS_ENTRY_PROTOCOLS_MAP[format_type],
|
||||||
m3u8_id=format_type, fatal=False))
|
m3u8_id=format_type, fatal=False)
|
||||||
|
formats.extend(fmts)
|
||||||
|
subtitles = self._merge_subtitles(subtitles, subs)
|
||||||
elif format_type == 'HDS':
|
elif format_type == 'HDS':
|
||||||
formats.extend(self._extract_f4m_formats(
|
formats.extend(self._extract_f4m_formats(
|
||||||
format_url, video_id, f4m_id=format_type, fatal=False))
|
format_url, video_id, f4m_id=format_type, fatal=False))
|
||||||
elif format_type == 'MPEG_DASH':
|
elif format_type == 'MPEG_DASH':
|
||||||
formats.extend(self._extract_mpd_formats(
|
fmts, subs = self._extract_mpd_formats_and_subtitles(
|
||||||
format_url, video_id, mpd_id=format_type, fatal=False))
|
format_url, video_id, mpd_id=format_type, fatal=False)
|
||||||
|
formats.extend(fmts)
|
||||||
|
subtitles = self._merge_subtitles(subtitles, subs)
|
||||||
elif format_type == 'HSS':
|
elif format_type == 'HSS':
|
||||||
formats.extend(self._extract_ism_formats(
|
fmts, subs = self._extract_ism_formats_and_subtitles(
|
||||||
format_url, video_id, ism_id='mss', fatal=False))
|
format_url, video_id, ism_id='mss', fatal=False)
|
||||||
|
formats.extend(fmts)
|
||||||
|
subtitles = self._merge_subtitles(subtitles, subs)
|
||||||
else:
|
else:
|
||||||
formats.append({
|
formats.append({
|
||||||
'format_id': format_type,
|
'format_id': format_type,
|
||||||
|
@ -108,7 +115,6 @@ class CanvasIE(InfoExtractor):
|
||||||
})
|
})
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
subtitles = {}
|
|
||||||
subtitle_urls = data.get('subtitleUrls')
|
subtitle_urls = data.get('subtitleUrls')
|
||||||
if isinstance(subtitle_urls, list):
|
if isinstance(subtitle_urls, list):
|
||||||
for subtitle in subtitle_urls:
|
for subtitle in subtitle_urls:
|
||||||
|
|
Loading…
Reference in New Issue