{"record":{"id":"75684e21b5340984","repo":"tonhowtf/omniget","slug":"nao-achei-as-paginas-desse-documento-privado-ou-layout-novo","errorCode":null,"errorMessage":"nao achei as paginas desse documento (privado ou layout novo)","messagePattern":"nao achei as paginas desse documento \\(privado ou layout novo\\)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/calameo.rs","lineNumber":43,"sourceCode":"\npub async fn download(\n    url: &str,\n    dest_dir: &str,\n    progress: super::ProgressFn,\n) -> anyhow::Result<CalameoResult> {\n    if !url.contains(\"calameo.com\") {\n        return Err(anyhow!(\"cole um link do calameo.com\"));\n    }\n    let client = super::client()?;\n    let html = client\n        .get(url)\n        .send()\n        .await?\n        .error_for_status()?\n        .text()\n        .await?;\n    let prefix = page_prefix(&html)\n        .ok_or_else(|| anyhow!(\"nao achei as paginas desse documento (privado ou layout novo)\"))?;\n    let title = super::slides::og_title(&html).unwrap_or_else(|| \"calameo\".to_string());\n    let folder = PathBuf::from(dest_dir).join(super::sanitize_name(&title));\n    std::fs::create_dir_all(&folder)?;\n    let id = format!(\"calameo:{}\", url);\n    let mut n = 0usize;\n    let mut format = \"svg\".to_string();\n    for page in 1..=2000usize {\n        super::report(&progress, &id, \"download\", page as u64, None, None);\n        let svg_url = format!(\"{}p{}.svgz\", prefix, page);\n        let resp = client.get(&svg_url).send().await?;\n        if resp.status().is_success() {\n            let bytes = resp.bytes().await?;\n            let mut dec = flate2::read::GzDecoder::new(&bytes[..]);\n            let mut svg = Vec::new();\n            if dec.read_to_end(&mut svg).is_err() {\n                svg = bytes.to_vec();\n            }\n            tokio::fs::write(folder.join(format!(\"p{:04}.svg\", page)), &svg).await?;","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/calameo.rs#L25-L61","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the document is publicly viewable in a normal browser (logged out) and use its public read URL","If the layout genuinely changed, update page_prefix() in calameo.rs to match the new HTML structure","Check the fetched HTML manually (save it and inspect) to see whether a login wall or a new viewer format is being served"],"exampleFix":"// before\nlet html = client.get(private_url).send().await?.text().await?; // private doc\n// after\nlet html = client.get(public_read_url).send().await?.text().await?;\nlet prefix = page_prefix(&html).ok_or_else(|| anyhow!(\"nao achei as paginas...\"))?;","handlingStrategy":"fallback","validationCode":"// probe first\nlet html = client.get(url).send().await?.text().await?;\nif page_prefix(&html).is_none() {\n    anyhow::bail!(\"document not publicly readable or unsupported layout\");\n}","typeGuard":null,"tryCatchPattern":"match calameo::download(url, dest, progress).await {\n    Ok(res) => res,\n    Err(e) if e.to_string().contains(\"nao achei as paginas\") => {\n        eprintln!(\"Skipping {}: private or unsupported layout\", url);\n        Default::default()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Check that the document opens in a logged-out browser before batch downloading","Keep page_prefix updated against Calameo viewer changes; add a regression test with saved HTML fixtures","Detect login/paywall markers in the HTML and report a clearer message"],"tags":["calameo","scraping","parser","rust"],"backgroundTag":"unexpected-response-shape","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}