From 8c44ddbd039953a9aefa9ab93278ace488aaf69b Mon Sep 17 00:00:00 2001 From: phoenix Date: Thu, 26 Jun 2025 18:53:16 -0400 Subject: [PATCH] Starting work to update queued song --- src/main.rs | 17 ++++++++--------- src/the_rest.rs | 4 ++++ src/util.rs | 10 ++++++++++ 3 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 src/the_rest.rs create mode 100644 src/util.rs diff --git a/src/main.rs b/src/main.rs index b29bc69..dff9769 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,6 @@ +pub mod the_rest; +pub mod util; + use std::io::Write; pub const SECONDS_TO_SLEEP: u64 = 5; @@ -97,8 +100,10 @@ async fn process_song(api_url: &String, song_queue_id: &uuid::Uuid) -> Result<() println!("Saved coverart queue file at: {:?}", coverart_queue_path); - match apply_metadata(song_queue_path, coverart_queue_path, metadata).await { + match apply_metadata(song_queue_path.clone(), coverart_queue_path, metadata).await { Ok(_) => { + let s_path = util::path_buf_to_string(&song_queue_path); + the_rest::update_queued_song(&s_path).await; // TODO: Update the queued song with the updated queued song // TODO: Create song // TODO: Create coverart @@ -211,10 +216,7 @@ pub async fn apply_metadata( metadata: &api::get_metadata_queue::response::Metadata, ) -> Result { // Apply metadata fields - let s_path = match song_queue_path.to_str() { - Some(val) => String::from(val), - None => String::new(), - }; + let s_path = util::path_buf_to_string(&song_queue_path); if s_path.is_empty() { println!("Song queue path is empty"); @@ -326,10 +328,7 @@ pub async fn apply_metadata( } // Apply coverart - let c_path: String = match coverart_queue_path.to_str() { - Some(val) => String::from(val), - None => String::new(), - }; + let c_path: String = util::path_buf_to_string(&coverart_queue_path); match icarus_meta::meta::coverart::contains_coverart(&s_path) { Ok((exists, size)) => { diff --git a/src/the_rest.rs b/src/the_rest.rs new file mode 100644 index 0000000..374fc31 --- /dev/null +++ b/src/the_rest.rs @@ -0,0 +1,4 @@ +// TODO: Refactor this file when this app is functional + +pub async fn update_queued_song(song_path: &String) { +} diff --git a/src/util.rs b/src/util.rs new file mode 100644 index 0000000..c55ded3 --- /dev/null +++ b/src/util.rs @@ -0,0 +1,10 @@ + +pub fn path_buf_to_string(path: &std::path::PathBuf) -> String { + let s_path = match path.to_str() { + Some(val) => String::from(val), + None => String::new(), + }; + + s_path +} +