dotenv is fucking scary dude
This commit is contained in:
6
homegrown/email-rust/.dockerignore
Normal file
6
homegrown/email-rust/.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
||||
debug
|
||||
target
|
||||
**/*.rs.bk
|
||||
*.pdb
|
||||
**/mutants.out*/
|
||||
|
1945
homegrown/email-rust/Cargo.lock
generated
Normal file
1945
homegrown/email-rust/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
homegrown/email-rust/Cargo.toml
Normal file
16
homegrown/email-rust/Cargo.toml
Normal file
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "email"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
reqwest = { version = "0.12", features = ["json"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
lettre = "0.11"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
dotenv = "0.15.0"
|
||||
chrono = "0.4.41"
|
||||
|
4
homegrown/email-rust/Dockerfile
Normal file
4
homegrown/email-rust/Dockerfile
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM rust:1.88.0
|
||||
COPY ./ ./
|
||||
RUN cargo build --release
|
||||
CMD ["./target/release/email"]
|
7
homegrown/email-rust/readme.md
Normal file
7
homegrown/email-rust/readme.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# email
|
||||
sends me an email every monday with all the new videos from channels i like on youtbue
|
||||
|
||||
# status
|
||||
can read the json, now to actually implement the youtube api calls.
|
||||
Prolly just gonna call the api directly with reqwest.
|
||||
add <option> datafields in the struct. cleanup the "listje"
|
41
homegrown/email-rust/src/main.rs
Normal file
41
homegrown/email-rust/src/main.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
use serde::Deserialize;
|
||||
use std::env;
|
||||
use chrono::prelude::*;
|
||||
use dotenv::dotenv;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Channel {
|
||||
id: String,
|
||||
name: String,
|
||||
kind: String,
|
||||
}
|
||||
|
||||
struct Videos {
|
||||
id: String,
|
||||
name: String,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
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()
|
||||
.text().await.unwrap();
|
||||
let channels = serde_json::from_str::<Vec<Channel>>(&resp).unwrap();
|
||||
let apikey = env::var("APIKEY").unwrap();
|
||||
// let lastMonday =
|
||||
let datetime: DateTime<Utc> = 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={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");
|
||||
let resp = reqwest::get(videos_request).await.unwrap().text().await.unwrap();
|
||||
println!("{}", resp);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user