Queue metadata #60
@@ -442,10 +442,9 @@ impl CommitManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let queued_metadata_id = match up.queue_metadata(token, album, song, &queued_song_id).await {
|
let queued_metadata_id = match up.queue_metadata(token, album, song, &queued_song_id).await
|
||||||
Ok(id) => {
|
{
|
||||||
id
|
Ok(id) => id,
|
||||||
}
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Err(std::io::Error::other(err.to_string()));
|
return Err(std::io::Error::other(err.to_string()));
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-11
@@ -24,7 +24,7 @@ mod response {
|
|||||||
#[derive(Debug, serde::Deserialize)]
|
#[derive(Debug, serde::Deserialize)]
|
||||||
pub struct Response {
|
pub struct Response {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub data: Vec<uuid::Uuid>
|
pub data: Vec<uuid::Uuid>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,13 @@ 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> {
|
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 endpoint = String::from("api/v2/song/metadata/queue");
|
||||||
let url = format!("{}/{endpoint}", self.api.url);
|
let url = format!("{}/{endpoint}", self.api.url);
|
||||||
|
|
||||||
@@ -174,23 +180,25 @@ impl Upload {
|
|||||||
"year": album.year,
|
"year": album.year,
|
||||||
"duration": song.duration,
|
"duration": song.duration,
|
||||||
});
|
});
|
||||||
|
|
||||||
let client = reqwest::Client::builder().build().unwrap();
|
let client = reqwest::Client::builder().build().unwrap();
|
||||||
|
|
||||||
match client.post(url).headers(headers).json(&payload).send().await {
|
match client
|
||||||
|
.post(url)
|
||||||
|
.headers(headers)
|
||||||
|
.json(&payload)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
{
|
||||||
Ok(response) => match response.json::<response::queue_metadata::Response>().await {
|
Ok(response) => match response.json::<response::queue_metadata::Response>().await {
|
||||||
Ok(resp) => {
|
Ok(resp) => {
|
||||||
println!("Message: {:?}", resp.message);
|
println!("Message: {:?}", resp.message);
|
||||||
|
|
||||||
Ok(resp.data[0])
|
Ok(resp.data[0])
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => Err(err),
|
||||||
Err(err)
|
},
|
||||||
}
|
Err(err) => Err(err),
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
Err(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user