diff options
| author | A Farzat <a@farzat.xyz> | 2026-03-03 14:16:45 +0300 |
|---|---|---|
| committer | A Farzat <a@farzat.xyz> | 2026-03-03 14:16:45 +0300 |
| commit | 6782269bb52a349e9568a28ed6c1f43438b7bb24 (patch) | |
| tree | 4f2cc973c6d160c475790dccf38aebeb4c5d4a69 /src/main.rs | |
| parent | 9a95cf1684fcd8bfc81efcac7676532413d35328 (diff) | |
| download | oreilly-epub-6782269bb52a349e9568a28ed6c1f43438b7bb24.tar.gz oreilly-epub-6782269bb52a349e9568a28ed6c1f43438b7bb24.zip | |
Add container.xml to zip
Instead of writing it to file and then reading it again, we write
container.xml straight to zip, just like we did with mimetype.
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs index db1fdd4..8c5c712 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ mod models; use std::collections::HashMap; use std::path::Path; -use crate::epub::{download_all_files, write_container_xml}; +use crate::epub::{download_all_files,}; use crate::http_client::build_authenticated_client; use crate::models::{Chapter, EpubResponse, FileEntry, Paginated, SpineItem, TocNode}; use anyhow::{Context, Result, ensure}; @@ -112,16 +112,9 @@ async fn main() -> Result<()> { let spine_items: Vec<SpineItem> = fetch_all_pages(&client, epub_data.spine.clone()).await?; let toc_vec: Vec<TocNode> = fetch_direct_array(&client, &epub_data.table_of_contents).await?; - // Find the OPF file entry to reference it in container.xml - let opf_entry = file_entries - .iter() - .find(|f| f.filename_ext == ".opf" && f.media_type == "application/oebps-package+xml") - .context("No OPF file with the correct MIME type was found.")?; - let dest_root = format!("Books/{}/epub_root", args.bookid); let dest_root = Path::new(&dest_root); download_all_files(&client, &file_entries, dest_root).await?; - write_container_xml(dest_root, &opf_entry.full_path).await?; // Sanity check: Every entry in spine exists in chapters. let chapters: HashMap<String, Chapter> = |
