tonhowtf/omniget · error

download falhou: HTTP

Error message

download falhou: HTTP {}

What it means

Thrown inside Instagram media `download` when the HTTP response status is not a success (non-2xx). Instagram (or an intermediate CDN/proxy) rejected the media fetch, so the tool aborts instead of writing a corrupt file.

Solutions

  1. Refresh the media URL by re-fetching the post/story metadata, then retry the download
  2. Add valid session cookies/auth so the CDN accepts the request
  3. Slow down: add delays/backoff between downloads to avoid HTTP 429
  4. Check media still exists (404) — skip removed items
Defensive patterns

Strategy: retry

Validate before calling

// can't pre-validate remote status, but check URL freshness before download
let meta = fetch_media_metadata(id).await?; // re-signs/refreshes CDN URL
if meta.url.is_empty() { skip_item(id); }

Try / catch

match instagram::download(url, &dest).await {
    Ok(n) => info!("downloaded {} bytes", n),
    Err(e) if e.to_string().contains("download falhou") => {
        warn!("HTTP failure, retrying with backoff: {}", e);
        retry_with_backoff(3, || instagram::download(url, &dest)).await?;
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: `download` issues a GET with `Referer: https://www.instagram.com/` and the response `resp.status().is_success()` is false — e.g. 403 for expired/signed-out CDN URLs, 404 for deleted media, 429 rate limiting.

Common situations: Expired Instagram CDN media URL after the item URL aged out; Instagram blocking datacenter IPs or missing auth cookies; rate-limited bulk downloads; media deleted between listing and download.

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/ea74dc9478bedbf2. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/instagram/mod.rs:434

        self.absorb(&resp);
        if resp.status().is_redirection() {
            return Err(IgError::LoginRequired);
        }
        resp.text().await.map_err(|e| IgError::Other(e.to_string()))
    }

    /// Baixa um arquivo de CDN (sem cabeçalhos de API).
    pub async fn download(&self, url: &str, dest: &std::path::Path) -> anyhow::Result<u64> {
        use futures::StreamExt;
        use tokio::io::AsyncWriteExt;
        let resp = self
            .http
            .get(url)
            .header("Referer", "https://www.instagram.com/")
            .send()
            .await?;
        if !resp.status().is_success() {
            bail!("download falhou: HTTP {}", resp.status());
        }
        if let Some(p) = dest.parent() {
            std::fs::create_dir_all(p)?;
        }
        let part = dest.with_extension("part");
        let mut file = tokio::fs::File::create(&part).await?;
        let mut stream = resp.bytes_stream();
        let mut n = 0u64;
        while let Some(chunk) = stream.next().await {
            let chunk = chunk?;
            file.write_all(&chunk).await?;
            n += chunk.len() as u64;
        }
        file.flush().await?;
        drop(file);
        tokio::fs::rename(&part, dest).await?;
        Ok(n)
    }

View on GitHub (pinned to 8600b91f42)