diff --git a/homegrown/email/Cargo.lock b/homegrown/email/Cargo.lock index 4b6a7c9..c63f028 100644 --- a/homegrown/email/Cargo.lock +++ b/homegrown/email/Cargo.lock @@ -141,8 +141,10 @@ checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" dependencies = [ "android-tzdata", "iana-time-zone", + "js-sys", "num-traits", "serde", + "wasm-bindgen", "windows-link", ] @@ -260,6 +262,7 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" name = "email" version = "0.1.0" dependencies = [ + "chrono", "dotenv", "google-youtube3", "lettre", diff --git a/homegrown/email/Cargo.toml b/homegrown/email/Cargo.toml index 61f686b..f10a787 100644 --- a/homegrown/email/Cargo.toml +++ b/homegrown/email/Cargo.toml @@ -14,4 +14,5 @@ serde_json = "1" google-youtube3 = "*" dotenv = "0.15.0" +chrono = "0.4.41" diff --git a/homegrown/email/src/main.rs b/homegrown/email/src/main.rs index 586a654..9564f01 100644 --- a/homegrown/email/src/main.rs +++ b/homegrown/email/src/main.rs @@ -1,6 +1,6 @@ use serde::Deserialize; use std::env; -use chrono; +use chrono::prelude::*; use dotenv::dotenv; #[derive(Deserialize)] @@ -17,7 +17,7 @@ struct Videos { #[tokio::main] async fn main() { - dotenv.ok(); + dotenv().ok(); let channellist = "https://raw.githubusercontent.com/bvanroll/home/refs/heads/master/static/yters.json"; let resp = reqwest::get(channellist)//.await.unwrap().text().await; .await.unwrap() @@ -25,12 +25,17 @@ async fn main() { let channels = serde_json::from_str::>(&resp).unwrap(); let apikey = env::var("APIKEY").unwrap(); // let lastMonday = + let datetime: DateTime = chrono::prelude::Utc::now() - chrono::TimeDelta::try_days(7).unwrap() ; + //let datestr = datetime. + let date= datetime.format("%Y-%m-%dT%H:%M:%SZ"); //(1970-01-01T00:00:00Z). + let part="snippet"; + let order = "date"; for i in channels { let id = i.id; - - let videos_request = format!("https://www.googleapis.com/youtube/v3/search/?channelId={id}&part=snippet,id&order=date&publishedAfter={date}&key={apikey}"); + let videos_request = format!("https://www.googleapis.com/youtube/v3/search/?channelId={id}&part={part},id&order={order}&publishedAfter={date}&key={apikey}"); //let videos_request = format!("https://www.googleapis.com/youtube/v3/channels?id={id}&key={apikey}&part=contentDetails"); - println!("{}", videos_request); + let resp = reqwest::get(videos_request).await.unwrap().text().await.unwrap(); + println!("{}", resp); } }