Added code to link queued coverart to queued song
This commit is contained in:
@@ -454,8 +454,14 @@ impl CommitManager {
|
||||
println!("Queued metadata Id: {queued_metadata_id:?}");
|
||||
|
||||
match up.queue_coverart(token, coverart).await {
|
||||
Ok(id) => {
|
||||
println!("Queued coverart Id: {id:?}");
|
||||
Ok(id) => match up.link_queued_song_to_queued_coverart(token, &queued_song_id, &id).await {
|
||||
Ok(_) => {
|
||||
println!("Queued coverart Id: {id:?}");
|
||||
println!("Linked queued song to queued coverart");
|
||||
}
|
||||
Err(err) => {
|
||||
return Err(std::io::Error::other(err.to_string()));
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
return Err(std::io::Error::other(err.to_string()));
|
||||
|
||||
@@ -268,6 +268,33 @@ impl Upload {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn link_queued_song_to_queued_coverart(&self, token: &icarus_models::token::AccessToken, queued_song_id: &uuid::Uuid, queued_coverart_id: &uuid::Uuid) -> Result<(), reqwest::Error> {
|
||||
let endpoint = String::from("api/v2/coverart/queue/link");
|
||||
let url = format!("{}/{endpoint}", self.api.url);
|
||||
|
||||
let mut headers = reqwest::header::HeaderMap::new();
|
||||
let (auth, auth_val) = syncers::common::auth_header(token).await;
|
||||
headers.insert(auth, auth_val);
|
||||
|
||||
let payload = serde_json::json!({
|
||||
"song_queue_id": queued_song_id,
|
||||
"coverart_id": queued_coverart_id
|
||||
});
|
||||
|
||||
let client = reqwest::Client::builder().build().unwrap();
|
||||
|
||||
match client
|
||||
.patch(url)
|
||||
.headers(headers)
|
||||
.json(&payload)
|
||||
.send()
|
||||
.await
|
||||
{
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
fn init_form(
|
||||
&self,
|
||||
song: &icarus_models::song::Song,
|
||||
|
||||
Reference in New Issue
Block a user