You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some epubs may use custom string when assigning their cover images. My current workaround is below, some context is missing but i'm sure you can figure it out
//Look for keys in the hashmap containing the word cover
let pattern = r"(?i)cover";
let regex = Regex::new(pattern).unwrap();
let epub_resources = doc.resources.clone();
println!("Resources {:?}", epub_resources);
let cover_id = epub_resources.keys().find(|key| regex.is_match(key));
if cover_id.is_some() {
let cover = doc.get_resource(cover_id.unwrap());
let cover_data = cover.unwrap().0;
let mut f = fs::File
::create(&cover_path)
.map_err(|err| format!("Error creating cover file: {}", err))?;
f.write_all(&cover_data).map_err(|err| format!("Error writing cover data: {}", err))?;
} else {
//Return our error thumbnail placeholder
return Ok(format!("{}/{}", get_home_dir(), "error.jpg"));
}
The text was updated successfully, but these errors were encountered:
Some epubs may use custom string when assigning their cover images. My current workaround is below, some context is missing but i'm sure you can figure it out
The text was updated successfully, but these errors were encountered: