From efe9dba595cb8b1c129b9e65541adf5febf421e6 Mon Sep 17 00:00:00 2001 From: Felix S Date: Thu, 15 Apr 2021 10:16:15 +0200 Subject: [PATCH] [srgssr] Extract subtitles from HLS manifests --- yt_dlp/extractor/srgssr.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/yt_dlp/extractor/srgssr.py b/yt_dlp/extractor/srgssr.py index ac018e740..2977b5e67 100644 --- a/yt_dlp/extractor/srgssr.py +++ b/yt_dlp/extractor/srgssr.py @@ -87,6 +87,7 @@ class SRGSSRIE(InfoExtractor): title = media_data['title'] formats = [] + subtitles = {} q = qualities(['SD', 'HD']) for source in (media_data.get('resourceList') or []): format_url = source.get('url') @@ -104,12 +105,16 @@ class SRGSSRIE(InfoExtractor): if source.get('tokenType') == 'AKAMAI': format_url = self._get_tokenized_src( format_url, media_id, format_id) - formats.extend(self._extract_akamai_formats( - format_url, media_id)) + fmts, subs = self._extract_akamai_formats_and_subtitles( + format_url, media_id) + formats.extend(fmts) + subtitles = self._merge_subtitles(subtitles, subs) elif protocol == 'HLS': - formats.extend(self._extract_m3u8_formats( + m3u8_fmts, m3u8_subs = self._extract_m3u8_formats_and_subtitles( format_url, media_id, 'mp4', 'm3u8_native', - m3u8_id=format_id, fatal=False)) + m3u8_id=format_id, fatal=False) + formats.extend(m3u8_fmts) + subtitles = self._merge_subtitles(subtitles, m3u8_subs) elif protocol in ('HTTP', 'HTTPS'): formats.append({ 'format_id': format_id, @@ -133,7 +138,6 @@ class SRGSSRIE(InfoExtractor): }) self._sort_formats(formats) - subtitles = {} if media_type == 'video': for sub in (media_data.get('subtitleList') or []): sub_url = sub.get('url')