{"record":{"id":"85fbb13f0f7d0547","repo":"tonhowtf/omniget","slug":"yt-dlp-falhou","errorCode":null,"errorMessage":"yt-dlp falhou: {}","messagePattern":"yt-dlp falhou: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/yt_archive.rs","lineNumber":72,"sourceCode":"async fn ytdlp_path() -> anyhow::Result<PathBuf> {\n    crate::core::dependencies::find_tool(\"yt-dlp\")\n        .await\n        .ok_or_else(|| anyhow!(\"o yt-dlp não está instalado\"))\n}\n\n/// Roda o yt-dlp e devolve a saída padrão. Erro traz o fim do stderr.\npub async fn run_ytdlp(args: &[String]) -> anyhow::Result<String> {\n    let bin = ytdlp_path().await?;\n    let out = crate::core::ytdlp::ytdlp_command(&bin)\n        .args(args)\n        .stdin(std::process::Stdio::null())\n        .output()\n        .await\n        .map_err(|e| anyhow!(\"o yt-dlp não iniciou: {}\", e))?;\n    if !out.status.success() {\n        let err = String::from_utf8_lossy(&out.stderr);\n        let tail: Vec<&str> = err.lines().rev().take(3).collect();\n        return Err(anyhow!(\n            \"yt-dlp falhou: {}\",\n            tail.into_iter().rev().collect::<Vec<_>>().join(\" / \")\n        ));\n    }\n    Ok(String::from_utf8_lossy(&out.stdout).to_string())\n}\n\n// ── Estado ─────────────────────────────────────────────────────────────\n\n#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]\n#[serde(rename_all = \"lowercase\")]\npub enum ItemStatus {\n    /// Ainda na fila.\n    Pending,\n    /// Baixado (ou já presente no `--download-archive`).\n    Ok,\n    /// Tentou e deu erro; o motivo fica no item.\n    Failed,","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/yt_archive.rs#L54-L90","documentation":"run_ytdlp checks the process exit status; when yt-dlp runs but exits non-zero, it throws \"yt-dlp falhou: {}\" containing the last 3 lines of yt-dlp's stderr. The library surfaces yt-dlp's own diagnostics because the failure cause (bad URL, region lock, format issue) comes from yt-dlp itself.","triggerScenarios":"Calling enumerate when yt-dlp exits non-zero: unsupported/private/deleted video, network failure, outdated yt-dlp version facing a YouTube layout change, bad cookie file, or invalid CLI args.","commonSituations":"YouTube breaking yt-dlp until an update ships; expired YouTube session cookies in the netscape file; private playlists without cookies; rate limiting/bot checks.","solutions":["Read the stderr tail in the error message — it names the actual yt-dlp failure.","Update yt-dlp to the latest version (pip install -U yt-dlp); YouTube breakage is usually fixed within days.","If the error mentions sign-in/cookies, refresh the session cookie file or export fresh cookies.","Check the URL is a valid, public playlist/video; retry after backoff if it mentions rate limiting or bot detection."],"exampleFix":"// before\nlet json = run_ytdlp(&args).await?;\n// after\nlet json = match run_ytdlp(&args).await {\n    Ok(j) => j,\n    Err(e) => {\n        eprintln!(\"yt-dlp: {e}; tentando atualizar yt-dlp...\");\n        let _ = Command::new(\"pip\").args([\"install\", \"-U\", \"yt-dlp\"]).status();\n        run_ytdlp(&args).await?\n    }\n};","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match run_ytdlp(&args).await {\n    Ok(out) => out,\n    Err(e) if e.to_string().contains(\"yt-dlp falhou\") => {\n        eprintln!(\"{e}\");\n        if e.to_string().to_lowercase().contains(\"update\") || e.to_string().contains(\"unable to extract\") {\n            update_ytdlp().await?;\n            run_ytdlp(&args).await?\n        } else { return Err(e); }\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep yt-dlp up to date (nightly releases fix YouTube breakage fast)","Read the stderr tail embedded in the error for the root cause","Refresh session cookies before they expire","Back off and retry on rate-limit/bot-check messages"],"tags":["yt-dlp","external-process","youtube"],"backgroundTag":"http-error-response","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"}