tonhowtf/omniget · error · anyhow::Error

cole um link do calameo.com

Error message

cole um link do calameo.com

What it means

calameo::download performs a cheap substring check on the provided URL and rejects anything that does not contain 'calameo.com' before making any network request. It is a guard against passing documents from other services or malformed input to the Calameo downloader.

Solutions

  1. Pass the full public Calameo URL, e.g. https://www.calameo.com/read/0056...— including the calameo.com host
  2. Normalize the input before calling download (prepend https://www.calameo.com/... if you only have an ID and know the path format)
  3. Route non-calameo URLs to the appropriate tool instead of calameo::download

Example fix

// before
calameo::download("005678901abcdef2345", &dest, progress).await?;
// after
calameo::download("https://www.calameo.com/read/005678901abcdef2345", &dest, progress).await?;
Defensive patterns

Strategy: validation

Validate before calling

let url = url.trim();
if !url.starts_with("http") || !url.contains("calameo.com") {
    anyhow::bail!("expected a calameo.com URL");
}

Type guard

fn is_calameo_url(url: &str) -> bool { url.contains("calameo.com") }

Prevention

When it happens

Trigger: Calling download(url, dest_dir, progress) with a URL from another provider (issuu, scribd), a bare document ID, an empty string, or a typo'd domain (e.g. 'calameo.org').

Common situations: Mixing up URL strings in a batch-download script; user pasting an embedded-viewer URL on a different host; clipboard missing part of the URL.

Understand the failure class

Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/calameo.rs:32

    pub pages: usize,
    pub folder: String,
    pub format: String,
}

pub fn page_prefix(html: &str) -> Option<String> {
    let re = regex::Regex::new(r#"<meta[^>]*property="og:image"[^>]*content="([^"]+)""#).ok()?;
    let img = re.captures(html)?[1].to_string();
    let re2 = regex::Regex::new(r"^(.*?/)p?1\.(svgz|jpg|jpeg|png)").ok()?;
    re2.captures(&img).map(|c| c[1].to_string())
}

pub async fn download(
    url: &str,
    dest_dir: &str,
    progress: super::ProgressFn,
) -> anyhow::Result<CalameoResult> {
    if !url.contains("calameo.com") {
        return Err(anyhow!("cole um link do calameo.com"));
    }
    let client = super::client()?;
    let html = client
        .get(url)
        .send()
        .await?
        .error_for_status()?
        .text()
        .await?;
    let prefix = page_prefix(&html)
        .ok_or_else(|| anyhow!("nao achei as paginas desse documento (privado ou layout novo)"))?;
    let title = super::slides::og_title(&html).unwrap_or_else(|| "calameo".to_string());
    let folder = PathBuf::from(dest_dir).join(super::sanitize_name(&title));
    std::fs::create_dir_all(&folder)?;
    let id = format!("calameo:{}", url);
    let mut n = 0usize;
    let mut format = "svg".to_string();
    for page in 1..=2000usize {

View on GitHub (pinned to 8600b91f42)