aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/common.py
diff options
context:
space:
mode:
authorcoletdjnz <coletdjnz@protonmail.com>2022-05-29 19:54:22 +1200
committercoletdjnz <coletdjnz@protonmail.com>2022-05-29 19:54:22 +1200
commitee27297f82ccbd702ccd4721d1d3c9d67bbe187e (patch)
tree296813e12f9080358c36e0beaa4d2988cd4ef445 /yt_dlp/extractor/common.py
parentee164987c731aa2dccdc035b196795666e860ee0 (diff)
downloadhypervideo-pre-ee27297f82ccbd702ccd4721d1d3c9d67bbe187e.tar.lz
hypervideo-pre-ee27297f82ccbd702ccd4721d1d3c9d67bbe187e.tar.xz
hypervideo-pre-ee27297f82ccbd702ccd4721d1d3c9d67bbe187e.zip
[extractor/youtube] Fix initial player response extraction
Authored by: pukkandan, coletdjnz
Diffstat (limited to 'yt_dlp/extractor/common.py')
-rw-r--r--yt_dlp/extractor/common.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py
index b24599d5f..5767662ed 100644
--- a/yt_dlp/extractor/common.py
+++ b/yt_dlp/extractor/common.py
@@ -1033,11 +1033,19 @@ class InfoExtractor:
expected_status=expected_status)
return res if res is False else res[0]
- def _parse_json(self, json_string, video_id, transform_source=None, fatal=True):
+ def _parse_json(self, json_string, video_id, transform_source=None, fatal=True, lenient=False):
if transform_source:
json_string = transform_source(json_string)
try:
- return json.loads(json_string, strict=False)
+ try:
+ return json.loads(json_string, strict=False)
+ except json.JSONDecodeError as e:
+ if not lenient:
+ raise
+ try:
+ return json.loads(json_string[:e.pos], strict=False)
+ except ValueError:
+ raise e
except ValueError as ve:
errmsg = '%s: Failed to parse JSON ' % video_id
if fatal: