]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/utils.py
[utils] js_to_json: Fix bug in f55523c (#5771)
[yt-dlp.git] / yt_dlp / utils.py
index 43b5fda1d243422532ca0d69523fb9c3641df3fb..64c83a77a27a4920a19ffda9f87f49384d3323ad 100644 (file)
@@ -3360,7 +3360,13 @@ def fix_kv(m):
                 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}"'