mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-01-03 06:01:02 +00:00
[wat] Extract subtitles from streaming manifests
This commit is contained in:
parent
c811e8d8bd
commit
ec4f374c05
1 changed files with 10 additions and 4 deletions
|
@ -69,19 +69,24 @@ def _real_extract(self, url):
|
||||||
title = video_info['title']
|
title = video_info['title']
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
|
subtitles = {}
|
||||||
|
|
||||||
def extract_formats(manifest_urls):
|
def extract_formats(manifest_urls):
|
||||||
for f, f_url in manifest_urls.items():
|
for f, f_url in manifest_urls.items():
|
||||||
if not f_url:
|
if not f_url:
|
||||||
continue
|
continue
|
||||||
if f in ('dash', 'mpd'):
|
if f in ('dash', 'mpd'):
|
||||||
formats.extend(self._extract_mpd_formats(
|
fmts, subs = self._extract_mpd_formats_and_subtitles(
|
||||||
f_url.replace('://das-q1.tf1.fr/', '://das-q1-ssl.tf1.fr/'),
|
f_url.replace('://das-q1.tf1.fr/', '://das-q1-ssl.tf1.fr/'),
|
||||||
video_id, mpd_id='dash', fatal=False))
|
video_id, mpd_id='dash', fatal=False)
|
||||||
elif f == 'hls':
|
elif f == 'hls':
|
||||||
formats.extend(self._extract_m3u8_formats(
|
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
||||||
f_url, video_id, 'mp4',
|
f_url, video_id, 'mp4',
|
||||||
'm3u8_native', m3u8_id='hls', fatal=False))
|
'm3u8_native', m3u8_id='hls', fatal=False)
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
formats.extend(fmts)
|
||||||
|
self._merge_subtitles(subs, target=subtitles)
|
||||||
|
|
||||||
delivery = video_data.get('delivery') or {}
|
delivery = video_data.get('delivery') or {}
|
||||||
extract_formats({delivery.get('format'): delivery.get('url')})
|
extract_formats({delivery.get('format'): delivery.get('url')})
|
||||||
|
@ -103,4 +108,5 @@ def extract_formats(manifest_urls):
|
||||||
video_data, lambda x: x['mediametrie']['chapters'][0]['estatS4'])),
|
video_data, lambda x: x['mediametrie']['chapters'][0]['estatS4'])),
|
||||||
'duration': int_or_none(video_info.get('duration')),
|
'duration': int_or_none(video_info.get('duration')),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
|
'subtitles': subtitles,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue