Files
songparser/src/update_queued_song.rs
phoenix f748d93b3f
All checks were successful
Rust Build / Check (push) Successful in 33s
Rust Build / Rustfmt (push) Successful in 29s
Rust Build / Test Suite (push) Successful in 38s
Rust Build / Clippy (push) Successful in 41s
Rust Build / build (push) Successful in 34s
tsk-41: Adding auth (#43)
Closes #41

Reviewed-on: #43
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-08-14 23:11:41 +00:00

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>,
}
}