.clone() is a crime against humanity, but sometimes those can be a good thing
This commit is contained in:
parent
d55c600eee
commit
f2d40849db
10
src/lib.rs
10
src/lib.rs
|
@ -1,3 +1,5 @@
|
|||
pub mod cache;
|
||||
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use scraper::{Html, Selector};
|
||||
|
@ -52,8 +54,8 @@ pub fn link_to_datestring(link: String) -> String {
|
|||
link.split("=").collect::<Vec<&str>>().pop().unwrap().to_string()
|
||||
}
|
||||
|
||||
pub fn ensure_exists(path: String) {
|
||||
let p = Path::new(&path);
|
||||
pub fn ensure_exists(path: &String) {
|
||||
let p = Path::new(path);
|
||||
if !p.exists() {
|
||||
fs::create_dir_all(p).expect(&format!("couldn't create folder {path}")[..])
|
||||
}
|
||||
|
@ -73,7 +75,7 @@ pub struct Page {
|
|||
pub image: String,
|
||||
}
|
||||
|
||||
pub async fn get_page(date: String) -> Page {
|
||||
pub async fn get_page(date: &String) -> Page {
|
||||
let page_html = &reqwest::get(format!(
|
||||
"https://girlgeniusonline.com/comic.php?date={date}"
|
||||
))
|
||||
|
@ -106,7 +108,7 @@ pub async fn get_page(date: String) -> Page {
|
|||
}
|
||||
|
||||
Page {
|
||||
date,
|
||||
date: date.clone(),
|
||||
next_page,
|
||||
prev_page,
|
||||
image,
|
||||
|
|
|
@ -16,10 +16,9 @@ async fn main() {
|
|||
ggg::create_config(&config_file);
|
||||
|
||||
let config = ggg::read_config(&config_file);
|
||||
ggg::ensure_exists(config.cache_folder);
|
||||
ggg::ensure_exists(&config.cache_folder);
|
||||
|
||||
let current_page = ggg::get_page(config.latest_date).await;
|
||||
println!("{current_page:?}");
|
||||
let current_page = ggg::get_page(&config.latest_date).await;
|
||||
|
||||
ggg::update_latest_date(&config_file, ggg::link_to_datestring(current_page.next_page.unwrap()));
|
||||
println!("{:?}", &config);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue