tonhowtf/omniget · error · anyhow::Error

Failed to download thumbnail

Error message

Failed to download thumbnail: {}

What it means

download_thumbnail fetches a thumbnail image URL before embedding it with ffmpeg. When the reqwest GET fails to even complete (DNS failure, connection refused, TLS error, timeout), the code wraps the transport error with this message via anyhow. It indicates the HTTP request itself failed, not a bad status code.

Solutions

  1. Check network connectivity/DNS to the thumbnail host; test the URL in a browser or with curl.
  2. Verify the thumbnail URL is valid and not expired; re-extract metadata if the URL contains a signature.
  3. If a request timeout/proxy is involved, configure reqwest Client with proper timeout and proxy settings.
  4. Make thumbnail embedding non-fatal: fall back to skipping thumbnail embed when download fails.

Example fix

// before
let response = client.get(url).send().await
    .map_err(|e| anyhow!("Failed to download thumbnail: {}", e))?;
// after
let response = match client.get(url).send().await {
    Ok(r) => r,
    Err(e) => {
        log::warn!("thumbnail download failed, skipping embed: {e}");
        return Ok(None); // proceed without thumbnail
    }
};
Defensive patterns

Strategy: try-catch

Validate before calling

// Rust: sanity-check the URL before requesting
if !url.starts_with("http") {
    anyhow::bail!("invalid thumbnail url: {url}");
}
// optionally: if tokio::net::lookup_host(host_port).await.is_err() { bail!("DNS failure") }

Try / catch

match client.get(url).send().await {
    Ok(resp) => resp,
    Err(e) => { log::warn!("thumb fetch failed: {e}"); return Ok(None); } // degrade gracefully
};

Prevention

When it happens

Trigger: Calling embed_metadata -> download_thumbnail when the thumbnail host is unreachable, DNS fails, the URL scheme is unsupported, TLS handshake fails, or the request times out.

Common situations: Video host serves thumbnails from a different CDN that is blocked/offline; offline or proxied environment; thumbnail URL extracted with an expired signed token; misconfigured proxy blocking the request.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/ffmpeg.rs:579

    }
    if !rename_ok {
        let _ = std::fs::remove_file(&temp_output);
        return Err(anyhow!("Failed to replace file"));
    }

    Ok(())
}

async fn download_thumbnail(
    client: &reqwest::Client,
    url: &str,
    dest_dir: &Path,
) -> anyhow::Result<std::path::PathBuf> {
    let response = client
        .get(url)
        .send()
        .await
        .map_err(|e| anyhow!("Failed to download thumbnail: {}", e))?;

    let content_type = response
        .headers()
        .get("content-type")
        .and_then(|v| v.to_str().ok())
        .unwrap_or("image/jpeg")
        .to_string();

    let bytes = response
        .bytes()
        .await
        .map_err(|e| anyhow!("Failed to read thumbnail: {}", e))?;

    let ext = if content_type.contains("png") {
        "png"
    } else {
        "jpg"
    };

View on GitHub (pinned to 8600b91f42)