]> jfr.im git - yt-dlp.git/commitdiff
[ie/tv5mondeplus] Extract subtitles (#4209)
authorFrankZ85 <redacted>
Wed, 15 Nov 2023 22:38:52 +0000 (23:38 +0100)
committerGitHub <redacted>
Wed, 15 Nov 2023 22:38:52 +0000 (22:38 +0000)
Closes #4205
Authored by: FrankZ85

yt_dlp/extractor/tv5mondeplus.py

index 4da1b26d1a46df3b5a23b49deeb0ba2b7f86c8c9..a445fae853f64b65a0ee19fbdae6ce4878a74d65 100644 (file)
@@ -84,6 +84,13 @@ class TV5MondePlusIE(InfoExtractor):
     }]
     _GEO_BYPASS = False
 
+    @staticmethod
+    def _extract_subtitles(data_captions):
+        subtitles = {}
+        for f in traverse_obj(data_captions, ('files', lambda _, v: url_or_none(v['file']))):
+            subtitles.setdefault(f.get('label') or 'fra', []).append({'url': f['file']})
+        return subtitles
+
     def _real_extract(self, url):
         display_id = self._match_id(url)
         webpage = self._download_webpage(url, display_id)
@@ -176,6 +183,8 @@ def process_video_files(v):
             'duration': duration,
             'upload_date': upload_date,
             'formats': formats,
+            'subtitles': self._extract_subtitles(self._parse_json(
+                traverse_obj(vpl_data, ('data-captions', {str}), default='{}'), display_id, fatal=False)),
             'series': series,
             'episode': episode,
         }