| Crates.io | libwebnovel-storage |
| lib.rs | libwebnovel-storage |
| version | 0.3.2 |
| created_at | 2024-09-15 19:50:22.555068+00 |
| updated_at | 2025-02-02 11:07:58.300029+00 |
| description | A complement to libwebnovel: this package handles downloading and organizing collections of followed webnovels |
| homepage | https://codeberg.org/paulollivier/libwebnovel-storage |
| repository | https://codeberg.org/paulollivier/libwebnovel-storage |
| max_upload_size | |
| id | 1375709 |
| size | 132,676 |
This is an implementation of a local repository of webnovels. It downloads webnovels & places them in a coherent manner on the filesystem. It is also capable of generating ebooks from these downloaded webnovels.
Basically, it provides data structures and method easing the work of
implementing a program using libwebnovel. Said program would only have to make the "glue" between UI and this library's functions.
use libwebnovel_storage::{LibraryError, LocalLibrary};
fn main() -> Result<(), LibraryError> {
let library_path = ".config/my_library/config.toml";
let mut library = LocalLibrary::load(library_path)?;
// Add to watchlist & download
library.add("https://www.royalroad.com/fiction/21220/mother-of-learning")?;
// update all novels
let errors = library.update();
// or, if you want to have more control over the update process
// (for instance, printing a progress bar):
for novel in library.novels_mut() {
let novel_title = novel.title()?.clone();
for (i, result) in novel.update_iter().enumerate() {
if result.is_err() {
eprintln!(
"Encountered an error while updating novel {}: {}",
novel_title,
result.unwrap_err()
);
}
println!("novel {}: updated chapter {}", novel_title, i + 1);
}
#[cfg(feature = "epub")]
println!(
"Generated ebook path: {}",
novel.generate_epub().unwrap().display()
);
}
Ok(())
}
cargo featuresBy default, the epub feature is active. If you do not wish to use this
feature, use the following in your Cargo.toml:
# Cargo.toml
[dependencies.libwebnovel-storage]
version = '0'
default-features = false
Without explicit refutation in the header of any file in this repository, all files in this repository are considered under the terms of the AGPL-3 license (of which a copy can be found in the LICENSE file at the root of this repository) and bearing the mention "Copyright (c) 2024 paulollivier & contributors".
Basically, please do not use this code without crediting its writer(s) or for a commercial project.
License: AGPL-3.0-or-later