{"record":{"id":"453aa933c1d95af6","repo":"tonhowtf/omniget","slug":"could-not-extract-youtube-video-id-mod","errorCode":null,"errorMessage":"Could not extract YouTube video ID","messagePattern":"Could not extract YouTube video ID","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/platforms/youtube/mod.rs","lineNumber":115,"sourceCode":"                    url: entry.url,\n                    format: \"ytdlp_playlist\".to_string(),\n                })\n                .collect();\n\n            return Ok(MediaInfo {\n                title: sanitize_filename::sanitize(&playlist_title),\n                author: playlist_title,\n                platform: \"youtube\".to_string(),\n                duration_seconds: None,\n                thumbnail_url: None,\n                available_qualities: qualities,\n                media_type: MediaType::Playlist,\n                file_size_bytes: None,\n            });\n        }\n\n        let _video_id = Self::extract_video_id(url)\n            .ok_or_else(|| anyhow!(\"Could not extract YouTube video ID\"))?;\n\n        let json = ytdlp::get_video_info(ytdlp_path, url, &[]).await?;\n        Self::parse_video_info(&json)\n    }\n\n    fn extract_quality_height(quality_str: &str) -> Option<u32> {\n        let s = quality_str.trim().to_lowercase();\n        if s == \"best\" || s == \"highest\" {\n            return None;\n        }\n        s.trim_end_matches('p').parse::<u32>().ok()\n    }\n\n    pub fn parse_video_info(json: &serde_json::Value) -> anyhow::Result<MediaInfo> {\n        let video_id = json\n            .get(\"id\")\n            .and_then(|v| v.as_str())\n            .unwrap_or(\"unknown\")","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/src/platforms/youtube/mod.rs#L97-L133","documentation":"Thrown by YouTubeDownloader::fetch_with_ytdlp when Self::extract_video_id(url) returns None for a non-playlist URL. It means the URL does not match any supported YouTube video URL shape, so the video ID cannot be parsed out of it.","triggerScenarios":"Calling fetch_with_ytdlp with a non-YouTube URL, a YouTube URL in an unsupported shape (e.g. youtu.be with extra junk, /shorts/ variants if unhandled, mangled query strings), or an empty/whitespace string.","commonSituations":"Users pasting search-result pages, channel URLs, or music.youtube.com links; URLs wrapped in extra text; regional YouTube domains the extractor doesn't recognize; mobile share links with redirects.","solutions":["Validate that the input is a YouTube watch/shorts/youtu.be URL before calling fetch_with_ytdlp.","Normalize the URL: strip surrounding text, scheme, and unnecessary query parameters.","Run Self::extract_video_id(url) as a pre-check and show a user-facing 'invalid YouTube URL' message on None.","Extend extract_video_id to cover additional URL shapes (shorts, embed, live) if users commonly submit them."],"exampleFix":"// before\nlet _video_id = Self::extract_video_id(url)\n    .ok_or_else(|| anyhow!(\"Could not extract YouTube video ID\"))?;\n// after: normalize before extracting\nlet cleaned = url.trim().split_whitespace().next().unwrap_or(\"\");\nlet _video_id = Self::extract_video_id(cleaned)\n    .ok_or_else(|| anyhow!(\"Could not extract YouTube video ID from '{}'\", cleaned))?;","handlingStrategy":"type-guard","validationCode":"if !youtube_url_is_valid(user_input) {\n    return Err(anyhow!(\"please paste a valid YouTube video URL (watch, youtu.be, or shorts)\"));\n}\nfn youtube_url_is_valid(url: &str) -> bool {\n    url.contains(\"youtube.com/watch\") || url.contains(\"youtu.be/\") || url.contains(\"youtube.com/shorts/\")\n}","typeGuard":"fn has_extractable_video_id(url: &str) -> bool {\n    YouTubeDownloader::extract_video_id(url.trim()).is_some()\n}","tryCatchPattern":"match YouTubeDownloader::extract_video_id(url.trim()) {\n    Some(id) => proceed_with(id),\n    None => {\n        eprintln!(\"invalid YouTube URL: '{}' — expected a watch/youtu.be/shorts link\", url);\n        return;\n    }\n}","preventionTips":["Validate/normalize user-pasted URLs before calling the downloader.","Trim whitespace and strip surrounding text from clipboard input.","Support common YouTube URL shapes (watch, youtu.be, shorts, embed) in the UI.","Show a clear 'not a YouTube video URL' message at input time.","Redirect channel/playlist/search URLs to the appropriate handlers instead."],"tags":["youtube","url-parsing","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"}