Queue metadata #60
@@ -41,6 +41,7 @@ struct UploadSongMembers {
|
||||
pub song: icarus_models::song::Song,
|
||||
pub coverart: icarus_models::coverart::CoverArt,
|
||||
pub token: icarus_models::token::AccessToken,
|
||||
pub album: icarus_models::album::collection::Album,
|
||||
}
|
||||
|
||||
pub fn retrieve_song(
|
||||
@@ -389,6 +390,7 @@ impl CommitManager {
|
||||
song: s,
|
||||
coverart: cover_art,
|
||||
token: token,
|
||||
album: album,
|
||||
};
|
||||
|
||||
match self.upload_song_process(&members).await {
|
||||
@@ -418,6 +420,7 @@ impl CommitManager {
|
||||
|
||||
let token = &data.token;
|
||||
let song = &data.song;
|
||||
let album = &data.album;
|
||||
|
||||
println!("Queueing song");
|
||||
|
||||
@@ -439,6 +442,17 @@ impl CommitManager {
|
||||
}
|
||||
}
|
||||
|
||||
let queued_metadata_id = match up.queue_metadata(token, album, song, &queued_song_id).await {
|
||||
Ok(id) => {
|
||||
id
|
||||
}
|
||||
Err(err) => {
|
||||
return Err(std::io::Error::other(err.to_string()));
|
||||
}
|
||||
};
|
||||
|
||||
println!("Queued metadata Id: {queued_metadata_id:?}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
+52
-2
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user