0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-26 02:55:17 +00:00

[francetv] Extract subtitles from the HLS manifest

This commit is contained in:
Felix S 2021-04-18 15:47:49 +02:00
parent 2de3b21e05
commit b2cd5da460

View file

@ -151,6 +151,7 @@ def sign(manifest_url, manifest_id):
videos.append(fallback_info['video']) videos.append(fallback_info['video'])
formats = [] formats = []
subtitles = {}
for video in videos: for video in videos:
video_url = video.get('url') video_url = video.get('url')
if not video_url: if not video_url:
@ -171,10 +172,12 @@ def sign(manifest_url, manifest_id):
sign(video_url, format_id) + '&hdcore=3.7.0&plugin=aasp-3.7.0.39.44', sign(video_url, format_id) + '&hdcore=3.7.0&plugin=aasp-3.7.0.39.44',
video_id, f4m_id=format_id, fatal=False)) video_id, f4m_id=format_id, fatal=False))
elif ext == 'm3u8': elif ext == 'm3u8':
formats.extend(self._extract_m3u8_formats( m3u8_fmts, m3u8_subs = self._extract_m3u8_formats_and_subtitles(
sign(video_url, format_id), video_id, 'mp4', sign(video_url, format_id), video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id=format_id, entry_protocol='m3u8_native', m3u8_id=format_id,
fatal=False)) fatal=False)
formats.extend(m3u8_fmts)
subtitles = self._merge_subtitles(subtitles, m3u8_subs)
elif ext == 'mpd': elif ext == 'mpd':
formats.extend(self._extract_mpd_formats( formats.extend(self._extract_mpd_formats(
sign(video_url, format_id), video_id, mpd_id=format_id, fatal=False)) sign(video_url, format_id), video_id, mpd_id=format_id, fatal=False))
@ -199,13 +202,12 @@ def sign(manifest_url, manifest_id):
title += ' - %s' % subtitle title += ' - %s' % subtitle
title = title.strip() title = title.strip()
subtitles = {} subtitles.setdefault('fr', []).extend(
subtitles_list = [{ [{
'url': subformat['url'], 'url': subformat['url'],
'ext': subformat.get('format'), 'ext': subformat.get('format'),
} for subformat in info.get('subtitles', []) if subformat.get('url')] } for subformat in info.get('subtitles', []) if subformat.get('url')]
if subtitles_list: )
subtitles['fr'] = subtitles_list
return { return {
'id': video_id, 'id': video_id,