[ARD] Back-port subtitle extraction from yt-dlp PR 2409
authordirkf <fieldhouse@gmx.net>
Mon, 7 Feb 2022 13:28:21 +0000 (13:28 +0000)
committerdirkf <fieldhouse@gmx.net>
Mon, 7 Feb 2022 13:47:38 +0000 (13:47 +0000)
Authored by: fstirlitz
Fixes #30543
Closes #17766 (thanks ngdio)

youtube_dl/extractor/ard.py

index d45a9fe5226496e9d396128e774e543c8cb4bdbe..a5b1f54d5bc3f09f0963738ce36a9325377b466b 100644 (file)
@@ -332,9 +332,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),