From 4f07c29a31939c0a0a08526a943f1d0d221b24e6 Mon Sep 17 00:00:00 2001 From: Sean Ellingham Date: Mon, 24 Jun 2024 19:13:00 +0100 Subject: [PATCH] Apply suggestion from code review --- yt_dlp/extractor/vidyard.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/yt_dlp/extractor/vidyard.py b/yt_dlp/extractor/vidyard.py index ac6ea39cc..5ceae8a7e 100644 --- a/yt_dlp/extractor/vidyard.py +++ b/yt_dlp/extractor/vidyard.py @@ -14,11 +14,10 @@ class VidyardBaseIE(InfoExtractor): _HEADERS = {} def _get_formats_and_subtitles(self, video_source, video_id): - video_source = video_source or {} formats, subtitles = [], {} - for key, value in video_source.items(): - if key == 'hls': - for video_hls in value: + for source_type, sources in traverse_obj(video_source, ({dict.items}, lambda _, v: v[1][0])): + if source_type == 'hls': + for video_hls in sources: fmts, subs = self._extract_m3u8_formats_and_subtitles(video_hls.get('url'), video_id, headers=self._HEADERS) formats.extend(fmts) self._merge_subtitles(subs, target=subtitles) @@ -26,7 +25,7 @@ def _get_formats_and_subtitles(self, video_source, video_id): formats.extend({ 'url': video_mp4.get('url'), 'ext': 'mp4', - } for video_mp4 in value) + } for video_mp4 in sources) return formats, subtitles