From 38950d2e873ca6a02507f1279ae6674ba4d7eef8 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Wed, 11 Jun 2025 20:02:34 -0400 Subject: [PATCH] Some cleanup --- src/main.rs | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index adbe5f5..3056e41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,12 @@ async fn main() -> Result<(), Box> { if !song_queue_item.data.is_empty() { println!("Song queue item: {:?}", song_queue_item); - match api::fetch_song_queue_data::get_data(&app_base_url, &song_queue_item.data[0].id).await { + match api::fetch_song_queue_data::get_data( + &app_base_url, + &song_queue_item.data[0].id, + ) + .await + { Ok(response) => { // TODO: At some point, handle the flow if the size is small or // large @@ -33,11 +38,16 @@ async fn main() -> Result<(), Box> { let mut song = icarus_models::song::Song::default(); song.data = all_bytes; - song.filename = song.generate_filename(icarus_models::types::MusicTypes::FlacExtension, true); + song.filename = song.generate_filename( + icarus_models::types::MusicTypes::FlacExtension, + true, + ); // TODO: Add function to save bytes to a file in icarus_models + // repo - song.directory = icarus_envy::environment::get_root_directory().await; + song.directory = + icarus_envy::environment::get_root_directory().await; let dir = std::path::Path::new(&song.directory); let save_path = dir.join(&song.filename); @@ -46,26 +56,22 @@ async fn main() -> Result<(), Box> { file.write_all(&song.data).unwrap(); println!("File saved to: {:?}", save_path); -// Process data here... - -// TODO: Parse the response body to a struct -// TODO: Get queued song data -// TODO: Get queued song's metadata -// TODO: Get queued coverart -// TODO: Get queued coverart's data -// TODO: Apply metadata to the queued song -// TODO: Update the queued song with the updated queued song -// TODO: Create song -// TODO: Create coverart -// TODO: Wipe data from queued song -// TODO: Wipe data from queued coverart + // Process data here... + // TODO: Get queued song's metadata + // TODO: Get queued coverart + // TODO: Get queued coverart's data + // TODO: Apply metadata to the queued song + // TODO: Update the queued song with the updated queued song + // TODO: Create song + // TODO: Create coverart + // TODO: Wipe data from queued song + // TODO: Wipe data from queued coverart } Err(err) => { eprintln!("Error fetching song queue data: {:?}", err); } } - } else { println!("No data to fetch"); } @@ -113,7 +119,10 @@ mod api { } pub mod fetch_song_queue_data { - pub async fn get_data(base_url: &String, id: &uuid::Uuid) -> Result { + pub async fn get_data( + base_url: &String, + id: &uuid::Uuid, + ) -> Result { let client = reqwest::Client::new(); let endpoint = String::from("api/v2/song/queue"); let api_url = format!("{}/{}/{}", base_url, endpoint, id);