mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-20 05:47:24 +01:00
return None when None/key not exist
This commit is contained in:
parent
b28dc2a424
commit
6f6cab852d
@ -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<a>"?(?P<b>.+?)"?);', 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
|
||||
|
Loading…
Reference in New Issue
Block a user