From 6311170b6adb4391d2ec844639c08ecdd3cc3d67 Mon Sep 17 00:00:00 2001 From: Mozi <29089388+pzhlkj6612@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:49:42 +0000 Subject: [PATCH] [ie/RadioRadicale] Merge subtitles; clean code --- yt_dlp/extractor/radioradicale.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/yt_dlp/extractor/radioradicale.py b/yt_dlp/extractor/radioradicale.py index 3ad46fe391..aa2326c010 100644 --- a/yt_dlp/extractor/radioradicale.py +++ b/yt_dlp/extractor/radioradicale.py @@ -1,8 +1,6 @@ from .common import InfoExtractor -from ..utils import ( - strftime_or_none, - traverse_obj, -) +from ..utils import url_or_none +from ..utils.traversal import traverse_obj class RadioRadicaleIE(InfoExtractor): @@ -38,10 +36,12 @@ def _real_extract(self, url): formats.extend( self._extract_m3u8_formats(source.get('src'), video_id)) - subtitles = {sub.get('srclang') or 'und': [{ - 'url': sub.get('src'), - 'name': sub.get('label') - }] for sub in traverse_obj(video_info, ('playlist', 0, 'subtitles', ...))} + subtitles = {} + for sub in traverse_obj(video_info, ('playlist', 0, 'subtitles')): + self._merge_subtitles({sub.get('srclang') or 'und': [{ + 'url': sub.get('src'), + 'name': sub.get('label'), + }]}, target=subtitles) return { 'id': video_id, @@ -50,7 +50,6 @@ def _real_extract(self, url): 'title': json_ld.get('title') or self._og_search_title(webpage), 'location': video_info.get('luogo'), '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')), + 'thumbnail': traverse_obj(json_ld, ('thumbnails', 0, 'url', {url_or_none})), 'description': json_ld.get('description') or self._og_search_description(webpage), }