{"record":{"id":"968a00486e128873","repo":"tonhowtf/omniget","slug":"failed-to-detect-url-kind-mod","errorCode":null,"errorMessage":"Failed to detect URL kind: {}","messagePattern":"Failed to detect URL kind: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/src/platforms/bilibili/mod.rs","lineNumber":122,"sourceCode":"        .first()\n        .map(|q| q.url.as_str())\n        .unwrap_or(\"\");\n    if url.is_empty() {\n        return Err(anyhow!(\"No URL available\"));\n    }\n\n    let slug = active_account_slug();\n    let client = build_api_client(slug.as_deref(), opts.user_agent.as_deref())?;\n\n    let mut effective_url = url.to_string();\n    if url_kind::is_b23_short(&effective_url) {\n        if let Ok(resolved) = url_kind::resolve_b23(&client, &effective_url).await {\n            effective_url = resolved;\n        }\n    }\n\n    let kind = url_kind::detect(&effective_url)\n        .map_err(|e| anyhow!(\"Failed to detect URL kind: {}\", e.i18n_key()))?;\n    let parsed = parser::parse(&client, &kind)\n        .await\n        .map_err(|e| anyhow!(\"Failed to parse content: {}\", e.i18n_key()))?;\n\n    let settings = crate::storage::config::load_settings_standalone();\n    let container = mux::container_from_setting(&settings.download.bilibili_container);\n    let danmaku_format = danmaku_format_from_setting(&settings.download.bilibili_danmaku_format);\n    let cover_format = cover::CoverFormat::from_str(&settings.download.bilibili_cover_format);\n    let template_set = naming::TemplateSet {\n        video: settings.download.bilibili_naming_video.clone(),\n        multi_part: settings.download.bilibili_naming_multi_part.clone(),\n        bangumi: settings.download.bilibili_naming_bangumi.clone(),\n        cheese: settings.download.bilibili_naming_cheese.clone(),\n        collection: settings.download.bilibili_naming_collection.clone(),\n    };\n    let first_item_owned = parsed.items.first().cloned().unwrap_or_default();\n    let naming_kind = naming::classify(&kind, &first_item_owned);\n    let naming_inputs = naming::NamingInputs {","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/src/platforms/bilibili/mod.rs#L104-L140","documentation":"`api_engine_download` resolves b23.tv short links, then calls `url_kind::detect(&effective_url)` to classify the URL (video, audio, article, etc.). If detection fails, the error's i18n key is wrapped with `anyhow!(\"Failed to detect URL kind: {}\")`. Without a kind, the engine cannot choose a parser.","triggerScenarios":"Calling `download` with a URL that `url_kind::detect` cannot classify — not a valid Bilibili URL at all, a b23.tv link that failed to resolve and remains a short URL, malformed video ID/BV numbers, or unsupported URL shapes (live rooms, space pages) the detector doesn't handle.","commonSituations":"Users pasting arbitrary web pages or non-Bilibili links; b23.tv short-link resolution failing due to network/redirect changes; new Bilibili URL formats not yet supported by the detector; typos in BV/AV ids.","solutions":["Verify the URL is a supported Bilibili content URL (video BV/AV, etc.) before calling download.","Ensure b23.tv short links can be resolved (network access); paste the expanded URL if resolution fails.","Update the app — new Bilibili URL formats require updated detection rules.","Map the error's i18n key to a user-facing message and prompt for a corrected link."],"exampleFix":"// before\nlet url = \"https://example.com/not-bilibili\";\ndownload(info_from(url), opts, progress).await?; // Failed to detect URL kind\n// after\nif !url.contains(\"bilibili.com\") && !url.contains(\"b23.tv\") {\n    return Err(anyhow!(\"not a Bilibili URL\"));\n}\ndownload(info_from(url), opts, progress).await?;","handlingStrategy":"validation","validationCode":"fn looks_like_bilibili(url: &str) -> bool {\n    url.contains(\"bilibili.com\") || url.contains(\"b23.tv\")\n}\nif !looks_like_bilibili(&effective_url) { return Err(anyhow!(\"unsupported URL\")); }","typeGuard":null,"tryCatchPattern":"match download(info, opts, progress).await {\n    Err(e) if e.to_string().contains(\"Failed to detect URL kind\") => ask_user_for_valid_link(),\n    Err(e) => return Err(e),\n    Ok(_) => {},\n}","preventionTips":["Validate that the input is a supported Bilibili URL before calling download.","Expand b23.tv short links and handle resolution failures explicitly.","Keep the app updated for new Bilibili URL formats.","Reject obviously non-Bilibili links in the UI input layer."],"tags":["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"}