[utils] traverse_obj: Allow filtering by value

This commit is contained in:
pukkandan
2022-03-31 13:25:50 +05:30
parent c4f60dd7cd
commit e6f868a63c
3 changed files with 6 additions and 6 deletions

View File

@@ -333,7 +333,7 @@ class FunimationShowIE(FunimationBaseIE):
'https://prod-api-funimationnow.dadcdigital.com/api/funimation/episodes/?limit=99999&title_id=%s'
% show_info.get('id'), display_id)
vod_items = traverse_obj(items_info, ('items', ..., re.compile('(?i)mostRecent[AS]vod').match, 'item'))
vod_items = traverse_obj(items_info, ('items', ..., lambda k, _: re.match(r'(?i)mostRecent[AS]vod', k), 'item'))
return {
'_type': 'playlist',

View File

@@ -626,8 +626,8 @@ class IqIE(InfoExtractor):
note=f'Downloading format data for {self._BID_TAGS[bid]}', errnote='Unable to download format data',
fatal=False), 'data', expected_type=dict)
video_format = next((video_format for video_format in traverse_obj(
format_data, ('program', 'video', ...), expected_type=dict, default=[]) if str(video_format['bid']) == bid), {})
video_format = traverse_obj(format_data, ('program', 'video', lambda _, v: str(v['bid']) == bid),
expected_type=dict, default=[], get_all=False) or {}
extracted_formats = []
if video_format.get('m3u8Url'):
extracted_formats.extend(self._extract_m3u8_formats(