diff --git a/Cargo.lock b/Cargo.lock index 3b7d565..1b4c019 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -631,6 +631,15 @@ dependencies = [ "libc", ] +[[package]] +name = "num_threads" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +dependencies = [ + "libc", +] + [[package]] name = "once_cell" version = "1.16.0" @@ -946,8 +955,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" dependencies = [ + "itoa", + "libc", + "num_threads", "serde", "time-core", + "time-macros", ] [[package]] @@ -956,6 +969,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +[[package]] +name = "time-macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +dependencies = [ + "time-core", +] + [[package]] name = "tinyvec" version = "1.6.0" diff --git a/Cargo.toml b/Cargo.toml index 1b7914f..1220402 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,6 @@ edition = "2021" [dependencies] reqwest = { version = "0.11.13", features = ["blocking"] } rss = "2" -time = "0.3" +time = { version = "0.3", features = ["local-offset", "formatting", "macros"]} clokwerk = "0.4" pico-args = "0.5" diff --git a/lfs_scraper.service b/lfs_scraper.service new file mode 100644 index 0000000..9b8bbd6 --- /dev/null +++ b/lfs_scraper.service @@ -0,0 +1,14 @@ +[Unit] +Description=LFS Scraper +After=network.target +StartLimitIntervalSec=0 + +[Service] +Type=simple +Restart=always +RestartSec=1 +User=git +ExecStart=/usr/local/bin/lfs_scraper --url https://www.lfs.sachsen.de/restplatzboerse-5152.html --rss-file /var/www/tfld/ffw.rss + +[Install] +WantedBy=multi-user.target diff --git a/src/main.rs b/src/main.rs index 0b3b413..3928a1c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,7 +43,7 @@ fn main() { let mut scheduler = Scheduler::new(); scheduler - .every(1.minutes()) + .every(30.minutes()) .run(move || match get_current_places(&args.url) { Ok(places) => { if should_feed_be_updated(&places, &last_places) { @@ -105,12 +105,12 @@ fn update_rss_file(places: Vec, url: &str, rss_file: &str) { .language(Some("de-DE".to_string())) .build(); - let title = format!("Restplatzbörse Update - {}", OffsetDateTime::now_utc()); + let title = format!("Restplatzbörse Update - {}", OffsetDateTime::now_local().unwrap().format(time::macros::format_description!("[year]-[month]-[day] [hour]:[minute]")).unwrap()); let content = places .iter() .map(|place| { format!( - "{} - {} - {} - {}", + "{} - {} - {} - {} Plätze
", place.id, place.description, place.date, place.free ) })