{"record":{"id":"4bf92d6b2777e089","repo":"tonhowtf/omniget","slug":"could-not-resolve-short-link","errorCode":null,"errorMessage":"Could not resolve short link","messagePattern":"Could not resolve short link","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/platforms/tiktok.rs","lineNumber":111,"sourceCode":"            .headers()\n            .get(\"location\")\n            .and_then(|v| v.to_str().ok())\n        {\n            let clean = location.split('?').next().unwrap_or(location).to_string();\n            return Ok(clean);\n        }\n\n        let html = response.text().await?;\n\n        if html.starts_with(\"<a href=\\\"https://\") {\n            if let Some(url_part) = html.split(\"<a href=\\\"\").nth(1) {\n                let full_url = url_part.split('\"').next().unwrap_or(url_part);\n                let clean = full_url.split('?').next().unwrap_or(full_url).to_string();\n                return Ok(clean);\n            }\n        }\n\n        Err(anyhow!(\"Could not resolve short link\"))\n    }\n\n    fn is_captcha_page(html: &str) -> bool {\n        html.contains(\"verify-bar-close\")\n            || html.contains(\"captcha_verify\")\n            || html.contains(\"tiktok-verify-page\")\n            || html.contains(\"verify/page\")\n            || (html.contains(\"Verify to continue\")\n                && !html.contains(\"__UNIVERSAL_DATA_FOR_REHYDRATION__\"))\n    }\n\n    fn is_valid_play_addr(url: &str) -> bool {\n        if url.is_empty() {\n            return false;\n        }\n        if !url.starts_with(\"http://\") && !url.starts_with(\"https://\") {\n            return false;\n        }","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/platforms/tiktok.rs#L93-L129","documentation":"resolve_short_link in tiktok.rs follows TikTok short links (vm.tiktok.com / vt.tiktok.com) by fetching the page and scraping the canonical/redirect URL out of the HTML. If none of the extraction patterns match the response, it returns this error, meaning the short link could not be expanded to a full video URL.","triggerScenarios":"get_media_info calls resolve_short_link with a vm./vt.tiktok.com URL and: the HTML layout no longer contains the expected anchor/JSON URL markers, TikTok serves a redirect page variant, or an interstitial (captcha/region) page is returned instead.","commonSituations":"TikTok changing the short-link redirect page markup; a new URL field format that split('\"')/split('?') logic misses; regional redirects serving different HTML; heavy bot protection returning blank pages.","solutions":["Prefer following HTTP redirects (reqwest redirect policy) instead of scraping HTML for the URL","Log the fetched HTML when this fires and add the new URL pattern to the extraction logic","Retry — short-link resolution can transiently return interstitial pages","Fall back to constructing the canonical /video/{id} URL from the ID in the short link"],"exampleFix":"// before\nErr(anyhow!(\"Could not resolve short link\"))\n// after\nErr(anyhow!(\"Could not resolve short link: {} (page layout may have changed)\", short_url))","handlingStrategy":"fallback","validationCode":"if (/^https:\\/\\/(vm|vt)\\.tiktok\\.com\\//.test(url)) {\n  // short link: be prepared to fall back if expansion fails\n}","typeGuard":null,"tryCatchPattern":"let canonical = match tiktok.resolve_short_link(short).await {\n    Ok(u) => u,\n    Err(_) => follow_http_redirects(short).await?, // fallback\n};","preventionTips":["Enable HTTP redirect following so most short links resolve without scraping","Log failing pages to detect TikTok markup changes quickly","Cache resolved canonical URLs to reduce repeat short-link hits","Keep multiple extraction patterns for the redirect URL"],"tags":["tiktok","scraping","short-link"],"backgroundTag":"unexpected-response-shape","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"}