tonhowtf/omniget · error
Erro ao processar resposta do TikTok
Error message
Erro ao processar resposta do TikTok
What it means
The TikTok HTML page was fetched, but the JSON embedded in the __UNIVERSAL_DATA_FOR_REHYDRATION__ script tag could not be parsed by serde_json. This means TikTok served a page whose rehydration payload is malformed, truncated, or not JSON (e.g. a captcha/interstitial page). The library throws it instead of panicking on from_str.
Solutions
- Wait a few minutes and retry — TikTok is likely serving an anti-bot challenge (see the companion 'TikTok is blocking requests' error).
- Check that the URL is a canonical tiktok.com video URL (@user/video/id) rather than a share/redirect link.
- Retry through a different IP / proxy or with fresh cookies to avoid the challenge page.
- Fall back to the yt-dlp path (get_media_info_via_ytdlp), which does not depend on the rehydration JSON.
Example fix
// caller-side fallback
match tiktok.get_media_info(url).await {
Ok(info) => info,
Err(e) if e.to_string().contains("Erro ao processar resposta do TikTok") => {
tiktok.get_media_info_via_ytdlp(url, &post_id).await?
}
Err(e) => return Err(e),
} Defensive patterns
Strategy: fallback
Try / catch
match tiktok.get_media_info(url).await {
Err(e) if e.to_string().contains("Erro ao processar resposta do TikTok") => tiktok.get_media_info_via_ytdlp(url, &post_id).await,
other => other,
} Prevention
- Always implement the yt-dlp fallback alongside the direct scraper.
- Back off between requests to avoid triggering TikTok's anti-bot challenge pages.
- Send realistic browser headers/cookies with every request.
- Monitor for this error spike as a signal that TikTok changed its response format.
When it happens
Trigger: fetch_detail receives HTML containing the __UNIVERSAL_DATA_FOR_REHYDRATION__ script tag, but serde_json::from_str fails on its contents — e.g. TikTok returned an anti-bot page, a partially-rendered SSR page, or an encoding that breaks JSON parsing.
Common situations: TikTok's bot protection serving a challenge page instead of the real video page; TikTok changing the payload shape/escaping; proxy or CDN mangling the response; rate-limiting from rapid repeated get_media_info calls.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- a API do TikTok devolveu resposta vazia — normalmente é a…
- a lista voltou vazia — o TikTok não entregou os favoritos…
- a resposta da API do TikTok não era JSON
- Age-restricted content
- Could not resolve short link
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/b9162eb373c018db.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/platforms/tiktok.rs:171
*self.captured_cookies.lock().await = Some(cookie_str);
}
let html = response.text().await?;
if Self::is_captcha_page(&html) {
return Err(anyhow!(
"TikTok is blocking requests. Try again in a few minutes."
));
}
let json_str = html
.split("<script id=\"__UNIVERSAL_DATA_FOR_REHYDRATION__\" type=\"application/json\">")
.nth(1)
.and_then(|s| s.split("</script>").next())
.ok_or_else(|| anyhow!("TikTok is blocking requests. Try again in a few minutes."))?;
let data: serde_json::Value = serde_json::from_str(json_str)
.map_err(|_| anyhow!("Erro ao processar resposta do TikTok"))?;
let video_detail = data
.get("__DEFAULT_SCOPE__")
.and_then(|s| s.get("webapp.video-detail"))
.ok_or_else(|| anyhow!("Video data not found in TikTok response"))?;
if let Some(status_msg) = video_detail
.get("statusMsg")
.and_then(|v| v.as_str())
.filter(|s| !s.is_empty())
{
return Err(anyhow!("Post not available: {}", status_msg));
}
if let Some(status_code) = video_detail.get("statusCode").and_then(|v| v.as_u64()) {
if status_code != 0 {
return Err(anyhow!("Post not available (status {})", status_code));
}View on GitHub (pinned to 8600b91f42)