mirror of
https://github.com/Raine-gay/royal_road_archiver.git
synced 2024-11-14 11:28:43 -06:00
Removed rustls from reqwest since it breaks windows support
This commit is contained in:
parent
d46d8b209b
commit
7b8a9ab2df
59
Cargo.lock
generated
59
Cargo.lock
generated
|
@ -1203,7 +1203,6 @@ dependencies = [
|
|||
"once_cell",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"rustls",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
|
@ -1218,20 +1217,6 @@ dependencies = [
|
|||
"winreg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.17.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"getrandom",
|
||||
"libc",
|
||||
"spin",
|
||||
"untrusted",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "royal_road_archiver"
|
||||
version = "0.1.0"
|
||||
|
@ -1268,28 +1253,6 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.21.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba"
|
||||
dependencies = [
|
||||
"log",
|
||||
"ring",
|
||||
"rustls-webpki",
|
||||
"sct",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
version = "0.101.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.16"
|
||||
|
@ -1336,16 +1299,6 @@ dependencies = [
|
|||
"tendril",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sct"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "security-framework"
|
||||
version = "2.9.2"
|
||||
|
@ -1471,12 +1424,6 @@ dependencies = [
|
|||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.0"
|
||||
|
@ -1715,12 +1662,6 @@ version = "0.1.11"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
|
||||
|
||||
[[package]]
|
||||
name = "untrusted"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.5.0"
|
||||
|
|
|
@ -21,7 +21,7 @@ html2md = "0.2.14"
|
|||
indicatif = "0.17.7"
|
||||
path-slash = "0.2.1"
|
||||
regex = "1.10.3"
|
||||
reqwest = { version = "0.11.23", features = ["rustls", "blocking"] }
|
||||
reqwest = { version = "0.11.23", features = ["blocking"] }
|
||||
scraper = "0.18.1"
|
||||
serde_json = "1.0.111"
|
||||
url = "2.5.0"
|
||||
|
|
17
src/book.rs
17
src/book.rs
|
@ -1,3 +1,5 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
use scraper::Html;
|
||||
use url::Url;
|
||||
|
@ -23,6 +25,9 @@ pub struct Book {
|
|||
|
||||
/// A vector of the book's chapters.
|
||||
pub chapters: Vec<Chapter>,
|
||||
|
||||
/// A hashmap representing the book image urls and their corresponding img html tags.
|
||||
image_urls: HashMap<Url, Vec<String>>,
|
||||
}
|
||||
|
||||
impl Book {
|
||||
|
@ -34,6 +39,8 @@ impl Book {
|
|||
|
||||
let mut chapters: Vec<Chapter> = Vec::with_capacity(chapter_names_and_urls.len());
|
||||
|
||||
let mut image_urls: HashMap<Url, Vec<String>> = HashMap::new();
|
||||
|
||||
println!("\nDownloading and processing chapters:");
|
||||
// Spawn a progress bar showing how many chapters have been downloaded & processed.
|
||||
let progress_bar = ProgressBar::new(chapter_names_and_urls.len().try_into().unwrap());
|
||||
|
@ -46,6 +53,10 @@ impl Book {
|
|||
// Generate the chapters and add em to the book.
|
||||
for i in 0..chapter_names_and_urls.len() {
|
||||
let chapter = Chapter::new(&chapter_names_and_urls[i][0], &chapter_names_and_urls[i][1]);
|
||||
|
||||
// extract the image urls and add em to the image_urls hashmap.
|
||||
|
||||
|
||||
chapters.push(chapter);
|
||||
|
||||
progress_bar.inc(1);
|
||||
|
@ -60,6 +71,7 @@ impl Book {
|
|||
cover_image_url: http::string_to_url(&html::get_cover_image_url_from_index(&index_html)),
|
||||
index_html: index_html,
|
||||
chapters: chapters,
|
||||
image_urls: image_urls,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,11 +111,6 @@ impl Chapter {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO!
|
||||
struct BookImages {
|
||||
|
||||
}
|
||||
|
||||
// TODO!
|
||||
struct BookCss {
|
||||
|
||||
|
|
11
src/html.rs
11
src/html.rs
|
@ -1,7 +1,8 @@
|
|||
use std::process::exit;
|
||||
use std::{collections::HashMap, process::exit};
|
||||
|
||||
use regex::Regex;
|
||||
use scraper::{Html, Selector};
|
||||
use url::Url;
|
||||
|
||||
/// Convert a string to an html document.
|
||||
pub fn string_to_html_document(document_string: &str) -> Html {
|
||||
|
@ -158,4 +159,12 @@ pub fn remove_image_tags(html_fragment: Html) -> String {
|
|||
}
|
||||
|
||||
return html_fragment;
|
||||
}
|
||||
|
||||
pub fn extract_urls_and_imgs_tag(chapter_html: Html) -> HashMap<Url, Vec<String>> {
|
||||
let mut chapter_image_urls: HashMap<Url, Vec<String>> = HashMap::new();
|
||||
|
||||
|
||||
|
||||
return chapter_image_urls;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
use std::{fs::{File, OpenOptions}, io::Write, path::PathBuf, process::exit};
|
||||
use std::{fs::OpenOptions, io::Write, path::PathBuf, process::exit};
|
||||
|
||||
use chrono::prelude::Local;
|
||||
use clap::Args;
|
||||
|
@ -60,7 +60,7 @@ pub fn generate_audiobook(audiobook_args: AudiobookArgs, book_url: Url, output_d
|
|||
/// This function DOES NOT do any error checking on the Url or output directory & WILL panic if they are wrong.
|
||||
/// Make sure the Url is valid and the output directory is writable BEFORE passing them to this.
|
||||
pub fn generate_epub(epub_args: EpubArgs, book_url: Url, output_directory: PathBuf) {
|
||||
eprintln!("This is not implemented yet.");
|
||||
let book = book::Book::new(book_url);
|
||||
}
|
||||
|
||||
/// Generate an html archive from the given arguments, url, & outputs it to the output directory.
|
||||
|
|
Loading…
Reference in a new issue