tsk-62: Use QueuedSong and QueuedCoverArt to replace references to path of Song and CoverArt #64

Merged
phoenix merged 7 commits from tsk-62 into main 2025-10-22 17:42:01 +00:00
3 changed files with 27 additions and 32 deletions
Showing only changes of commit 05e772068c - Show all commits

View File

@@ -307,7 +307,7 @@ pub mod wipe_data {
pub mod song_queue {
pub async fn wipe_data(
app: &crate::config::App,
queued_song: &crate::queued_item::QueuedSong
queued_song: &crate::queued_item::QueuedSong,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::builder().build()?;
let url = format!("{}/api/v2/song/queue/data/wipe", app.uri);
@@ -331,7 +331,7 @@ pub mod wipe_data {
pub mod coverart_queue {
pub async fn wipe_data(
app: &crate::config::App,
queued_coverart: &crate::queued_item::QueuedCoverArt
queued_coverart: &crate::queued_item::QueuedCoverArt,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::builder().build()?;
let url = format!("{}/api/v2/coverart/queue/data/wipe", app.uri);

View File

@@ -65,12 +65,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
coverart,
_metadata,
queued_song,
queued_coverart
// (song_queue_id, _song_queue_path),
queued_coverart, // (song_queue_id, _song_queue_path),
// (coverart_queue_id, _coverart_queue_path),
)) => {
match wipe_data_from_queues(&app, &queued_song, &queued_coverart)
.await
match wipe_data_from_queues(&app, &queued_song, &queued_coverart).await
{
Ok(_) => match cleanup(&song, &coverart).await {
Ok(_) => {
@@ -106,7 +104,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
async fn wipe_data_from_queues(
app: &config::App,
queued_song: &crate::queued_item::QueuedSong,
queued_coverart: &crate::queued_item::QueuedCoverArt
queued_coverart: &crate::queued_item::QueuedCoverArt,
) -> Result<(), std::io::Error> {
match api::wipe_data::song_queue::wipe_data(app, queued_song).await {
Ok(response) => match response
@@ -185,7 +183,7 @@ async fn some_work(
icarus_models::coverart::CoverArt,
api::get_metadata_queue::response::Metadata,
queued_item::QueuedSong,
queued_item::QueuedCoverArt
queued_item::QueuedCoverArt,
),
std::io::Error,
> {
@@ -220,15 +218,9 @@ async fn some_work(
};
*/
match metadata::apply_metadata(&queued_song, &queued_coverart, &metadata).await
{
match metadata::apply_metadata(&queued_song, &queued_coverart, &metadata).await {
Ok(_applied) => {
match api::update_queued_song::update_queued_song(
app,
&queued_song,
)
.await
{
match api::update_queued_song::update_queued_song(app, &queued_song).await {
Ok(response) => {
match response
.json::<api::update_queued_song::response::Response>()
@@ -332,18 +324,18 @@ async fn prep_song(
};
*/
let queued_song: crate::queued_item::QueuedSong = match song.save_to_filesystem() {
Ok(_) => {
queued_item::QueuedSong {
let queued_song: crate::queued_item::QueuedSong =
match song.save_to_filesystem() {
Ok(_) => queued_item::QueuedSong {
id: *song_queue_id,
song,
path: songpath
}
}
path: songpath,
},
Err(err) => {
eprintln!("Error: {err:?}");
queued_item::QueuedSong{..Default::default()}
queued_item::QueuedSong {
..Default::default()
}
}
};

View File

@@ -122,7 +122,10 @@ pub async fn apply_metadata(
}
}
match icarus_meta::meta::coverart::set_coverart(&queued_song.path, &queued_coverart.path) {
match icarus_meta::meta::coverart::set_coverart(
&queued_song.path,
&queued_coverart.path,
) {
Ok(_data) => {
if _data.is_empty() {
println!("There was an issue");