{"record":{"id":"4c600bf8c1bb2ca9","repo":"tonhowtf/omniget","slug":"console-encoding-error-non-utf-8-locale-update-yt-dlp-in","errorCode":null,"errorMessage":"Console encoding error (non-UTF-8 locale). Update yt-dlp in Settings → Dependencies, or run `chcp 65001` in a terminal and reopen the app.","messagePattern":"Console encoding error \\(non-UTF-8 locale\\)\\. Update yt-dlp in Settings → Dependencies, or run `chcp 65001` in a terminal and reopen the app\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/ytdlp.rs","lineNumber":4423,"sourceCode":"        \"video is private\",\n        \"no video formats found\",\n        \"unsupported url\",\n        \"is not a valid url\",\n        \"http error 404\",\n        \"http error 410\",\n    ];\n    PATTERNS.iter().any(|p| stderr_lower.contains(p))\n}\n\nfn translate_ytdlp_error(stderr: &str) -> anyhow::Error {\n    let lower = stderr.to_lowercase();\n\n    if lower.contains(\"errno 22\")\n        && (lower.contains(\"textiowrapper\")\n            || lower.contains(\"encoding=\")\n            || lower.contains(\"exception ignored\"))\n    {\n        return anyhow!(\n            \"Console encoding error (non-UTF-8 locale). Update yt-dlp in Settings → Dependencies, or run `chcp 65001` in a terminal and reopen the app.\"\n        );\n    }\n\n    if lower.contains(\"http error 429\") {\n        return anyhow!(\"Server returned error 429 (too many requests). Try again later.\");\n    }\n    if lower.contains(\"http error 403\") || lower.contains(\"forbidden\") {\n        return anyhow!(\"Access denied (403). The video may be private or region-restricted.\");\n    }\n    if lower.contains(\"sign in to confirm\")\n        || lower.contains(\"login required\")\n        || stderr.contains(\"请先登录\")\n        || stderr.contains(\"需要登录\")\n        || stderr.contains(\"登录后可\")\n        || stderr.contains(\"仅登录用户\")\n        || lower.contains(\"this video is only available\") && lower.contains(\"members\")\n    {","sourceCodeStart":4405,"sourceCodeEnd":4441,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/ytdlp.rs#L4405-L4441","documentation":"A friendly remapping produced by the error-message classifier (ytdlp.rs:4423): yt-dlp emitted an 'Exception ignored'/TextIOWrapper 'errno 22' traceback caused by the child process writing to a console with a non-UTF-8 codepage (typical on Windows with a legacy locale). The library detects these markers and surfaces an actionable message instead of raw Python noise.","triggerScenarios":"Running yt-dlp on Windows with a non-UTF-8 console codepage (e.g. chcp 936/1252) where yt-dlp's output triggers an errno 22 TextIOWrapper encoding exception that appears in captured stderr.","commonSituations":"Chinese/Eastern-European Windows locales with legacy codepages; older yt-dlp versions sensitive to console encoding; running from a terminal with OEM codepage rather than UTF-8.","solutions":["Run `chcp 65001` in the terminal and reopen the app (switches console to UTF-8).","Update yt-dlp via Settings → Dependencies (newer versions handle encodings better).","Set the system 'Beta: Use Unicode UTF-8 for worldwide language support' option on Windows.","Set environment variables PYTHONIOENCODING=utf-8 / PYTHONUTF8=1 for the spawned process."],"exampleFix":"// before (cmd.xml)\ncmd.arg(\"yt-dlp\").arg(url);\n// after\ncmd.arg(\"yt-dlp\").arg(url)\n    .env(\"PYTHONUTF8\", \"1\")\n    .env(\"PYTHONIOENCODING\", \"utf-8\");","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["On Windows, switch the console to UTF-8 (`chcp 65001`) or enable the system-wide UTF-8 beta option.","Keep yt-dlp current — newer releases handle legacy codepages more gracefully.","Set PYTHONUTF8=1 for the spawned yt-dlp process in launcher scripts.","Prefer launching the app from a UTF-8 terminal rather than a legacy OEM codepage console."],"tags":["windows","encoding","ytdlp","console"],"backgroundTag":"console-encoding-error","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"}