1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-10-31 06:35:12 +00:00

[extractor/youtube] Fix initial player response extraction

Authored by: pukkandan, coletdjnz
This commit is contained in:
coletdjnz
2022-05-29 19:54:22 +12:00
parent ee164987c7
commit ee27297f82
2 changed files with 55 additions and 21 deletions

View File

@@ -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: