Closes #41 Reviewed-on: #43 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
37 lines
1000 B
Rust
37 lines
1000 B
Rust
pub async fn update_queued_song(
|
|
app: &crate::config::App,
|
|
song_path: &String,
|
|
song_queue_id: &uuid::Uuid,
|
|
) -> Result<reqwest::Response, reqwest::Error> {
|
|
let client = reqwest::Client::builder().build()?;
|
|
|
|
println!("Song path: {song_path:?}");
|
|
|
|
// TODO: Make the filename random
|
|
let form = reqwest::multipart::Form::new().part(
|
|
"file",
|
|
reqwest::multipart::Part::bytes(std::fs::read(song_path).unwrap())
|
|
.file_name("track01.flac"),
|
|
);
|
|
|
|
let url = format!("{}/api/v2/song/queue/{song_queue_id}", app.uri);
|
|
println!("Url: {url:?}");
|
|
|
|
let (key, header) = crate::api::auth_header(app).await;
|
|
let request = client.patch(url).multipart(form).header(key, header);
|
|
|
|
let response = request.send().await?;
|
|
|
|
Ok(response)
|
|
}
|
|
|
|
pub mod response {
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
pub struct Response {
|
|
pub message: String,
|
|
pub data: Vec<uuid::Uuid>,
|
|
}
|
|
}
|