From b2cd5da460d4ee2d376f0af68bdaadce93d0dd58 Mon Sep 17 00:00:00 2001 From: Felix S Date: Sun, 18 Apr 2021 15:47:49 +0200 Subject: [PATCH] [francetv] Extract subtitles from the HLS manifest --- yt_dlp/extractor/francetv.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/yt_dlp/extractor/francetv.py b/yt_dlp/extractor/francetv.py index 313de343e..e57e165fc 100644 --- a/yt_dlp/extractor/francetv.py +++ b/yt_dlp/extractor/francetv.py @@ -151,6 +151,7 @@ def sign(manifest_url, manifest_id): videos.append(fallback_info['video']) formats = [] + subtitles = {} for video in videos: video_url = video.get('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', video_id, f4m_id=format_id, fatal=False)) 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', 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': formats.extend(self._extract_mpd_formats( 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 = title.strip() - subtitles = {} - subtitles_list = [{ - 'url': subformat['url'], - 'ext': subformat.get('format'), - } for subformat in info.get('subtitles', []) if subformat.get('url')] - if subtitles_list: - subtitles['fr'] = subtitles_list + subtitles.setdefault('fr', []).extend( + [{ + 'url': subformat['url'], + 'ext': subformat.get('format'), + } for subformat in info.get('subtitles', []) if subformat.get('url')] + ) return { 'id': video_id,