From 6d88c7231743e8689c2369a2f62bc90118da9802 Mon Sep 17 00:00:00 2001 From: Trigus42 Date: Wed, 1 Sep 2021 16:34:36 +0200 Subject: [PATCH 1/2] Fix `json.decoder.JSONDecodeError: Extra data` Fix an error that occurs when `webpage` contains a JSON with multiple records. --- youtube_dl/extractor/crunchyroll.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/crunchyroll.py b/youtube_dl/extractor/crunchyroll.py index bc2d1fa8b..ef9639cbd 100644 --- a/youtube_dl/extractor/crunchyroll.py +++ b/youtube_dl/extractor/crunchyroll.py @@ -430,7 +430,10 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text if note_m: raise ExtractorError(note_m) - mobj = re.search(r'Page\.messaging_box_controller\.addItems\(\[(?P{.+?})\]\)', webpage) + mobj = re.search( + r'Page\.messaging_box_controller\.addItems\(\[(?P{(?!.*},{).+?})\]\)', + webpage) + if mobj: msg = json.loads(mobj.group('msg')) if msg.get('type') == 'error': From 6f08b513bf5e82132f07810f40e3fe81e5698ef5 Mon Sep 17 00:00:00 2001 From: Trigus42 <59501676+Trigus42@users.noreply.github.com> Date: Thu, 2 Sep 2021 16:26:49 +0200 Subject: [PATCH 2/2] Allow for white spaces around `.`, `(`, `)`, `[`, `]` and `,` https://github.com/ytdl-org/youtube-dl/pull/29897#pullrequestreview-744861659 --- youtube_dl/extractor/crunchyroll.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/crunchyroll.py b/youtube_dl/extractor/crunchyroll.py index ef9639cbd..3e72e6b17 100644 --- a/youtube_dl/extractor/crunchyroll.py +++ b/youtube_dl/extractor/crunchyroll.py @@ -431,7 +431,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text raise ExtractorError(note_m) mobj = re.search( - r'Page\.messaging_box_controller\.addItems\(\[(?P{(?!.*},{).+?})\]\)', + r'Page\s*\.\s*messaging_box_controller\s*\.\s*addItems\s*\(\s*\[\s*(?P{(?!.*}\s*,\s*{).+?})\s*\]\s*\)', webpage) if mobj: