From a31db5a182c7d45ca6720a99c409b5c35fad69bb Mon Sep 17 00:00:00 2001 From: A Farzat Date: Wed, 4 Mar 2026 21:14:32 +0300 Subject: Convert URLs pointing upstream to local relative EPUB standard only recognizes relative paths. Fixes image rendering. --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 3c5956e..80f81e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ mod epub; mod http_client; mod models; +use std::collections::HashMap; use std::path::Path; use crate::epub::{create_epub_archive, download_all_files}; @@ -107,6 +108,8 @@ async fn main() -> Result<()> { println!("Fetching book structure..."); let chapters: Vec = fetch_all_pages(&client, epub_data.chapters.clone()).await?; + let chapters: HashMap = + chapters.into_iter().map(|c| (c.ourn.clone(), c)).collect(); let file_entries: Vec = fetch_all_pages(&client, epub_data.files.clone()).await?; let spine_items: Vec = fetch_all_pages(&client, epub_data.spine.clone()).await?; let toc_vec: Vec = fetch_direct_array(&client, &epub_data.table_of_contents).await?; @@ -116,7 +119,7 @@ async fn main() -> Result<()> { download_all_files(&client, &file_entries, dest_root).await?; let epub_path = format!("Books/{0}/{0}.epub", args.bookid); let epub_path = Path::new(&epub_path); - create_epub_archive(dest_root, &epub_path, &file_entries)?; + create_epub_archive(dest_root, epub_path, &file_entries, &chapters)?; Ok(()) } -- cgit v1.2.3-70-g09d2