1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-09-03 16:45:17 +00:00

[utils] js_to_json: Make function less fatal (#12715)

Authored by: seproDev
This commit is contained in:
sepro
2025-03-24 22:28:47 +01:00
committed by GitHub
parent b7fbb5a0a1
commit 9491b44032
2 changed files with 3 additions and 1 deletions

View File

@ -2767,7 +2767,8 @@ def js_to_json(code, vars={}, *, strict=False):
def template_substitute(match):
evaluated = js_to_json(match.group(1), vars, strict=strict)
if evaluated[0] == '"':
return json.loads(evaluated)
with contextlib.suppress(json.JSONDecodeError):
return json.loads(evaluated)
return evaluated
def fix_kv(m):