From 6f6cab852d7268903527daaade9e6da4617cf716 Mon Sep 17 00:00:00 2001 From: kclauhk <78251477+kclauhk@users.noreply.github.com> Date: Wed, 21 Aug 2024 20:54:55 +0800 Subject: [PATCH] return None when None/key not exist --- yt_dlp/extractor/kidoodletv.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/yt_dlp/extractor/kidoodletv.py b/yt_dlp/extractor/kidoodletv.py index 3bbdb9022c..19a033d10f 100644 --- a/yt_dlp/extractor/kidoodletv.py +++ b/yt_dlp/extractor/kidoodletv.py @@ -38,7 +38,8 @@ def slugify(string): def get_field(field_name, idx, webpage, data): value = self._html_search_regex(rf'{idx}\.{field_name}=(?P"?(?P.+?)"?);', webpage, field_name, default=None, group=('a', 'b')) - return value[1] if value[1] != value[0] else (data.get(value[0]) or value[0]) + return (value[1] if value[1] != value[0] else ( + data.get(value[0]) if re.search(r'^[a-zA-Z_\$]{1,4}$', value[0]) else value[0])) idx = idx.replace('$', r'\$') video_id = get_field('id', idx, webpage, data) @@ -139,7 +140,7 @@ def _real_extract(self, url): description = self._html_search_meta('description', webpage, 'description', default=None) data_set = self._extract_data(webpage, video_id) info = {} - if idx := self._html_search_regex(rf'([\w\$]{{2,4}})\.seasonAndEpisode="{season_episode}";', + if idx := self._html_search_regex(rf'([\w\$]{{1,4}})\.seasonAndEpisode="{season_episode}";', webpage, 'data_idx', default=None): info = self._extract_by_idx(idx, webpage, data_set, video_id) @@ -180,7 +181,7 @@ def _real_extract(self, url): 'description', default=None) data_set = self._extract_data(webpage, series_id) entries = [] - for idx_se in sorted(re.findall(r'([\w\$]{2,4})\.seasonAndEpisode="([^"]+)";', webpage), + for idx_se in sorted(re.findall(r'([\w\$]{1,4})\.seasonAndEpisode="([^"]+)";', webpage), key=lambda x: x[1]): if entry := self._extract_by_idx(idx_se[0], webpage, data_set): entry['series_id'] = series_id