diff options
Diffstat (limited to 'yt_dlp/extractor/common.py')
-rw-r--r-- | yt_dlp/extractor/common.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 31a45b37a..18a52a855 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -1467,10 +1467,6 @@ class InfoExtractor: if not json_ld: return {} info = {} - if not isinstance(json_ld, (list, tuple, dict)): - return info - if isinstance(json_ld, dict): - json_ld = [json_ld] INTERACTION_TYPE_MAP = { 'CommentAction': 'comment', @@ -1570,11 +1566,13 @@ class InfoExtractor: extract_chapter_information(e) def traverse_json_ld(json_ld, at_top_level=True): - for e in json_ld: + for e in variadic(json_ld): + if not isinstance(e, dict): + continue if at_top_level and '@context' not in e: continue if at_top_level and set(e.keys()) == {'@context', '@graph'}: - traverse_json_ld(variadic(e['@graph'], allowed_types=(dict,)), at_top_level=False) + traverse_json_ld(e['@graph'], at_top_level=False) break if expected_type is not None and not is_type(e, expected_type): continue @@ -1629,8 +1627,8 @@ class InfoExtractor: continue else: break - traverse_json_ld(json_ld) + traverse_json_ld(json_ld) return filter_dict(info) def _search_nextjs_data(self, webpage, video_id, *, transform_source=None, fatal=True, **kw): |