Refactoring (#31)
All checks were successful
Rust Build / Check (push) Successful in 33s
Rust Build / Check (pull_request) Successful in 35s
Rust Build / build (push) Successful in 41s
Release Tagging / release (push) Successful in 32s
Rust Build / Test Suite (push) Successful in 37s
Rust Build / Rustfmt (push) Successful in 26s
Rust Build / Clippy (push) Successful in 33s
Rust Build / Test Suite (pull_request) Successful in 35s
Rust Build / Rustfmt (pull_request) Successful in 27s
Rust Build / Clippy (pull_request) Successful in 31s
Rust Build / build (pull_request) Successful in 37s

Reviewed-on: #31
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
2025-06-29 22:08:23 +00:00
committed by phoenix
parent 59ce1c294c
commit f9f3dbda36
4 changed files with 22 additions and 22 deletions

2
Cargo.lock generated
View File

@@ -1255,7 +1255,7 @@ dependencies = [
[[package]]
name = "songparser"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"futures",
"icarus_envy",

View File

@@ -1,6 +1,6 @@
[package]
name = "songparser"
version = "0.1.0"
version = "0.2.0"
edition = "2024"
rust-version = "1.88"

View File

@@ -11,20 +11,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let app_base_url = icarus_envy::environment::get_icarus_base_api_url().await;
loop {
println!("Base URL: {}", app_base_url);
println!("Base URL: {app_base_url}");
match is_queue_empty(&app_base_url).await {
Ok((empty, song_queue_item)) => {
if !empty {
println!("Queue is not empty");
println!("SongQueueItem: {:?}", song_queue_item);
println!("SongQueueItem: {song_queue_item:?}");
let song_queue_id = song_queue_item.data[0].id;
// TODO: Do something with the result later
match some_work(&app_base_url, &song_queue_id).await {
Ok(_) => {}
Err(err) => {
eprintln!("Error: {:?}", err);
eprintln!("Error: {err:?}");
}
}
} else {
@@ -32,7 +32,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}
Err(err) => {
eprintln!("Error checking if queue is empty: {:?}", err);
eprintln!("Error checking if queue is empty: {err:?}");
}
}
@@ -85,7 +85,7 @@ async fn some_work(
.await
{
Ok(_inner_response) => {
println!("Response: {:?}", _inner_response);
println!("Response: {_inner_response:?}");
Ok(())
}
Err(err) => Err(std::io::Error::other(err.to_string())),
@@ -113,7 +113,7 @@ async fn prep_song(
let (directory, filename) = generate_song_queue_dir_and_filename().await;
let song_queue_path = save_file_to_fs(&directory, &filename, &song_bytes).await;
println!("Saved at: {:?}", song_queue_path);
println!("Saved at: {song_queue_path:?}");
match api::get_metadata_queue::get(api_url, song_queue_id).await {
Ok(response) => {
@@ -125,9 +125,9 @@ async fn prep_song(
let id = &response.data[0].id;
let created_at = &response.data[0].created_at;
let metadata = &response.data[0].metadata;
println!("Id: {:?}", id);
println!("Metadata: {:?}", metadata);
println!("Created at: {:?}", created_at);
println!("Id: {id:?}");
println!("Metadata: {metadata:?}");
println!("Created at: {created_at:?}");
println!("Getting coverart queue");
match api::get_coverart_queue::get(api_url, song_queue_id).await
@@ -136,7 +136,7 @@ async fn prep_song(
match response.json::<api::get_coverart_queue::response::Response>().await {
Ok(response) => {
let coverart_queue_id = &response.data[0].id;
println!("Coverart queue Id: {:?}", coverart_queue_id);
println!("Coverart queue Id: {coverart_queue_id:?}");
match api::get_coverart_queue::get_data(api_url, coverart_queue_id).await {
Ok(response) => match api::parsing::parse_response_into_bytes(response).await {
@@ -144,7 +144,7 @@ async fn prep_song(
let (directory, filename) = generate_coverart_queue_dir_and_filename().await;
let coverart_queue_path = save_file_to_fs(&directory, &filename, &coverart_queue_bytes).await;
println!("Saved coverart queue file at: {:?}", coverart_queue_path);
println!("Saved coverart queue file at: {coverart_queue_path:?}");
let c_path = util::path_buf_to_string(&coverart_queue_path);
let s_path = util::path_buf_to_string(&song_queue_path);
@@ -350,7 +350,7 @@ pub async fn apply_metadata(
match icarus_meta::meta::coverart::contains_coverart(song_queue_path) {
Ok((exists, size)) => {
if exists {
println!("Coverart exists: {:?} size", size);
println!("Coverart exists: {size:?} size");
match icarus_meta::meta::coverart::remove_coverart(song_queue_path) {
Ok(_data) => {}
Err(err) => {
@@ -401,7 +401,7 @@ mod api {
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let fetch_endpoint = String::from("api/v2/song/queue/next");
let api_url = format!("{}/{}", base_url, fetch_endpoint);
let api_url = format!("{base_url}/{fetch_endpoint}");
client.get(api_url).send().await
}
@@ -432,7 +432,7 @@ mod api {
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/song/queue");
let api_url = format!("{}/{}/{}", base_url, endpoint, id);
let api_url = format!("{base_url}/{endpoint}/{id}");
client.get(api_url).send().await
}
}
@@ -444,7 +444,7 @@ mod api {
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/song/metadata/queue");
let api_url = format!("{}/{}", base_url, endpoint);
let api_url = format!("{base_url}/{endpoint}");
client
.get(api_url)
.query(&[("song_queue_id", song_queue_id)])
@@ -495,7 +495,7 @@ mod api {
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/coverart/queue");
let api_url = format!("{}/{}", base_url, endpoint);
let api_url = format!("{base_url}/{endpoint}");
client
.get(api_url)
.query(&[("song_queue_id", song_queue_id)])
@@ -509,7 +509,7 @@ mod api {
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/coverart/queue/data");
let api_url = format!("{}/{}/{}", base_url, endpoint, coverart_queue_id);
let api_url = format!("{base_url}/{endpoint}/{coverart_queue_id}");
client.get(api_url).send().await
}

View File

@@ -5,7 +5,7 @@ pub async fn update_queued_song(
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::builder().build()?;
println!("Song path: {:?}", song_path);
println!("Song path: {song_path:?}");
// TODO: Make the filename random
let form = reqwest::multipart::Form::new().part(
@@ -14,8 +14,8 @@ pub async fn update_queued_song(
.file_name("track01.flac"),
);
let url = format!("{}/api/v2/song/queue/{}", base_url, song_queue_id);
println!("Url: {:?}", url);
let url = format!("{base_url}/api/v2/song/queue/{song_queue_id}");
println!("Url: {url:?}");
let request = client.patch(url).multipart(form);