Starting work to update queued song
This commit is contained in:
17
src/main.rs
17
src/main.rs
@@ -1,3 +1,6 @@
|
|||||||
|
pub mod the_rest;
|
||||||
|
pub mod util;
|
||||||
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
pub const SECONDS_TO_SLEEP: u64 = 5;
|
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);
|
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(_) => {
|
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: Update the queued song with the updated queued song
|
||||||
// TODO: Create song
|
// TODO: Create song
|
||||||
// TODO: Create coverart
|
// TODO: Create coverart
|
||||||
@@ -211,10 +216,7 @@ pub async fn apply_metadata(
|
|||||||
metadata: &api::get_metadata_queue::response::Metadata,
|
metadata: &api::get_metadata_queue::response::Metadata,
|
||||||
) -> Result<bool, std::io::Error> {
|
) -> Result<bool, std::io::Error> {
|
||||||
// Apply metadata fields
|
// Apply metadata fields
|
||||||
let s_path = match song_queue_path.to_str() {
|
let s_path = util::path_buf_to_string(&song_queue_path);
|
||||||
Some(val) => String::from(val),
|
|
||||||
None => String::new(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if s_path.is_empty() {
|
if s_path.is_empty() {
|
||||||
println!("Song queue path is empty");
|
println!("Song queue path is empty");
|
||||||
@@ -326,10 +328,7 @@ pub async fn apply_metadata(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply coverart
|
// Apply coverart
|
||||||
let c_path: String = match coverart_queue_path.to_str() {
|
let c_path: String = util::path_buf_to_string(&coverart_queue_path);
|
||||||
Some(val) => String::from(val),
|
|
||||||
None => String::new(),
|
|
||||||
};
|
|
||||||
|
|
||||||
match icarus_meta::meta::coverart::contains_coverart(&s_path) {
|
match icarus_meta::meta::coverart::contains_coverart(&s_path) {
|
||||||
Ok((exists, size)) => {
|
Ok((exists, size)) => {
|
||||||
|
4
src/the_rest.rs
Normal file
4
src/the_rest.rs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
// TODO: Refactor this file when this app is functional
|
||||||
|
|
||||||
|
pub async fn update_queued_song(song_path: &String) {
|
||||||
|
}
|
10
src/util.rs
Normal file
10
src/util.rs
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user