{"record":{"id":"88b528befd668fcc","repo":"ytdl-org/youtube-dl","slug":"unknown-value","errorCode":null,"errorMessage":"Unknown value: ","messagePattern":"Unknown value: ","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"youtube_dl/utils.py","lineNumber":4627,"sourceCode":"                i = int(im.group(1), base)\n                return ('\"%s\":' if v.endswith(':') else '%s') % inv(i)\n\n        if v in vars:\n            try:\n                if not strict:\n                    json.loads(vars[v])\n            except JSONDecodeError:\n                return inv(json.dumps(vars[v]))\n            else:\n                return inv(vars[v])\n\n        if not strict:\n            v = try_call(inv, args=(v,), default=v)\n            if v in ('true', 'false'):\n                return v\n            return '\"{0}\"'.format(v)\n\n        raise ValueError('Unknown value: ' + v)\n\n    def create_map(mobj):\n        return json.dumps(dict(json.loads(js_to_json(mobj.group(1) or '[]', vars=vars))))\n\n    code = re.sub(r'new Map\\((\\[.*?\\])?\\)', create_map, code)\n    if not strict:\n        code = re.sub(r'new Date\\((\".+\")\\)', r'\\g<1>', code)\n        code = re.sub(r'new \\w+\\((.*?)\\)', lambda m: json.dumps(m.group(0)), code)\n        code = re.sub(r'parseInt\\([^\\d]+(\\d+)[^\\d]+\\)', r'\\1', code)\n        code = re.sub(r'\\(function\\([^)]*\\)\\s*\\{[^}]*\\}\\s*\\)\\s*\\(\\s*([\"\\'][^)]*[\"\\'])\\s*\\)', r'\\1', code)\n\n    return re.sub(r'''(?sx)\n        {str_}|\n        {comment}|\n        ,(?={skip}[\\]}}])|\n        void\\s0|\n        !*(?:(?<!\\d)[eE]|[a-df-zA-DF-Z_$])[.a-zA-Z_$0-9]*|\n        (?:\\b|!+)0(?:[xX][\\da-fA-F]+|[0-7]+)(?:{skip}:)?|","sourceCodeStart":4609,"sourceCodeEnd":4645,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/utils.py#L4609-L4645","documentation":"Raised by js_to_json() in youtube_dl.utils when parsing JavaScript (e.g. player configuration or JSON embedded in a webpage) with strict=True. A token in the JS object literal could not be converted to a valid JSON value: it is neither a quoted string, a number, true/false/null, nor a recognized identifier from the vars mapping. In strict mode the converter refuses to guess, so it raises ValueError('Unknown value: ' + v).","triggerScenarios":"Calling js_to_json(js_object_text, strict=True) (directly, or via a helper like json.loads(js_to_json(...)) in an extractor) where the JS source contains a bare unquoted value such as {v: foo}, a JS expression like new Something(...), an identifier not present in the vars dict, or a malformed literal. With strict=False the same input would be wrapped in quotes instead of raising.","commonSituations":"A website changes its player config and now embeds JS-only constructs (unquoted identifiers, function calls, Date objects) where JSON was expected; extractor regression after a site redesign; passing raw JS that was previously cleaned by non-strict preprocessing.","solutions":["Call js_to_json with strict=False so unrecognized bare values are quoted as strings instead of raising.","Pass a vars dict (js_to_json(code, vars={'foo': 'bar'})) mapping the bare identifiers to their JSON-serializable values.","Pre-clean the JS: strip function wrappers, parseInt(...), new Date(...) etc. before conversion (the non-strict path does this with regexes).","If you hit this inside an extractor for a specific site, report/update the extractor — the site's markup changed."],"exampleFix":"// before\nimport json\nfrom youtube_dl.utils import js_to_json\ndata = json.loads(js_to_json(js_text, strict=True))  # raises on bare identifiers\n\n// after\nimport json\nfrom youtube_dl.utils import js_to_json\ndata = json.loads(js_to_json(js_text, strict=False))  # unknown values become quoted strings","handlingStrategy":"fallback","validationCode":"import json\nfrom youtube_dl.utils import js_to_json\n\ndef parse_js_json(js_text, vars=None):\n    try:\n        return json.loads(js_to_json(js_text, vars=vars, strict=True))\n    except ValueError:\n        # retry non-strict: unknown bare values become quoted strings\n        return json.loads(js_to_json(js_text, vars=vars, strict=False))","typeGuard":null,"tryCatchPattern":"try:\n    data = json.loads(js_to_json(code, strict=True))\nexcept ValueError:\n    data = json.loads(js_to_json(code, vars=known_vars, strict=False))","preventionTips":["Prefer strict=False when the JS comes from web pages you do not control.","Pass a vars dict for known bare identifiers before conversion.","Wrap js_to_json results in json.loads inside try/except ValueError in extractor code."],"tags":["json","javascript","parsing","extractor"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}