{"record":{"id":"fec6b34946560751","repo":"tonhowtf/omniget","slug":"cole-o-link-de-um-post-do-reddit-de-um-i-redd-it-ou-de-um-v","errorCode":null,"errorMessage":"cole o link de um post do Reddit, de um i.redd.it ou de um v.redd.it","messagePattern":"cole o link de um post do Reddit, de um i\\.redd\\.it ou de um v\\.redd\\.it","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/reddit/download.rs","lineNumber":539,"sourceCode":"async fn download_gallery_dl(\n    url: &str,\n    dest: &Path,\n    progress: &ProgressFn,\n) -> Result<(Vec<String>, String)> {\n    let r =\n        crate::core::tools::gallery::download(url, &dest.to_string_lossy(), None, progress.clone())\n            .await?;\n    Ok((r.files, r.log_tail))\n}\n\npub async fn run(opts: &Options, progress: ProgressFn) -> Result<DownloadResult> {\n    report(&progress, ID, \"started\", 0, None, None);\n    let dest = PathBuf::from(&opts.dest);\n    std::fs::create_dir_all(&dest)?;\n    let fetcher = Fetcher::new(opts.delay_ms, opts.session_netscape.as_deref())?;\n\n    let mut target = parse_target(&opts.url).ok_or_else(|| {\n        anyhow!(\"cole o link de um post do Reddit, de um i.redd.it ou de um v.redd.it\")\n    })?;\n    if let Target::Short { url } = &target {\n        let final_url = fetcher.resolve(url).await?;\n        target = parse_target(&final_url)\n            .ok_or_else(|| anyhow!(\"o link curto não levou a um post ({})\", final_url))?;\n    }\n\n    // Mídia solta e link de fora não têm post para consultar.\n    let (post, plan) = match &target {\n        Target::Post { id, .. } => {\n            let post = fetch_post(&fetcher, id).await?;\n            let plan = plan_for(&post);\n            (Some(post), plan)\n        }\n        Target::Media { url, video: true } => (None, Plan::Video { url: url.clone() }),\n        Target::Media { url, video: false } => (None, Plan::Image { url: url.clone() }),\n        Target::External { url } => (None, Plan::External { url: url.clone() }),\n        Target::Subreddit { .. } | Target::User { .. } => {","sourceCodeStart":521,"sourceCodeEnd":557,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/reddit/download.rs#L521-L557","documentation":"parse_target() failed to classify the supplied URL as a Reddit post, media (i.redd.it / v.redd.it), external link, subreddit, user, or short link. The library throws this anyhow error to tell the user the input is not a recognizable Reddit download target. It is the first validation step of run(), so nothing has been fetched yet.","triggerScenarios":"run()/baixa_um_video_de_verdade/baixa_uma_galeria_de_verdade called with opts.url that is empty, not a URL, a reddit.com/comments listing without an id, an old.reddit.com variant parse_target doesn't recognize, or a non-Reddit URL.","commonSituations":"Pasting only a post title or id instead of the full link; copying a link from a share sheet that yields a tracking URL; feeding a search-results or crosspost page; typos like 'redd.it' without scheme handled differently by parse_target.","solutions":["Check opts.url is a full https:// Reddit post URL (reddit.com/r/<sub>/comments/<id>/...) or an i.redd.it / v.redd.it media link","Strip tracking/query parameters and re-submit the canonical post URL","If you have a short link (redd.it/<id>), pass it — it is resolved via Target::Short — but ensure it actually points to a post","Verify the URL includes the scheme (https://); add it if missing"],"exampleFix":"// before\nrun(RunOpts { url: \"my-favorite-post\".into(), .. })\n// after\nrun(RunOpts { url: \"https://www.reddit.com/r/rust/comments/abc123/title/\".into(), .. })","handlingStrategy":"validation","validationCode":"fn is_reddit_post_or_media(url: &str) -> bool {\n    let u = url.trim();\n    u.starts_with(\"https://\")\n        && (u.contains(\"reddit.com/r/\") && u.contains(\"/comments/\")\n            || u.contains(\"i.redd.it/\")\n            || u.contains(\"v.redd.it/\"))\n}\n// call before run(): assert!(is_reddit_post_or_media(&opts.url));","typeGuard":"fn looks_like_reddit_url(s: &str) -> bool {\n    s.starts_with(\"https://\") && s.contains(\"reddit.com\") || s.contains(\"redd.it/\")\n}","tryCatchPattern":null,"preventionTips":["Always paste the full canonical post URL including https:// and /comments/<id>/","Strip share/tracking query parameters before passing URLs","Prefer i.redd.it / v.redd.it links for direct media","Test parse_target logic in unit tests with your expected URL shapes"],"tags":["reddit","url-parsing","input-validation"],"backgroundTag":"invalid-url-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"}