tonhowtf/omniget · error · Error

YouTube não retornou URL

Error message

YouTube não retornou URL

What it means

Raised by get_guest_token in the Twitter platform module when the guest-token endpoint returns a non-2xx status. The guest token is required for anonymous API access to tweet metadata/media; without it no tweet can be resolved.

Solutions

  1. Retry with exponential backoff and jitter on 429/5xx; cache and reuse guest tokens instead of fetching per request.
  2. On 403, expect bot protection: update headers (user-agent, bearer token) or route via authenticated cookies / a different network.
  3. Verify the guest token endpoint URL and required auth headers are still current — this API changes frequently.
  4. Log the response body and fall back to authenticated access (user-provided cookies) if guest access is blocked.

Example fix

// before
if !response.status().is_success() {
    return Err(anyhow!("Falha ao obter guest token: HTTP {}", response.status()));
}
// after
let status = response.status();
if !status.is_success() {
    let body = response.text().await.unwrap_or_default();
    if status.as_u16() == 429 {
        return Err(TwitterError::RateLimited); // caller retries with backoff
    }
    anyhow::bail!("Guest token HTTP {}: {}", status, body);
}
Defensive patterns

Strategy: retry

Try / catch

// Cache guest tokens; back off on 429/403
match get_guest_token().await {
    Err(e) if e.to_string().contains("HTTP 429") => backoff_then_retry(),
    Err(e) if e.to_string().contains("HTTP 403") => switch_to_authenticated_access(),
    other => other,
}

Prevention

When it happens

Trigger: GET to the guest token activation endpoint (with x-twitter-active-user / Accept-Language headers) returns a non-success status — 403 bot protection, 429 rate limit, 400 bad headers, 5xx outage.

Common situations: X/Twitter tightening anti-bot measures (403 on guest activation); guest-token endpoint deprecated or changed; datacenter IP blocked; heavy scraping triggering 429s; missing or stale public bearer token header.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/c72f53e65c102b51. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/study-music/spotify-store.svelte.ts:155

    youtube_url: string;
    video_id: string;
    video_title: string;
    channel: string;
    score: number;
  }>("study", "study:spotify:resolve_youtube", {
    title: track.title,
    artist: track.artist,
    durationMs: track.duration_ms ?? 0,
    isrc: track.isrc,
  });
  console.log("[spotify-yt] resolved:", {
    video_id: res.video_id,
    video_title: res.video_title,
    channel: res.channel,
    score: res.score,
    url_preview: res.youtube_url?.slice(0, 100),
  });
  if (!res.youtube_url) throw new Error("YouTube não retornou URL");
  return res.youtube_url;
}

if (typeof window !== "undefined") {
  musicPlayer.spotifyFreeFallback = resolveSpotifyToYoutube;
}

function mapTrack(item: any, addedAt?: string, playedAt?: string): SpotifyTrack | null {
  const t = item?.track ?? item;
  if (!t || !t.id) return null;
  return {
    id: t.id,
    name: t.name ?? "",
    uri: t.uri ?? `spotify:track:${t.id}`,
    duration_ms: t.duration_ms ?? 0,
    explicit: !!t.explicit,
    is_playable: t.is_playable,
    preview_url: t.preview_url ?? null,

View on GitHub (pinned to 8600b91f42)