[ie/tv5mondeplus] Extract subtitles (#4209)

Closes #4205
Authored by: FrankZ85
This commit is contained in:
FrankZ85 2023-11-15 23:38:52 +01:00 committed by GitHub
parent 21dc069bea
commit 0f634dba3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,6 +84,13 @@ class TV5MondePlusIE(InfoExtractor):
}] }]
_GEO_BYPASS = False _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): def _real_extract(self, url):
display_id = self._match_id(url) display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id) webpage = self._download_webpage(url, display_id)
@ -176,6 +183,8 @@ def process_video_files(v):
'duration': duration, 'duration': duration,
'upload_date': upload_date, 'upload_date': upload_date,
'formats': formats, 'formats': formats,
'subtitles': self._extract_subtitles(self._parse_json(
traverse_obj(vpl_data, ('data-captions', {str}), default='{}'), display_id, fatal=False)),
'series': series, 'series': series,
'episode': episode, 'episode': episode,
} }