Crate libwebnovel_storage

source ·
Expand description

docs.rs

This is an implementation of a local repository of webnovels. It downloads webnovels & places them in a coherent manner on the filesystem.

§What this does

Basically, it provides data structures and method easing the work of implementing a program using libwebnovel.

§Example

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);
        }
    }

    Ok(())
}

§TODO

  • a local filesystem representation for a novel library
  • bulk updates
    • bulk updates with an iterator, to offer control over looping and get update information while they happen
  • add epub generation

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.

Structs§

  • A local disk storage.
  • Represents a novel. Stored on disk at the following path: <base_library_path>/<novel.title()>/
  • An iterator over the update operation of a chapter. Used to be able to monitor progress from your code.

Enums§

  • Represents an error that can happen during Library operations