Code formatting
Some checks failed
Rust Build / Check (pull_request) Failing after 37s
Rust Build / Test Suite (pull_request) Failing after 43s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Clippy (pull_request) Failing after 36s
Rust Build / build (pull_request) Failing after 50s

This commit is contained in:
2025-06-27 21:03:56 -04:00
parent 0ae6214969
commit 47a3b60b8d
4 changed files with 35 additions and 27 deletions

View File

@@ -23,8 +23,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// TODO: Do something with the result later
// let _ = prep_song(&app_base_url, &song_queue_id).await;
match some_work(&app_base_url, &song_queue_id).await {
Ok(_) => {
}
Ok(_) => {}
Err(err) => {
eprintln!("Error: {:?}", err);
}
@@ -66,19 +65,27 @@ async fn is_queue_empty(
}
}
async fn some_work(app_base_url: &String, song_queue_id: &uuid::Uuid) -> Result<(), std::io::Error> {
async fn some_work(
app_base_url: &String,
song_queue_id: &uuid::Uuid,
) -> Result<(), std::io::Error> {
match prep_song(app_base_url, song_queue_id).await {
Ok((song_queue_path, coverart_queue_path, metadata)) => {
match apply_metadata(&song_queue_path, &coverart_queue_path, &metadata).await {
Ok(_applied) => {
// let s_path = util::path_buf_to_string(&song_queue_path);
match update_queued_song::update_queued_song(app_base_url, &song_queue_path, song_queue_id).await {
Ok(_response) => {
Ok(())
}
Err(err) => {
Err(std::io::Error::new(std::io::ErrorKind::Other, err.to_string()))
}
match update_queued_song::update_queued_song(
app_base_url,
&song_queue_path,
song_queue_id,
)
.await
{
Ok(_response) => Ok(()),
Err(err) => Err(std::io::Error::new(
std::io::ErrorKind::Other,
err.to_string(),
)),
}
// Ok((s_path))
}
@@ -88,13 +95,14 @@ async fn some_work(app_base_url: &String, song_queue_id: &uuid::Uuid) -> Result<
}
}
}
Err(_err) => {
Ok(())
}
Err(_err) => Ok(()),
}
}
async fn prep_song(api_url: &String, song_queue_id: &uuid::Uuid) -> Result<(String, String, api::get_metadata_queue::response::Metadata), reqwest::Error> {
async fn prep_song(
api_url: &String,
song_queue_id: &uuid::Uuid,
) -> Result<(String, String, api::get_metadata_queue::response::Metadata), reqwest::Error> {
match api::fetch_song_queue_data::get_data(api_url, song_queue_id).await {
Ok(response) => {
// Process data here...

View File

@@ -1,7 +1,5 @@
// TODO: Refactor this file when this app is functional
// TODO: Create song
// TODO: Create coverart
// TODO: Wipe data from queued song

View File

@@ -1,18 +1,23 @@
use reqwest::multipart;
// TODO: Update the queued song with the updated queued song
pub async fn update_queued_song(base_url: &String, song_path: &String, song_queue_id: &uuid::Uuid) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::builder()
.build()?;
pub async fn update_queued_song(
base_url: &String,
song_path: &String,
song_queue_id: &uuid::Uuid,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::builder().build()?;
let form = reqwest::multipart::Form::new()
.part("file",
reqwest::multipart::Part::bytes(std::fs::read(song_path).unwrap()).file_name("track01.flac"));
let form = reqwest::multipart::Form::new().part(
"file",
reqwest::multipart::Part::bytes(std::fs::read(song_path).unwrap())
.file_name("track01.flac"),
);
let method = "PATCH";
let url = format!("{}/api/v2/song/queue/{}", base_url, song_queue_id);
let request = client.request(reqwest::Method::from_bytes(method.as_bytes()).unwrap(), url)
let request = client
.request(reqwest::Method::from_bytes(method.as_bytes()).unwrap(), url)
.multipart(form);
let response = request.send().await?;
@@ -20,7 +25,6 @@ pub async fn update_queued_song(base_url: &String, song_path: &String, song_queu
Ok(response)
}
pub mod response {
use serde::{Deserialize, Serialize};
}

View File

@@ -1,4 +1,3 @@
pub fn path_buf_to_string(path: &std::path::PathBuf) -> String {
let s_path = match path.to_str() {
Some(val) => String::from(val),
@@ -7,4 +6,3 @@ pub fn path_buf_to_string(path: &std::path::PathBuf) -> String {
s_path
}