{"record":{"id":"705b8db98458d503","repo":"tonhowtf/omniget","slug":"could-not-extract-pin-id-mod","errorCode":null,"errorMessage":"Could not extract pin ID","messagePattern":"Could not extract pin ID","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/platforms/pinterest/mod.rs","lineNumber":271,"sourceCode":"            file_size_bytes: total_bytes,\n            duration_seconds: 0.0,\n            torrent_id: None,\n        })\n    }\n}\n\nimpl PinterestDownloader {\n    async fn fallback_ytdlp(&self, url: &str) -> anyhow::Result<MediaInfo> {\n        let ytdlp_path = crate::core::ytdlp::ensure_ytdlp().await?;\n        let json = crate::core::ytdlp::get_video_info(&ytdlp_path, url, &[]).await?;\n        crate::platforms::generic_ytdlp::GenericYtdlpDownloader::parse_video_info(&json)\n    }\n\n    async fn native_get_media_info(&self, url: &str) -> anyhow::Result<MediaInfo> {\n        let canonical = self.resolve_pin_url(url).await?;\n\n        let pin_id =\n            Self::extract_pin_id(&canonical).ok_or_else(|| anyhow!(\"Could not extract pin ID\"))?;\n\n        let html = self.fetch_pin_html(&pin_id).await?;\n\n        if Self::check_pin_not_found(&html) {\n            return Err(anyhow!(\"Pin not found\"));\n        }\n\n        if let Some(video_url) = Self::extract_video_url(&html) {\n            return Ok(MediaInfo {\n                title: format!(\"pinterest_{}\", pin_id),\n                author: String::new(),\n                platform: \"pinterest\".to_string(),\n                duration_seconds: None,\n                thumbnail_url: None,\n                available_qualities: vec![VideoQuality {\n                    label: \"original\".to_string(),\n                    width: 0,\n                    height: 0,","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/src/platforms/pinterest/mod.rs#L253-L289","documentation":"native_get_media_info canonicalizes the pin URL then extracts the numeric pin ID from it. If extract_pin_id cannot find an ID in the canonical URL, this error is thrown. It means the URL is not (or no longer looks like) a valid pin permalink.","triggerScenarios":"native_get_media_info(url) -> resolve_pin_url returns a canonical URL that extract_pin_id cannot parse — the URL is a profile/board/user page, a shortened/malformed link, or Pinterest redirected to a non-pin page (deleted pin, login wall).","commonSituations":"User pastes a board or profile URL instead of a pin URL; pin.pinterest.com short links redirect unexpectedly; Pinterest changes URL structure (/pin/<id>/ pattern altered); resolve_pin_url follows a redirect to an error/login page.","solutions":["Log the canonical URL when this fires and update extract_pin_id's regex for Pinterest's current URL format.","Validate the input is a pin URL (/pin/<digits>) before calling get_media_info and give early feedback.","Check what resolve_pin_url returned — a login-wall or 404 redirect indicates the pin is gone, not a parser bug.","Handle pinterest.com/pin/... and pin.it/... variants explicitly in resolve_pin_url."],"exampleFix":"// before\nlet pin_id = Self::extract_pin_id(&canonical)\n    .ok_or_else(|| anyhow!(\"Could not extract pin ID\"))?;\n// after\nlet pin_id = Self::extract_pin_id(&canonical).ok_or_else(|| {\n    anyhow!(\"Could not extract pin ID from canonical URL: {} (is this a pin permalink?)\", canonical)\n})?;","handlingStrategy":"validation","validationCode":"// Rust: validate the pin URL before calling get_media_info\nlet re = regex::Regex::new(r\"pinterest\\.[a-z.]+/pin/(\\d+)\").unwrap();\nif !re.is_match(url) && !url.starts_with(\"https://pin.it/\") {\n    return Err(anyhow!(\"not a pin permalink: {}\", url));\n}","typeGuard":"// Rust\nfn pin_id_of(url: &str) -> Option<String> {\n    regex::Regex::new(r\"/pin/(\\d+)\")\n        .ok()?\n        .captures(url)\n        .and_then(|c| c.get(1))\n        .map(|m| m.as_str().to_string())\n}","tryCatchPattern":"match get_media_info(url).await {\n    Err(e) if e.to_string().contains(\"Could not extract pin ID\") => {\n        eprintln!(\"Provide a direct pin permalink (pinterest.com/pin/<id>)\");\n    }\n    other => other?,\n}","preventionTips":["Only accept /pin/<id> permalinks or known short-link hosts in user input","Keep resolve_pin_url's redirect handling aligned with Pinterest's current URL scheme","Unit-test extract_pin_id against a matrix of Pinterest URL formats","Log the canonical URL whenever ID extraction fails to catch format changes early"],"tags":["pinterest","url","parsing","validation"],"backgroundTag":"invalid-identifier-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"}