aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2026-03-03 08:38:11 +0300
committerA Farzat <a@farzat.xyz>2026-03-03 08:38:11 +0300
commit859700794abece7d5a90896a87fe012164d9fc0e (patch)
treeb028b02785c06d90050b1865d9d152a2738061c2 /src
parentc0e92932f83ece433426d7e711c5165420a71e6c (diff)
downloadoreilly-epub-859700794abece7d5a90896a87fe012164d9fc0e.tar.gz
oreilly-epub-859700794abece7d5a90896a87fe012164d9fc0e.zip
Add OPF file detection
We need to know its full_path as it will be referenced in container.xml.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 34d4d51..4f28d52 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -109,6 +109,12 @@ 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.")?;
+
// Sanity check: Every entry in spine exists in chapters.
let chapters: HashMap<String, Chapter> =
chapters.into_iter().map(|c| (c.ourn.clone(), c)).collect();