tsk-62: Use QueuedSong and QueuedCoverArt to replace references to path of Song and CoverArt #64
@@ -307,7 +307,7 @@ pub mod wipe_data {
|
|||||||
pub mod song_queue {
|
pub mod song_queue {
|
||||||
pub async fn wipe_data(
|
pub async fn wipe_data(
|
||||||
app: &crate::config::App,
|
app: &crate::config::App,
|
||||||
queued_song: &crate::queued_item::QueuedSong
|
queued_song: &crate::queued_item::QueuedSong,
|
||||||
) -> Result<reqwest::Response, reqwest::Error> {
|
) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
let client = reqwest::Client::builder().build()?;
|
let client = reqwest::Client::builder().build()?;
|
||||||
let url = format!("{}/api/v2/song/queue/data/wipe", app.uri);
|
let url = format!("{}/api/v2/song/queue/data/wipe", app.uri);
|
||||||
@@ -331,7 +331,7 @@ pub mod wipe_data {
|
|||||||
pub mod coverart_queue {
|
pub mod coverart_queue {
|
||||||
pub async fn wipe_data(
|
pub async fn wipe_data(
|
||||||
app: &crate::config::App,
|
app: &crate::config::App,
|
||||||
queued_coverart: &crate::queued_item::QueuedCoverArt
|
queued_coverart: &crate::queued_item::QueuedCoverArt,
|
||||||
) -> Result<reqwest::Response, reqwest::Error> {
|
) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
let client = reqwest::Client::builder().build()?;
|
let client = reqwest::Client::builder().build()?;
|
||||||
let url = format!("{}/api/v2/coverart/queue/data/wipe", app.uri);
|
let url = format!("{}/api/v2/coverart/queue/data/wipe", app.uri);
|
||||||
|
36
src/main.rs
36
src/main.rs
@@ -65,12 +65,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
coverart,
|
coverart,
|
||||||
_metadata,
|
_metadata,
|
||||||
queued_song,
|
queued_song,
|
||||||
queued_coverart
|
queued_coverart, // (song_queue_id, _song_queue_path),
|
||||||
// (song_queue_id, _song_queue_path),
|
|
||||||
// (coverart_queue_id, _coverart_queue_path),
|
// (coverart_queue_id, _coverart_queue_path),
|
||||||
)) => {
|
)) => {
|
||||||
match wipe_data_from_queues(&app, &queued_song, &queued_coverart)
|
match wipe_data_from_queues(&app, &queued_song, &queued_coverart).await
|
||||||
.await
|
|
||||||
{
|
{
|
||||||
Ok(_) => match cleanup(&song, &coverart).await {
|
Ok(_) => match cleanup(&song, &coverart).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@@ -106,7 +104,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
async fn wipe_data_from_queues(
|
async fn wipe_data_from_queues(
|
||||||
app: &config::App,
|
app: &config::App,
|
||||||
queued_song: &crate::queued_item::QueuedSong,
|
queued_song: &crate::queued_item::QueuedSong,
|
||||||
queued_coverart: &crate::queued_item::QueuedCoverArt
|
queued_coverart: &crate::queued_item::QueuedCoverArt,
|
||||||
) -> Result<(), std::io::Error> {
|
) -> Result<(), std::io::Error> {
|
||||||
match api::wipe_data::song_queue::wipe_data(app, queued_song).await {
|
match api::wipe_data::song_queue::wipe_data(app, queued_song).await {
|
||||||
Ok(response) => match response
|
Ok(response) => match response
|
||||||
@@ -185,7 +183,7 @@ async fn some_work(
|
|||||||
icarus_models::coverart::CoverArt,
|
icarus_models::coverart::CoverArt,
|
||||||
api::get_metadata_queue::response::Metadata,
|
api::get_metadata_queue::response::Metadata,
|
||||||
queued_item::QueuedSong,
|
queued_item::QueuedSong,
|
||||||
queued_item::QueuedCoverArt
|
queued_item::QueuedCoverArt,
|
||||||
),
|
),
|
||||||
std::io::Error,
|
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) => {
|
Ok(_applied) => {
|
||||||
match api::update_queued_song::update_queued_song(
|
match api::update_queued_song::update_queued_song(app, &queued_song).await {
|
||||||
app,
|
|
||||||
&queued_song,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
match response
|
match response
|
||||||
.json::<api::update_queued_song::response::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() {
|
let queued_song: crate::queued_item::QueuedSong =
|
||||||
Ok(_) => {
|
match song.save_to_filesystem() {
|
||||||
queued_item::QueuedSong {
|
Ok(_) => queued_item::QueuedSong {
|
||||||
id: *song_queue_id,
|
id: *song_queue_id,
|
||||||
song,
|
song,
|
||||||
path: songpath
|
path: songpath,
|
||||||
}
|
},
|
||||||
|
|
||||||
}
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Error: {err:?}");
|
eprintln!("Error: {err:?}");
|
||||||
queued_item::QueuedSong{..Default::default()}
|
queued_item::QueuedSong {
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -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) => {
|
Ok(_data) => {
|
||||||
if _data.is_empty() {
|
if _data.is_empty() {
|
||||||
println!("There was an issue");
|
println!("There was an issue");
|
||||||
|
Reference in New Issue
Block a user