From 47f4203dd3cf0f75eee2b61b7be8a84aa4947f26 Mon Sep 17 00:00:00 2001 From: Felix S Date: Thu, 15 Apr 2021 10:14:46 +0200 Subject: [PATCH] [nytimes] Extract subtitles from HLS manifests --- yt_dlp/extractor/nytimes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yt_dlp/extractor/nytimes.py b/yt_dlp/extractor/nytimes.py index 1f03a9462..99964737d 100644 --- a/yt_dlp/extractor/nytimes.py +++ b/yt_dlp/extractor/nytimes.py @@ -46,6 +46,7 @@ def get_file_size(file_size): urls = [] formats = [] + subtitles = {} for video in video_data.get('renditions', []): video_url = video.get('url') format_id = video.get('type') @@ -54,9 +55,11 @@ def get_file_size(file_size): urls.append(video_url) ext = mimetype2ext(video.get('mimetype')) or determine_ext(video_url) if ext == 'm3u8': - formats.extend(self._extract_m3u8_formats( + m3u8_fmts, m3u8_subs = self._extract_m3u8_formats_and_subtitles( video_url, video_id, 'mp4', 'm3u8_native', - m3u8_id=format_id or 'hls', fatal=False)) + m3u8_id=format_id or 'hls', fatal=False) + formats.extend(m3u8_fmts) + subtitles = self._merge_subtitles(subtitles, m3u8_subs) elif ext == 'mpd': continue # formats.extend(self._extract_mpd_formats( @@ -96,6 +99,7 @@ def get_file_size(file_size): 'uploader': video_data.get('byline'), 'duration': float_or_none(video_data.get('duration'), 1000), 'formats': formats, + 'subtitles': subtitles, 'thumbnails': thumbnails, }