Compare commits

...

2 Commits

Author SHA1 Message Date
eaa3c6f40e Get Metadata queue (#23)
All checks were successful
Release Tagging / release (push) Successful in 31s
Rust Build / Check (push) Successful in 32s
Rust Build / Test Suite (push) Successful in 35s
Rust Build / Rustfmt (push) Successful in 24s
Rust Build / Clippy (push) Successful in 33s
Rust Build / build (push) Successful in 38s
Rust Build / Check (pull_request) Successful in 32s
Rust Build / Test Suite (pull_request) Successful in 37s
Rust Build / Rustfmt (pull_request) Successful in 25s
Rust Build / Clippy (pull_request) Successful in 34s
Rust Build / build (pull_request) Successful in 39s
Reviewed-on: #23
Co-authored-by: kdeng00 <kundeng00@pm.me>
Co-committed-by: kdeng00 <kundeng00@pm.me>
2025-06-14 00:30:25 +00:00
79eea81e28 Updated icarus_envy (#22)
All checks were successful
Release Tagging / release (push) Successful in 31s
Rust Build / Check (push) Successful in 46s
Rust Build / Test Suite (push) Successful in 38s
Rust Build / Rustfmt (push) Successful in 28s
Rust Build / Clippy (push) Successful in 35s
Rust Build / build (push) Successful in 40s
Rust Build / Check (pull_request) Successful in 35s
Rust Build / Test Suite (pull_request) Successful in 37s
Rust Build / Rustfmt (pull_request) Successful in 25s
Rust Build / Clippy (pull_request) Successful in 33s
Rust Build / build (pull_request) Successful in 39s
Reviewed-on: #22
Co-authored-by: kdeng00 <kundeng00@pm.me>
Co-committed-by: kdeng00 <kundeng00@pm.me>
2025-06-12 23:59:24 +00:00
3 changed files with 118 additions and 20 deletions

33
Cargo.lock generated
View File

@@ -83,6 +83,26 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "const_format"
version = "0.2.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd"
dependencies = [
"const_format_proc_macros",
]
[[package]]
name = "const_format_proc_macros"
version = "0.2.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.4" version = "0.9.4"
@@ -450,9 +470,10 @@ dependencies = [
[[package]] [[package]]
name = "icarus_envy" name = "icarus_envy"
version = "0.2.0" version = "0.2.2"
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.2.0#3ee8c1e573ba9637769aa0538d2c11335e39ed9f" source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.2.2-devel-84ea6e4c22-006#84ea6e4c223f19ff96f6b7cae944e831ef4aa831"
dependencies = [ dependencies = [
"const_format",
"dotenvy", "dotenvy",
] ]
@@ -1148,13 +1169,13 @@ dependencies = [
name = "songparser" name = "songparser"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"dotenvy",
"futures", "futures",
"icarus_envy", "icarus_envy",
"icarus_models", "icarus_models",
"reqwest", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
"time",
"tokio", "tokio",
"uuid", "uuid",
] ]
@@ -1415,6 +1436,12 @@ version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "unicode-xid"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
[[package]] [[package]]
name = "untrusted" name = "untrusted"
version = "0.9.0" version = "0.9.0"

View File

@@ -10,7 +10,7 @@ futures = { version = "0.3.31" }
reqwest = { version = "0.12.19", features = ["json", "stream"] } reqwest = { version = "0.12.19", features = ["json", "stream"] }
serde = { version = "1.0.218", features = ["derive"] } serde = { version = "1.0.218", features = ["derive"] }
serde_json = { version = "1.0.139" } serde_json = { version = "1.0.139" }
time = { version = "0.3.41", features = ["macros", "serde"] }
uuid = { version = "1.16.0", features = ["v4", "serde"] } uuid = { version = "1.16.0", features = ["v4", "serde"] }
dotenvy = { version = "0.15.7" }
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.4.3" } icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.4.3" }
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.2.0" } icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.2.2-devel-84ea6e4c22-006" }

View File

@@ -4,7 +4,7 @@ pub const SECONDS_TO_SLEEP: u64 = 5;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
let app_base_url = get_icarus_url().await; let app_base_url = icarus_envy::environment::get_icarus_base_api_url().await;
loop { loop {
println!("Base URL: {}", app_base_url); println!("Base URL: {}", app_base_url);
@@ -18,11 +18,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(song_queue_item) => { Ok(song_queue_item) => {
if !song_queue_item.data.is_empty() { if !song_queue_item.data.is_empty() {
println!("Song queue item: {:?}", song_queue_item); println!("Song queue item: {:?}", song_queue_item);
let song_queue_id = song_queue_item.data[0].id;
println!("Fetching song queue data"); println!("Fetching song queue data");
match api::fetch_song_queue_data::get_data( match api::fetch_song_queue_data::get_data(
&app_base_url, &app_base_url,
&song_queue_item.data[0].id, &song_queue_id,
) )
.await .await
{ {
@@ -41,16 +42,40 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Saved at: {:?}", save_path); println!("Saved at: {:?}", save_path);
// TODO: Get queued song's metadata match api::get_metadata_queue::get(
&app_base_url,
&song_queue_id,
)
.await
{
Ok(response) => {
match response.json::<api::get_metadata_queue::response::Response>().await {
Ok(response) => {
let id = &response.data[0].id;
let metadata = &response.data[0].metadata;
let created_at = &response.data[0].created_at;
println!("Id: {:?}", id);
println!("Metadata: {:?}", metadata);
println!("Created at: {:?}", created_at);
// TODO: Get queued coverart // TODO: Get queued coverart
// TODO: Get queued coverart's data // TODO: Get queued coverart's data
// TODO: Apply metadata to the queued song // TODO: Apply metadata to the queued song (modifying file)
// TODO: Update the queued song with the updated queued song // TODO: Update the queued song with the updated queued song
// TODO: Create song // TODO: Create song
// TODO: Create coverart // TODO: Create coverart
// TODO: Wipe data from queued song // TODO: Wipe data from queued song
// TODO: Wipe data from queued coverart // TODO: Wipe data from queued coverart
} }
Err(err) => {
eprintln!("Error: {:?}", err);
}
}
}
Err(err) => {
eprintln!("Error: {:?}", err);
}
}
}
Err(err) => { Err(err) => {
eprintln!("Error fetching song queue data: {:?}", err); eprintln!("Error fetching song queue data: {:?}", err);
} }
@@ -159,9 +184,55 @@ mod api {
} }
} }
} }
pub mod get_metadata_queue {
pub async fn get(
base_url: &String,
song_queue_id: &uuid::Uuid,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/song/metadata/queue");
let api_url = format!("{}/{}", base_url, endpoint);
client
.get(api_url)
.query(&[("song_queue_id", song_queue_id)])
.send()
.await
} }
async fn get_icarus_url() -> String { pub mod response {
dotenvy::dotenv().ok(); use serde::{Deserialize, Serialize};
std::env::var("ICARUS_BASE_API_URL").expect("Could not find url")
#[derive(Debug, Deserialize, Serialize)]
pub struct Metadata {
pub id: uuid::Uuid,
pub album: String,
pub album_artist: String,
pub artist: String,
pub disc: i32,
pub disc_count: i32,
pub duration: i64,
pub genre: String,
pub title: String,
pub track: i32,
pub track_count: i32,
pub year: i32,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct QueueItem {
pub id: uuid::Uuid,
pub metadata: Metadata,
#[serde(with = "time::serde::rfc3339")]
pub created_at: time::OffsetDateTime,
pub song_queue_id: uuid::Uuid,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct Response {
pub message: String,
pub data: Vec<QueueItem>,
}
}
}
} }