From ad9158d5f46658b31523e937974b305618271570 Mon Sep 17 00:00:00 2001 From: Felix S Date: Fri, 21 Jan 2022 06:58:22 +0000 Subject: [PATCH] [ard] Extract subtitles (#2409) Fixes https://github.com/ytdl-org/youtube-dl/issues/30543, related: https://github.com/ytdl-org/youtube-dl/pull/17766 Authored by: fstirlitz --- yt_dlp/extractor/ard.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/yt_dlp/extractor/ard.py b/yt_dlp/extractor/ard.py index 1aff0361c..4ad5d6ddd 100644 --- a/yt_dlp/extractor/ard.py +++ b/yt_dlp/extractor/ard.py @@ -376,9 +376,24 @@ class ARDIE(InfoExtractor): formats.append(f) self._sort_formats(formats) + _SUB_FORMATS = ( + ('./dataTimedText', 'ttml'), + ('./dataTimedTextNoOffset', 'ttml'), + ('./dataTimedTextVtt', 'vtt'), + ) + + subtitles = {} + for subsel, subext in _SUB_FORMATS: + for node in video_node.findall(subsel): + subtitles.setdefault('de', []).append({ + 'url': node.attrib['url'], + 'ext': subext, + }) + return { 'id': xpath_text(video_node, './videoId', default=display_id), 'formats': formats, + 'subtitles': subtitles, 'display_id': display_id, 'title': video_node.find('./title').text, 'duration': parse_duration(video_node.find('./duration').text),