From 5f48fc3d1d87ea7b6d5fa942d1642a69475dc6db Mon Sep 17 00:00:00 2001 From: kikuyan Date: Wed, 28 Jul 2021 15:19:46 +0900 Subject: [PATCH] [extractor/common] add transform_source kwargs to _search_json_ld() --- youtube_dl/extractor/common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index 797c35fd5..0d5912dbc 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -1195,10 +1195,12 @@ class InfoExtractor(object): # At the same time `default` may be passed that assumes `fatal=False` # for _search_regex. Let's simulate the same behavior here as well. fatal = kwargs.get('fatal', True) if default == NO_DEFAULT else False + # Give the caller extractor the opportunity to fix malformed JSON-LD. + transform_source = kwargs.get('transform_source', None) json_ld = [] for mobj in json_ld_list: json_ld_item = self._parse_json( - mobj.group('json_ld'), video_id, fatal=fatal) + mobj.group('json_ld'), video_id, transform_source=transform_source, fatal=fatal) if not json_ld_item: continue if isinstance(json_ld_item, dict):