tsk-54: Make Song file random when updating queued song (#65)
All checks were successful
Rust Build / Check (push) Successful in 35s
Rust Build / Test Suite (push) Successful in 39s
Rust Build / Rustfmt (push) Successful in 32s
Rust Build / Clippy (push) Successful in 43s
Rust Build / build (push) Successful in 49s

Closes #54

Reviewed-on: #65
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
This commit was merged in pull request #65.
This commit is contained in:
2025-10-22 18:09:48 +00:00
committed by phoenix
parent bd351b1157
commit 113416432b
7 changed files with 340 additions and 332 deletions

60
src/queue/mod.rs Normal file
View File

@@ -0,0 +1,60 @@
pub async fn wipe_data_from_queues(
app: &crate::config::App,
queued_song: &crate::queued_item::QueuedSong,
queued_coverart: &crate::queued_item::QueuedCoverArt,
) -> Result<(), std::io::Error> {
match crate::api::wipe_data::song_queue::wipe_data(app, queued_song).await {
Ok(response) => match response
.json::<crate::api::wipe_data::song_queue::response::Response>()
.await
{
Ok(_resp) => {
match crate::api::wipe_data::coverart_queue::wipe_data(app, queued_coverart).await {
Ok(inner_response) => match inner_response
.json::<crate::api::wipe_data::coverart_queue::response::Response>()
.await
{
Ok(_inner_resp) => {
println!("Wiped data from CoverArt queue");
println!("Resp: {_inner_resp:?}");
Ok(())
}
Err(err) => Err(std::io::Error::other(err.to_string())),
},
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
Err(err) => Err(std::io::Error::other(err.to_string())),
},
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
pub async fn is_queue_empty(
app: &crate::config::App,
) -> Result<
(
bool,
crate::api::fetch_next_queue_item::response::SongQueueItem,
),
reqwest::Error,
> {
match crate::api::fetch_next_queue_item::fetch_next_queue_item(app).await {
Ok(response) => {
match response
.json::<crate::api::fetch_next_queue_item::response::SongQueueItem>()
.await
{
Ok(response) => {
if response.data.is_empty() {
Ok((true, response))
} else {
Ok((false, response))
}
}
Err(err) => Err(err),
}
}
Err(err) => Err(err),
}
}