1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-09-28 21:47:09 +02:00

Apply suggestion from code review

This commit is contained in:
Sean Ellingham 2024-06-24 19:13:00 +01:00
parent caae2e6233
commit 4f07c29a31

View File

@ -14,11 +14,10 @@ class VidyardBaseIE(InfoExtractor):
_HEADERS = {} _HEADERS = {}
def _get_formats_and_subtitles(self, video_source, video_id): def _get_formats_and_subtitles(self, video_source, video_id):
video_source = video_source or {}
formats, subtitles = [], {} formats, subtitles = [], {}
for key, value in video_source.items(): for source_type, sources in traverse_obj(video_source, ({dict.items}, lambda _, v: v[1][0])):
if key == 'hls': if source_type == 'hls':
for video_hls in value: for video_hls in sources:
fmts, subs = self._extract_m3u8_formats_and_subtitles(video_hls.get('url'), video_id, headers=self._HEADERS) fmts, subs = self._extract_m3u8_formats_and_subtitles(video_hls.get('url'), video_id, headers=self._HEADERS)
formats.extend(fmts) formats.extend(fmts)
self._merge_subtitles(subs, target=subtitles) self._merge_subtitles(subs, target=subtitles)
@ -26,7 +25,7 @@ def _get_formats_and_subtitles(self, video_source, video_id):
formats.extend({ formats.extend({
'url': video_mp4.get('url'), 'url': video_mp4.get('url'),
'ext': 'mp4', 'ext': 'mp4',
} for video_mp4 in value) } for video_mp4 in sources)
return formats, subtitles return formats, subtitles