From 7b00e23a086b0d1c56581a5ee378bf7ff3789358 Mon Sep 17 00:00:00 2001 From: death916 Date: Thu, 19 Mar 2026 01:50:27 -0700 Subject: [PATCH] news wip --- rustclock/Cargo.lock | 131 ++++++++++++++++++++++++++++++++++++++- rustclock/Cargo.toml | 1 + rustclock/src/main.rs | 5 +- rustclock/src/news.rs | 50 +++++++++++++++ rustclock/src/weather.rs | 1 + 5 files changed, 184 insertions(+), 4 deletions(-) create mode 100644 rustclock/src/news.rs diff --git a/rustclock/Cargo.lock b/rustclock/Cargo.lock index d1af527..8d3fdfe 100644 --- a/rustclock/Cargo.lock +++ b/rustclock/Cargo.lock @@ -290,6 +290,19 @@ dependencies = [ "syn", ] +[[package]] +name = "atom_syndication" +version = "0.12.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f68d23e2cb4fd958c705b91a6b4c80ceeaf27a9e11651272a8389d5ce1a4a3" +dependencies = [ + "chrono", + "derive_builder", + "diligent-date-parser", + "never", + "quick-xml 0.37.5", +] + [[package]] name = "atomic-waker" version = "1.1.2" @@ -842,6 +855,81 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "derive_builder" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" +dependencies = [ + "derive_builder_core", + "syn", +] + +[[package]] +name = "diligent-date-parser" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ede7d79366f419921e2e2f67889c12125726692a313bffb474bd5f37a581e9" +dependencies = [ + "chrono", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -1934,6 +2022,12 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "1.1.0" @@ -2440,6 +2534,12 @@ dependencies = [ "jni-sys", ] +[[package]] +name = "never" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c96aba5aa877601bb3f6dd6a63a969e1f82e60646e81e71b14496995e9853c91" + [[package]] name = "new_debug_unreachable" version = "1.0.6" @@ -3179,6 +3279,16 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" +[[package]] +name = "quick-xml" +version = "0.37.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "331e97a1af0bf59823e6eadffe373d7b27f485be8748f71471c662c1f269b7fb" +dependencies = [ + "encoding_rs", + "memchr", +] + [[package]] name = "quick-xml" version = "0.39.2" @@ -3490,6 +3600,18 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" +[[package]] +name = "rss" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2107738f003660f0a91f56fd3e3bd3ab5d918b2ddaf1e1ec2136fb1c46f71bf" +dependencies = [ + "atom_syndication", + "derive_builder", + "never", + "quick-xml 0.37.5", +] + [[package]] name = "rustc-hash" version = "1.1.0" @@ -3509,6 +3631,7 @@ dependencies = [ "chrono", "iced", "reqwest", + "rss", "serde", "serde_json", "tokio", @@ -3958,6 +4081,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "subtle" version = "2.6.1" @@ -4749,7 +4878,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c86287151a309799b821ca709b7345a048a2956af05957c89cb824ab919fa4e3" dependencies = [ "proc-macro2", - "quick-xml", + "quick-xml 0.39.2", "quote", ] diff --git a/rustclock/Cargo.toml b/rustclock/Cargo.toml index a5a3258..58584d2 100644 --- a/rustclock/Cargo.toml +++ b/rustclock/Cargo.toml @@ -7,6 +7,7 @@ edition = "2024" chrono = "0.4.44" iced = { version = "0.14.0", features = ["image", "tokio"] } reqwest = "0.13.2" +rss = "2.0.12" serde = { version = "1.0.228", features = ["derive"] } serde_json = "1.0.149" tokio = "1.50.0" diff --git a/rustclock/src/main.rs b/rustclock/src/main.rs index 3dd34fa..7207252 100644 --- a/rustclock/src/main.rs +++ b/rustclock/src/main.rs @@ -1,4 +1,5 @@ // #![allow(dead_code)] +mod news; mod panes; mod sports; mod weather; @@ -6,9 +7,7 @@ use chrono::{DateTime, Local}; use iced::Element; use iced::Subscription; use iced::Task; -use iced::time; use iced::time::Duration; -use iced::widget::image; use iced::widget::image::Handle; use iced::widget::pane_grid; use iced::widget::pane_grid::Configuration; @@ -16,7 +15,7 @@ use sports::Game; use std::collections::HashMap; const CLOCK_UPDATE_TIME_MS: u64 = 1500; -const UPDATE_SPORTS_TIME_MINS: u64 = 3; +const UPDATE_SPORTS_TIME_MINS: u64 = 5; const WEATHER_UPDATE_TIME_MINS: u64 = 30; pub fn main() -> iced::Result { diff --git a/rustclock/src/news.rs b/rustclock/src/news.rs new file mode 100644 index 0000000..06118fd --- /dev/null +++ b/rustclock/src/news.rs @@ -0,0 +1,50 @@ +use rss::Channel; +use std::fs::File; +use std::io::{BufRead, BufReader}; +use std::str::FromStr; + +pub fn get_news() { + let feeds = File::open("../feeds.txt"); + let mut feed_vec = Vec::new(); + match feeds { + Ok(file) => { + let reader = BufReader::new(file); + let channel = Channel::read_from(reader); + if let Ok(channel) = channel { + println!("Title: {}", channel.title()); + println!("Link: {}", channel.link()); + println!("Description: {}", channel.description()); + } else { + eprintln!("Error parsing feed: {}", reader); + } + + for line in reader.lines() { + if let Ok(feed) = line { + dbg!(&feed); + feed_vec.push(feed); + } + } + } + Err(e) => { + eprintln!("Error opening file: {}", e); + } + } + + for feed in feed_vec.iter() { + let content = feed.as_str(); + dbg!(content); + let channel = Channel::from_str(content); + if let Ok(channel) = channel { + println!("Title: {}", channel.title()); + println!("Link: {}", channel.link()); + println!("Description: {}", channel.description()); + } else { + eprintln!("Error parsing feed: {}", content); + } + } +} + +#[test] +fn test() { + get_news(); +} diff --git a/rustclock/src/weather.rs b/rustclock/src/weather.rs index 5064d20..d2de663 100644 --- a/rustclock/src/weather.rs +++ b/rustclock/src/weather.rs @@ -11,5 +11,6 @@ pub fn get_weather() -> Option { .unwrap(); let handle = Some(Handle::from_bytes(image)); + dbg!("updating weather"); handle }