Added code to queue metadata

This commit is contained in:
kdeng00
2025-08-28 15:54:03 -04:00
parent a36914cc0d
commit 3d3f7ffd90
2 changed files with 66 additions and 2 deletions
+52 -2
View File
@@ -19,6 +19,14 @@ mod response {
pub data: Vec<uuid::Uuid>,
}
}
pub mod queue_metadata {
#[derive(Debug, serde::Deserialize)]
pub struct Response {
pub message: String,
pub data: Vec<uuid::Uuid>
}
}
}
impl Upload {
@@ -125,13 +133,13 @@ impl Upload {
let (auth, auth_val) = syncers::common::auth_header(token).await;
headers.insert(auth, auth_val);
let client = reqwest::Client::builder().build().unwrap();
let payload = serde_json::json!({
"song_queue_id": queued_song_id,
"user_id": token.user_id
});
let client = reqwest::Client::builder().build().unwrap();
match client
.patch(url)
.headers(headers)
@@ -144,6 +152,48 @@ impl Upload {
}
}
pub async fn queue_metadata(&self, token: &icarus_models::token::AccessToken, album: &icarus_models::album::collection::Album, song: &icarus_models::song::Song, queued_song_id: &uuid::Uuid) -> Result<uuid::Uuid, reqwest::Error> {
let endpoint = String::from("api/v2/song/metadata/queue");
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,
"title": song.title,
"artist": song.artist,
"album_artist": album.artist,
"album": album.title,
"genre": song.genre,
"track": song.track,
"track_count": album.track_count,
"disc": song.disc,
"disc_count": album.disc_count,
"year": album.year,
"duration": song.duration,
});
let client = reqwest::Client::builder().build().unwrap();
match client.post(url).headers(headers).json(&payload).send().await {
Ok(response) => match response.json::<response::queue_metadata::Response>().await {
Ok(resp) => {
println!("Message: {:?}", resp.message);
Ok(resp.data[0])
}
Err(err) => {
Err(err)
}
}
Err(err) => {
Err(err)
}
}
}
fn init_form(
&self,
song: &icarus_models::song::Song,