From e46d72c6c55ac6bcec3a7da37d7eaf219e03edf5 Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Sun, 17 Nov 2024 14:04:35 +0000 Subject: [PATCH] simplify --- yt_dlp/extractor/kenh14.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/yt_dlp/extractor/kenh14.py b/yt_dlp/extractor/kenh14.py index 2183d5646e58..3c46020e8b6a 100644 --- a/yt_dlp/extractor/kenh14.py +++ b/yt_dlp/extractor/kenh14.py @@ -83,17 +83,16 @@ def _real_extract(self, url): subtitles = {} video_data = self._download_json( f'https://{direct_url}.json', video_id, note='Downloading video data', fatal=False) - if video_data: - if hls_url := video_data.get('hls'): - fmts, subs = self._extract_m3u8_formats_and_subtitles( - hls_url, video_id, m3u8_id='hls', fatal=False) - formats.extend(fmts) - self._merge_subtitles(subs, target=subtitles) - if dash_url := video_data.get('mpd'): - fmts, subs = self._extract_mpd_formats_and_subtitles( - dash_url, video_id, mpd_id='dash', fatal=False) - formats.extend(fmts) - self._merge_subtitles(subs, target=subtitles) + if hls_url := traverse_obj(video_data, ('hls', {url_or_none})): + fmts, subs = self._extract_m3u8_formats_and_subtitles( + hls_url, video_id, m3u8_id='hls', fatal=False) + formats.extend(fmts) + self._merge_subtitles(subs, target=subtitles) + if dash_url := traverse_obj(video_data, ('mpd', {url_or_none})): + fmts, subs = self._extract_mpd_formats_and_subtitles( + dash_url, video_id, mpd_id='dash', fatal=False) + formats.extend(fmts) + self._merge_subtitles(subs, target=subtitles) return { **traverse_obj(metadata, {