Made book list configurable, updated dependencies

This commit is contained in:
max.nuding 2023-09-28 10:52:30 +02:00
parent c43a1b5ed3
commit 97d97f9f22
Failed to extract signature
4 changed files with 493 additions and 566 deletions

1027
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -9,4 +9,5 @@ edition = "2021"
chrono = "0.4.23"
reqwest = { version = "0.11.13", features = ["blocking"]}
rss = "2.0.2"
scraper = "0.14.0"
scraper = "0.17.1"
config = { version = "0.13.1", features = ["json"], default-features = false}

4
config.json.example Normal file
View File

@ -0,0 +1,4 @@
{
"Klufti Affenhitze":
"https://webopac.winbiap.de/konstanz/detail.aspx?data=U29ydD1adWdhbmdzZGF0dW0gKEJpYmxpb3RoZWspJmFtcDtjbWQ9MSZhbXA7cFM9MTAmYW1wO0NhdGFsb2d1ZUlkPTEwNjYwNCZhbXA7cEk9MCZhbXA7c0M9Y18wPTAlJW1fMD0xJSVmXzA9MiUlb18wPTglJXZfMD1hZmZlbmhpdHplJSVnXzA9LTEmYW1wO3NDYXRJZD0xMDY2MDQmYW1wO3BhZ2VJZD0yJmFtcDtTcmM9Mg%3d%3d"
}

View File

@ -1,7 +1,9 @@
use config::Config;
use reqwest::header;
use rss::{Channel, ChannelBuilder, ItemBuilder};
use scraper::{Html, Selector};
use std::{error::Error, fs::File, io::BufReader};
use std::collections::HashMap;
use chrono::prelude::*;
@ -32,25 +34,16 @@ fn get_last_status(title: &str) -> Result<String, Box<dyn Error>> {
}
fn main() -> Result<(), Box<dyn Error>> {
let searches = [(
"Klufti Affenhitze",
"https://webopac.winbiap.de/konstanz/detail.aspx?data=U29ydD1adWdhbmdzZGF0dW0gKEJpYmxpb3RoZWspJmFtcDtjbWQ9MSZhbXA7cFM9MTAmYW1wO0NhdGFsb2d1ZUlkPTEwNjYwNCZhbXA7cEk9MCZhbXA7c0M9Y18wPTAlJW1fMD0xJSVmXzA9MiUlb18wPTglJXZfMD1hZmZlbmhpdHplJSVnXzA9LTEmYW1wO3NDYXRJZD0xMDY2MDQmYW1wO3BhZ2VJZD0yJmFtcDtTcmM9Mg%3d%3d"
)]
.iter()
.cloned()
.collect::<std::collections::HashMap<&str, &str>>();
let settings = Config::builder()
.add_source(config::File::with_name("config.json"))
.build()?;
let books = settings.try_deserialize::<HashMap<String, String>>()?;
let searches = books
.iter()
.collect::<HashMap<&String,&String>>();
for (title, url) in searches {
search(url, title)?
}
/*
let url = "https://webopac.winbiap.de/konstanz/detail.aspx?data=U29ydD1adWdhbmdzZGF0dW0gKEJpYmxpb3RoZWspJmFtcDtjbWQ9MSZhbXA7cFM9MTAmYW1wO0NhdGFsb2d1ZUlkPTEwNjYwNCZhbXA7cEk9MCZhbXA7c0M9Y18wPTAlJW1fMD0xJSVmXzA9MiUlb18wPTglJXZfMD1hZmZlbmhpdHplJSVnXzA9LTEmYW1wO3NDYXRJZD0xMDY2MDQmYW1wO3BhZ2VJZD0yJmFtcDtTcmM9Mg%3d%3d";
if status != "entliehen" {
Notification::new()
.summary("Klufti News")
.body(&format!("Neuer Status: {}", status))
.show()?;
}*/
Ok(())
}