Made book list configurable, updated dependencies
This commit is contained in:
parent
c43a1b5ed3
commit
97d97f9f22
1027
Cargo.lock
generated
1027
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -9,4 +9,5 @@ edition = "2021"
|
|||||||
chrono = "0.4.23"
|
chrono = "0.4.23"
|
||||||
reqwest = { version = "0.11.13", features = ["blocking"]}
|
reqwest = { version = "0.11.13", features = ["blocking"]}
|
||||||
rss = "2.0.2"
|
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
4
config.json.example
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"Klufti Affenhitze":
|
||||||
|
"https://webopac.winbiap.de/konstanz/detail.aspx?data=U29ydD1adWdhbmdzZGF0dW0gKEJpYmxpb3RoZWspJmFtcDtjbWQ9MSZhbXA7cFM9MTAmYW1wO0NhdGFsb2d1ZUlkPTEwNjYwNCZhbXA7cEk9MCZhbXA7c0M9Y18wPTAlJW1fMD0xJSVmXzA9MiUlb18wPTglJXZfMD1hZmZlbmhpdHplJSVnXzA9LTEmYW1wO3NDYXRJZD0xMDY2MDQmYW1wO3BhZ2VJZD0yJmFtcDtTcmM9Mg%3d%3d"
|
||||||
|
}
|
25
src/main.rs
25
src/main.rs
@ -1,7 +1,9 @@
|
|||||||
|
use config::Config;
|
||||||
use reqwest::header;
|
use reqwest::header;
|
||||||
use rss::{Channel, ChannelBuilder, ItemBuilder};
|
use rss::{Channel, ChannelBuilder, ItemBuilder};
|
||||||
use scraper::{Html, Selector};
|
use scraper::{Html, Selector};
|
||||||
use std::{error::Error, fs::File, io::BufReader};
|
use std::{error::Error, fs::File, io::BufReader};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
|
|
||||||
@ -32,25 +34,16 @@ fn get_last_status(title: &str) -> Result<String, Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
let searches = [(
|
let settings = Config::builder()
|
||||||
"Klufti Affenhitze",
|
.add_source(config::File::with_name("config.json"))
|
||||||
"https://webopac.winbiap.de/konstanz/detail.aspx?data=U29ydD1adWdhbmdzZGF0dW0gKEJpYmxpb3RoZWspJmFtcDtjbWQ9MSZhbXA7cFM9MTAmYW1wO0NhdGFsb2d1ZUlkPTEwNjYwNCZhbXA7cEk9MCZhbXA7c0M9Y18wPTAlJW1fMD0xJSVmXzA9MiUlb18wPTglJXZfMD1hZmZlbmhpdHplJSVnXzA9LTEmYW1wO3NDYXRJZD0xMDY2MDQmYW1wO3BhZ2VJZD0yJmFtcDtTcmM9Mg%3d%3d"
|
.build()?;
|
||||||
)]
|
let books = settings.try_deserialize::<HashMap<String, String>>()?;
|
||||||
.iter()
|
let searches = books
|
||||||
.cloned()
|
.iter()
|
||||||
.collect::<std::collections::HashMap<&str, &str>>();
|
.collect::<HashMap<&String,&String>>();
|
||||||
for (title, url) in searches {
|
for (title, url) in searches {
|
||||||
search(url, title)?
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user