tonhowtf/omniget · error · anyhow::Error

não achei o secUid de @

Error message

não achei o secUid de @{} na página do perfil — a sessão pode ter expirado

What it means

After authenticating with the session cookies, list_private() fetches the profile page HTML and extracts the secUid via parse_sec_uid; when extraction fails it raises this anyhow error. Since the full profile page only renders for logged-in sessions, a missing secUid usually means the session is no longer valid.

Solutions

  1. Re-export fresh tiktok.com cookies (Netscape format) and update opts.session_netscape.
  2. Verify the handle is correct and the profile opens in a browser while logged in with the same account.
  3. Open tiktok.com in the browser; if it asks you to log in again or shows a captcha, resolve that before retrying.
  4. Retry later if TikTok is serving a bot-check page; consider adding delay between runs.

Example fix

// before
let opts = FavoritesOpts { session_netscape: Some("old-cookies.txt".into()), .. };
// after
// re-export cookies.txt in the browser extension, then:
let opts = FavoritesOpts { session_netscape: Some("cookies-fresh.txt".into()), .. };
Defensive patterns

Strategy: retry

Validate before calling

// Rust
// Verify session validity by opening the profile in the same cookie jar before batch runs:
// if a browser with those cookies shows the login page, re-export cookies first.
fn cookies_recent(path: &std::path::Path, max_age: std::time::Duration) -> bool {
    std::fs::metadata(path).and_then(|m| m.modified()).ok()
        .and_then(|t| t.elapsed().ok()).map_or(false, |age| age < max_age)
}

Type guard

fn extracted_sec_uid(html: &str) -> Option<String> { parse_sec_uid(html) }

Try / catch

match run(opts).await {
    Ok(entries) => render(entries),
    Err(e) if e.to_string().contains("secUid") => {
        eprintln!("Sessão expirada — reexporte os cookies");
        // re-export then retry once
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling run for favorites/liked when the cookies are expired, the logged-in account was changed or logged out, TikTok served a consent/captcha page instead of the profile, or the handle does not exist so the page has no secUid.

Common situations: Cookies exported days/weeks ago have expired; user logged out or rotated devices; TikTok shows a login wall or bot check; handle typo makes the profile 404.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/tiktok/favorites.rs:370

    let session = opts
        .session_netscape
        .as_deref()
        .filter(|c| !c.trim().is_empty())
        .ok_or_else(|| {
            anyhow!(
                "os favoritos e os curtidos só saem com a sua sessão: capture os cookies do \
                 tiktok.com pela extensão e escolha a conta aqui"
            )
        })?;
    let (client, _) = super::cookie_client(Some(session))?;

    // O `secUid` vem da própria página do perfil, que só abre inteira para
    // quem está logado.
    pacer.wait().await;
    let profile = format!("https://www.tiktok.com/@{}", handle);
    let html = client.get(&profile).send().await?.text().await?;
    let sec_uid = parse_sec_uid(&html).ok_or_else(|| {
        anyhow!(
            "não achei o secUid de @{} na página do perfil — a sessão pode ter expirado",
            handle
        )
    })?;

    let mut out: Vec<Entry> = Vec::new();
    let mut cursor = String::from("0");
    let teto = if opts.limit == 0 {
        u32::MAX
    } else {
        opts.limit
    };
    for _ in 0..200 {
        let url = item_list_url(&opts.source, &sec_uid, &cursor, 30)
            .ok_or_else(|| anyhow!("fonte desconhecida: {}", opts.source))?;
        pacer.wait().await;
        let resp = client.get(&url).header("Referer", &profile).send().await?;
        if !resp.status().is_success() {

View on GitHub (pinned to 8600b91f42)