tonhowtf/omniget · error · anyhow::Error

nao achei as paginas desse documento (privado ou layout…

Error message

nao achei as paginas desse documento (privado ou layout novo)

What it means

After fetching the document page, calameo::download calls page_prefix(&html) to extract the CDN page prefix used to build per-page image URLs. When the prefix cannot be found the document is either private/protected or Calameo changed its page layout, so the tool cannot construct download URLs and raises this error.

Solutions

  1. Confirm the document is publicly viewable in a normal browser (logged out) and use its public read URL
  2. If the layout genuinely changed, update page_prefix() in calameo.rs to match the new HTML structure
  3. Check the fetched HTML manually (save it and inspect) to see whether a login wall or a new viewer format is being served

Example fix

// before
let html = client.get(private_url).send().await?.text().await?; // private doc
// after
let html = client.get(public_read_url).send().await?.text().await?;
let prefix = page_prefix(&html).ok_or_else(|| anyhow!("nao achei as paginas..."))?;
Defensive patterns

Strategy: fallback

Validate before calling

// probe first
let html = client.get(url).send().await?.text().await?;
if page_prefix(&html).is_none() {
    anyhow::bail!("document not publicly readable or unsupported layout");
}

Try / catch

match calameo::download(url, dest, progress).await {
    Ok(res) => res,
    Err(e) if e.to_string().contains("nao achei as paginas") => {
        eprintln!("Skipping {}: private or unsupported layout", url);
        Default::default()
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: download() fetched the page successfully (HTTP 200) but the HTML contains no recognizable page-prefix pattern: viewer-restricted/private document, age/login-gated document, or a new Calameo viewer layout that page_prefix's regex/parsing no longer matches.

Common situations: Attempting to download a paywalled or access-restricted document; Calameo shipping a front-end redesign that breaks the scraper; document deleted but URL still serving a stub page.

Related errors


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

Appendix: source

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

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 {
        super::report(&progress, &id, "download", page as u64, None, None);
        let svg_url = format!("{}p{}.svgz", prefix, page);
        let resp = client.get(&svg_url).send().await?;
        if resp.status().is_success() {
            let bytes = resp.bytes().await?;
            let mut dec = flate2::read::GzDecoder::new(&bytes[..]);
            let mut svg = Vec::new();
            if dec.read_to_end(&mut svg).is_err() {
                svg = bytes.to_vec();
            }
            tokio::fs::write(folder.join(format!("p{:04}.svg", page)), &svg).await?;

View on GitHub (pinned to 8600b91f42)