From 8b38cee7b888dace02d2248c6f6019c7fddc17b7 Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 11 Nov 2024 10:15:03 +0100 Subject: [PATCH 1/7] README updated --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 1b3d891..564b3dc 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,6 @@ This program has been tested on a PocketBook It might work with other PocketBook devices/software versions. Please tell me if it works for you (and do make a backup of the explorer-3.db file before trying!). -**Please note:** As I do not currently own a PocketBook device, I am unfortunately unable to react to changes in the database structure. Perhaps you can send me your `explorer-3.db` so that I can take a look at the changes. Just get in touch with me. - ## Installation and Usage --- **WARNING**: From da77983228cfae45cfd4f8fc66b75919f67014ae Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Tue, 12 Nov 2024 10:37:01 +0100 Subject: [PATCH 2/7] get_rootfile() simplified --- Cargo.lock | 2 +- src/epub.rs | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1e7a0f..dd0508f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -396,7 +396,7 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "pbdbfixer" -version = "0.8.3" +version = "0.9.0" dependencies = [ "quick-xml", "rusqlite", diff --git a/src/epub.rs b/src/epub.rs index 3574377..82d67bc 100644 --- a/src/epub.rs +++ b/src/epub.rs @@ -61,18 +61,17 @@ fn get_rootfile(archive: &mut ZipArchive) -> String { loop { match reader.read_event_into(&mut buf) { Ok(Event::Start(ref e)) | Ok(Event::Empty(ref e)) - if e.local_name().into_inner() == b"rootfile" => + if e.name().as_ref() == b"rootfile" => { - opf_filename = String::from_utf8( - e.attributes() - .filter(|attr| attr.as_ref().unwrap().key.into_inner() == b"full-path") - .next() - .unwrap() - .unwrap() - .value - .to_vec(), - ) - .unwrap(); + opf_filename = e + .attributes() + .filter(|attr| attr.as_ref().unwrap().key.as_ref() == b"full-path") + .next() + .unwrap() + .unwrap() + .unescape_value() + .unwrap() + .to_string(); break; } Ok(Event::Eof) => break, From b02ede51820d9293cc6152f2a821f4687ff5ecb8 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Tue, 12 Nov 2024 10:57:03 +0100 Subject: [PATCH 3/7] get_epub_metadata() simplified. --- src/epub.rs | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/epub.rs b/src/epub.rs index 82d67bc..3ee7e28 100644 --- a/src/epub.rs +++ b/src/epub.rs @@ -1,5 +1,4 @@ use std::{ - borrow::Borrow, collections::HashMap, fs::{self, File}, io::Read, @@ -132,20 +131,20 @@ pub fn get_epub_metadata(filename: &str) -> Option { loop { match reader.read_event_into(&mut buf) { // See if we have EPUB3 or EPUB2 - Ok(Event::Start(ref e)) if e.local_name().into_inner() == b"package" => { + Ok(Event::Start(ref e)) if e.name().as_ref() == b"package" => { if e.attributes().any(|attr| { - attr.as_ref().unwrap().key.into_inner() == b"version" + attr.as_ref().unwrap().key.as_ref() == b"version" && attr.as_ref().unwrap().value.starts_with(b"3") }) { is_epub3 = true; } } - Ok(Event::Start(ref e)) if e.local_name().into_inner() == b"creator" => { + Ok(Event::Start(ref e)) if e.local_name().as_ref() == b"creator" => { creator_found = true; if is_epub3 { if let Some(idval) = e .attributes() - .filter(|attr| attr.as_ref().unwrap().key.into_inner() == b"id") + .filter(|attr| attr.as_ref().unwrap().key.as_ref() == b"id") .next() { curr_id = "#".to_string() @@ -165,7 +164,7 @@ pub fn get_epub_metadata(filename: &str) -> Option { attr.as_ref() .unwrap() .key - .into_inner() + .as_ref() .ends_with(b"file-as") }) .next() @@ -174,13 +173,13 @@ pub fn get_epub_metadata(filename: &str) -> Option { let entry = xml_authors.entry(curr_id.clone()).or_insert(XmlAut::new()); entry.sort = file_as_val .unwrap() - .decode_and_unescape_value(*reader.decoder().borrow()) + .unescape_value() .unwrap_or_default() .to_string(); entry.role = "aut".to_string(); } else if let Some(_role_val) = e .attributes() - .filter(|attr| attr.as_ref().unwrap().key.into_inner().ends_with(b"role")) + .filter(|attr| attr.as_ref().unwrap().key.as_ref().ends_with(b"role")) .next() { curr_id = "none".to_string() + xml_authors.len().to_string().as_str(); @@ -199,33 +198,33 @@ pub fn get_epub_metadata(filename: &str) -> Option { creator_found = false; } - Ok(Event::Start(ref e)) if e.local_name().into_inner() == b"meta" && is_epub3 => { + Ok(Event::Start(ref e)) if e.local_name().as_ref() == b"meta" && is_epub3 => { if let Some(refines) = e .attributes() - .filter(|attr| attr.as_ref().unwrap().key.into_inner() == b"refines") + .filter(|attr| attr.as_ref().unwrap().key.as_ref() == b"refines") .next() { if e.attributes().any(|attr| { - attr.as_ref().unwrap().key.into_inner() == b"property" + attr.as_ref().unwrap().key.as_ref() == b"property" && attr.as_ref().unwrap().value.ends_with(b"file-as") }) { curr_id = String::from_utf8(refines.unwrap().value.to_vec()).unwrap(); file_as_found = true; } else if e.attributes().any(|attr| { - attr.as_ref().unwrap().key.into_inner() == b"property" + attr.as_ref().unwrap().key.as_ref() == b"property" && attr.as_ref().unwrap().value.ends_with(b"role") }) { curr_id = String::from_utf8(refines.unwrap().value.to_vec()).unwrap(); role_found = true; } else if e.attributes().any(|attr| { - attr.as_ref().unwrap().key.into_inner() == b"property" + attr.as_ref().unwrap().key.as_ref() == b"property" && attr.as_ref().unwrap().value.ends_with(b"group-position") }) { series_index_found = true; } } if e.attributes().any(|attr| { - attr.as_ref().unwrap().key.into_inner() == b"property" + attr.as_ref().unwrap().key.as_ref() == b"property" && attr .as_ref() .unwrap() @@ -235,9 +234,9 @@ pub fn get_epub_metadata(filename: &str) -> Option { series_found = true; } } - Ok(Event::Empty(ref e)) if e.local_name().into_inner() == b"meta" && !is_epub3 => { + Ok(Event::Empty(ref e)) if e.local_name().as_ref() == b"meta" && !is_epub3 => { if e.attributes().any(|attr| { - attr.as_ref().unwrap().key.into_inner() == b"name" + attr.as_ref().unwrap().key.as_ref() == b"name" && attr .as_ref() .unwrap() @@ -247,15 +246,15 @@ pub fn get_epub_metadata(filename: &str) -> Option { }) { epub_meta.series.name = e .attributes() - .filter(|attr| attr.as_ref().unwrap().key.into_inner() == b"content") + .filter(|attr| attr.as_ref().unwrap().key.as_ref() == b"content") .next() .unwrap() .unwrap() - .decode_and_unescape_value(*reader.decoder().borrow()) + .unescape_value() .unwrap_or_default() .to_string(); } else if e.attributes().any(|attr| { - attr.as_ref().unwrap().key.into_inner() == b"name" + attr.as_ref().unwrap().key.as_ref() == b"name" && attr .as_ref() .unwrap() @@ -265,11 +264,11 @@ pub fn get_epub_metadata(filename: &str) -> Option { }) { let index_float = e .attributes() - .filter(|attr| attr.as_ref().unwrap().key.into_inner() == b"content") + .filter(|attr| attr.as_ref().unwrap().key.as_ref() == b"content") .next() .unwrap() .unwrap() - .decode_and_unescape_value(*reader.decoder().borrow()) + .unescape_value() .unwrap_or_default() .parse::() .unwrap_or_default(); @@ -301,11 +300,10 @@ pub fn get_epub_metadata(filename: &str) -> Option { series_index_found = false; } - Ok(Event::Start(ref e)) if e.local_name().into_inner() == b"subject" => { + Ok(Event::Start(ref e)) if e.local_name().as_ref() == b"subject" => { genre_found = true; } Ok(Event::Text(ref e)) if genre_found => { - //epub_meta.genre = e.unescape_and_decode(&reader).unwrap(); epub_meta.genre = e.unescape().unwrap().to_string(); genre_found = false; } From 35a0c1559ba51f6be7aacc7ffb4f4974f808de3a Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Tue, 14 Jan 2025 10:02:30 +0100 Subject: [PATCH 4/7] Attempt to support books on sdcard --- src/database.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/database.rs b/src/database.rs index 45d9771..e640771 100644 --- a/src/database.rs +++ b/src/database.rs @@ -30,7 +30,7 @@ fn get_epubs_from_database(tx: &Transaction) -> Vec { r#" SELECT books.id, folders.name, files.filename, books.firstauthor, books.author, genres.name, first_author_letter, series - FROM books_impl books JOIN files + FROM books_impl books JOIN files, storages ON books.id = files.book_id JOIN folders ON folders.id = files.folder_id @@ -38,7 +38,7 @@ fn get_epubs_from_database(tx: &Transaction) -> Vec { ON books.id = btg.bookid LEFT OUTER JOIN genres ON genres.id = btg.genreid - WHERE files.storageid = 1 AND {}.ext = 'epub' + WHERE files.storageid IN (SELECT storages.id WHERE storages.type = 1) AND {}.ext = 'epub' ORDER BY books.id"#, &books_or_files ); From d40637f5358d259d0a63a92b30660db350c78e9e Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Fri, 21 Feb 2025 08:52:49 +0100 Subject: [PATCH 5/7] edition 2024 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 08f848d..79d147d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "pbdbfixer" version = "0.9.0" authors = ["Martin Brodbeck "] -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From a26225b3a29248b06923e7e9f48801e9777e6426 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Thu, 8 May 2025 10:18:19 +0200 Subject: [PATCH 6/7] New version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 79d147d..7ec5c0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pbdbfixer" -version = "0.9.0" +version = "1.0.0" authors = ["Martin Brodbeck "] edition = "2024" From 35a689dbeb1a4ac1d78b14ac5d25b46a51704014 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Thu, 8 May 2025 10:41:21 +0200 Subject: [PATCH 7/7] =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd0508f..81ed7a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler2" @@ -396,7 +396,7 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "pbdbfixer" -version = "0.9.0" +version = "1.0.0" dependencies = [ "quick-xml", "rusqlite",