diff options
author | ChillingPepper <90042155+ChillingPepper@users.noreply.github.com> | 2022-12-30 07:38:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-30 12:08:38 +0530 |
commit | d5f043d127cac1e8ec8a6eacde04ad1133600a16 (patch) | |
tree | 9501d4c0aa7118f90864e39484aa387569ff9ecc /yt_dlp/utils.py | |
parent | fe74d5b592438c669f5717b34504f27c34ca9904 (diff) | |
download | hypervideo-pre-d5f043d127cac1e8ec8a6eacde04ad1133600a16.tar.lz hypervideo-pre-d5f043d127cac1e8ec8a6eacde04ad1133600a16.tar.xz hypervideo-pre-d5f043d127cac1e8ec8a6eacde04ad1133600a16.zip |
[utils] js_to_json: Fix bug in f55523c (#5771)
Authored by: ChillingPepper, pukkandan
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 43b5fda1d..64c83a77a 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -3360,7 +3360,13 @@ def js_to_json(code, vars={}, *, strict=False): return f'"{i}":' if v.endswith(':') else str(i) if v in vars: - return json.dumps(vars[v]) + try: + if not strict: + json.loads(vars[v]) + except json.decoder.JSONDecodeError: + return json.dumps(vars[v]) + else: + return vars[v] if not strict: return f'"{v}"' |