{"record":{"id":"7b68b06afd8a9a0f","repo":"tonhowtf/omniget","slug":"could-not-resolve-short-link-mod","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/src/platforms/tiktok/mod.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/src/platforms/tiktok/mod.rs#L93-L129","documentation":"resolve_short_link walks the redirect target extracted from the short-link page and, if no resolvable full URL is found in the HTML, returns this error. It means a TikTok short link (vm.tiktok.com / vt.tiktok.com style) could not be converted to a canonical video URL.","triggerScenarios":"get_media_info receives a short TikTok link and the fetched page contains none of the expected URL patterns (e.g. the page is a captcha, an app-download interstitial, or the redirect markup changed).","commonSituations":"Expired or deleted short links, TikTok serving a captcha/bot wall instead of a redirect page, or TikTok changing the HTML structure that resolve_short_link scrapes.","solutions":["Retry later — the failure is often a transient bot-wall","Follow HTTP redirects directly (send with redirect policy enabled) instead of scraping HTML","Update the extraction patterns to match TikTok's current page markup","Ask the user for the full canonical tiktok.com/@user/video/ID URL"],"exampleFix":"// before: scrape HTML for the target URL\nErr(anyhow!(\"Could not resolve short link\"))\n// after: follow redirects natively\nlet resp = self.client.get(short_url).send().await?;\nlet full = resp.url().to_string();\nif !full.contains(\"/video/\") { return Err(anyhow!(\"Could not resolve short link: {}\", full)); }","handlingStrategy":"fallback","validationCode":"if url.contains(\"vm.tiktok.com\") || url.contains(\"vt.tiktok.com\") {\n    // expect resolution step; pre-check the link responds\n}","typeGuard":"fn is_short_link(url: &str) -> bool {\n    url.contains(\"vm.tiktok.com\") || url.contains(\"vt.tiktok.com\")\n}","tryCatchPattern":"match resolve_short_link(url).await {\n    Err(e) if e.to_string().contains(\"Could not resolve short link\") => {\n        ask_user_for_full_url(url)\n    }\n    other => other,\n}","preventionTips":["Prefer full canonical tiktok.com/@user/video/ID URLs over short links","Detect captcha pages before attempting URL extraction","Keep HTTP redirect following enabled and use response.url() when possible"],"tags":["tiktok","scraping","short-link"],"backgroundTag":"invalid-url","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"}