{"record":{"id":"a8a7dcdfd1a31a34","repo":"tonhowtf/omniget","slug":"unrecognized-cookie-format-accepted-netscape-yt-dlp-json","errorCode":null,"errorMessage":"Unrecognized cookie format. Accepted: Netscape (yt-dlp), JSON (Edit-This-Cookie, Get-cookies.txt-LOCALLY), or a Cookie header when a target domain is provided.","messagePattern":"Unrecognized cookie format\\. Accepted: Netscape \\(yt-dlp\\), JSON \\(Edit-This-Cookie, Get-cookies\\.txt-LOCALLY\\), or a Cookie header when a target domain is provided\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/cookies/parsers.rs","lineNumber":48,"sourceCode":"    let first = trimmed.chars().next().unwrap_or(' ');\n    if first == '[' || first == '{' {\n        return CookieFormat::Json;\n    }\n    if trimmed.starts_with(\"# Netscape\")\n        || trimmed.starts_with(\"#HttpOnly_\")\n        || trimmed.contains('\\t')\n    {\n        return CookieFormat::Netscape;\n    }\n    CookieFormat::Unknown\n}\n\npub fn parse(content: &str) -> anyhow::Result<Vec<ExtensionCookie>> {\n    match detect_format(content) {\n        CookieFormat::Netscape => parse_netscape(content),\n        CookieFormat::Json => parse_json(content),\n        CookieFormat::Unknown => {\n            anyhow::bail!(\"Unrecognized cookie format. Accepted: Netscape (yt-dlp), JSON (Edit-This-Cookie, Get-cookies.txt-LOCALLY), or a Cookie header when a target domain is provided.\")\n        }\n    }\n}\n\npub fn parse_for_domain(content: &str, domain: &str) -> anyhow::Result<Vec<ExtensionCookie>> {\n    match detect_format(content) {\n        CookieFormat::Netscape => parse_netscape(content),\n        CookieFormat::Json => parse_json(content),\n        CookieFormat::Unknown if looks_like_cookie_header(content) => {\n            parse_cookie_header(content, domain)\n        }\n        CookieFormat::Unknown => {\n            anyhow::bail!(\"Unrecognized cookie format. Accepted: Netscape (yt-dlp), JSON (Edit-This-Cookie, Get-cookies.txt-LOCALLY), or Cookie header pairs like SESSDATA=...; bili_jct=... when a target domain is provided.\")\n        }\n    }\n}\n\nfn looks_like_cookie_header(content: &str) -> bool {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/src/cookies/parsers.rs#L30-L66","documentation":"The cookie parser's parse() dispatches on detect_format(); when the content is neither Netscape nor JSON it is Unknown, and parse() (which has no domain parameter, so Cookie headers can't be scoped) bails with this message listing the accepted formats.","triggerScenarios":"Calling parse() with a raw Cookie header string like 'SESSDATA=...; bili_jct=...', HTML, or other non-Netscape/non-JSON content.","commonSituations":"User pastes a browser DevTools 'Cookie:' request header instead of a cookies.txt export; empty/garbage clipboard content; extension export in an unsupported shape.","solutions":["Export cookies as Netscape format (yt-dlp cookies.txt) or JSON array (Edit-This-Cookie).","If you only have a Cookie header, call parse_for_domain(content, domain) instead of parse().","Trim stray 'Cookie:' prefixes/quotes and re-export if detection still fails."],"exampleFix":"// before\nlet cookies = parsers::parse(\"SESSDATA=abc; bili_jct=xyz\")?;\n// after\nlet cookies = parsers::parse_for_domain(\"SESSDATA=abc; bili_jct=xyz\", \"bilibili.com\")?;","handlingStrategy":"validation","validationCode":"fn is_supported_cookie_format(c: &str) -> bool {\n    let t = c.trim();\n    t.starts_with('#') || t.starts_with('[') || t.starts_with('{') // Netscape / JSON\n}","typeGuard":null,"tryCatchPattern":"match parsers::parse(content) {\n    Ok(cookies) => cookies,\n    Err(e) if e.to_string().contains(\"Unrecognized cookie format\") => {\n        parsers::parse_for_domain(content, target_domain)?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Use yt-dlp-style cookies.txt or extension JSON exports","If you only have a header, always call parse_for_domain","Strip 'Cookie:' prefixes before importing"],"tags":["cookies","parsing","format"],"backgroundTag":"invalid-argument-format","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}