[ie/RadioRadicale] Merge subtitles; clean code

This commit is contained in:
Mozi 2024-10-09 16:49:42 +00:00 committed by bashonly
parent 052534bcc2
commit 6311170b6a
No known key found for this signature in database
GPG key ID: 783F096F253D15B0

View file

@ -1,8 +1,6 @@
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import url_or_none
strftime_or_none, from ..utils.traversal import traverse_obj
traverse_obj,
)
class RadioRadicaleIE(InfoExtractor): class RadioRadicaleIE(InfoExtractor):
@ -38,10 +36,12 @@ def _real_extract(self, url):
formats.extend( formats.extend(
self._extract_m3u8_formats(source.get('src'), video_id)) self._extract_m3u8_formats(source.get('src'), video_id))
subtitles = {sub.get('srclang') or 'und': [{ subtitles = {}
for sub in traverse_obj(video_info, ('playlist', 0, 'subtitles')):
self._merge_subtitles({sub.get('srclang') or 'und': [{
'url': sub.get('src'), 'url': sub.get('src'),
'name': sub.get('label') 'name': sub.get('label'),
}] for sub in traverse_obj(video_info, ('playlist', 0, 'subtitles', ...))} }]}, target=subtitles)
return { return {
'id': video_id, 'id': video_id,
@ -50,7 +50,6 @@ def _real_extract(self, url):
'title': json_ld.get('title') or self._og_search_title(webpage), 'title': json_ld.get('title') or self._og_search_title(webpage),
'location': video_info.get('luogo'), 'location': video_info.get('luogo'),
'timestamp': json_ld.get('timestamp'), 'timestamp': json_ld.get('timestamp'),
'upload_date': strftime_or_none(json_ld.get('timestamp'), '%Y%m%d'), 'thumbnail': traverse_obj(json_ld, ('thumbnails', 0, 'url', {url_or_none})),
'thumbnail': traverse_obj(json_ld, ('thumbnails', 0, 'url')),
'description': json_ld.get('description') or self._og_search_description(webpage), 'description': json_ld.get('description') or self._og_search_description(webpage),
} }