Code cleanup and formatting
All checks were successful
Rust Build / Check (pull_request) Successful in 32s
Rust Build / Test Suite (pull_request) Successful in 39s
Rust Build / Rustfmt (pull_request) Successful in 24s
Rust Build / Clippy (pull_request) Successful in 33s
Rust Build / build (pull_request) Successful in 52s

This commit is contained in:
2025-06-10 18:40:04 -04:00
parent 4c56b48aef
commit 65ce5fee65

View File

@@ -1,8 +1,3 @@
// use std::error::Error;
// use tokio::io::AsyncReadExt;
// use tokio::net::{TcpListener, TcpStream};
// use tokio::spawn;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), Box<dyn std::error::Error>> {
let app_base_url = get_icarus_url().await; let app_base_url = get_icarus_url().await;
@@ -10,20 +5,29 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
loop { loop {
println!("Base URL: {}", app_base_url); println!("Base URL: {}", app_base_url);
// TODO: Update the api/v2/song/queue/next endpoint to only retrieve queued song that is
// ready to be processed. Make necessary changes to other endpoints
// let api_url = format!("{}/api/v2/song/queue/next", app_base_url);
// match client.get(api_url).send().await {
match api::fetch_next_queue_item(&app_base_url).await { match api::fetch_next_queue_item(&app_base_url).await {
Ok(response) => { Ok(response) => {
// let body = response.text().await?; match response
// println!("API response: {}", body); .json::<responses::fetch_next_queue_item::SongQueueItem>()
match response.json::<responses::fetch_next_queue_item::SongQueueItem>().await { .await
{
Ok(song_queue_item) => { Ok(song_queue_item) => {
if !song_queue_item.data.is_empty() { if !song_queue_item.data.is_empty() {
println!("Song queue item: {:?}", song_queue_item); println!("Song queue item: {:?}", song_queue_item);
// Process data here...
// TODO: Parse the response body to a struct
// TODO: Get queued song data
// TODO: Get queued song's metadata
// TODO: Get queued coverart
// TODO: Get queued coverart's data
// TODO: Apply metadata to the queued song
// TODO: Update the queued song with the updated queued song
// TODO: Create song
// TODO: Create coverart
// TODO: Wipe data from queued song
// TODO: Wipe data from queued coverart
} else { } else {
println!("No data to fetch"); println!("No data to fetch");
} }
@@ -32,19 +36,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
eprintln!("Error: {:?}", err); eprintln!("Error: {:?}", err);
} }
} }
// Process data here...
// TODO: Parse the response body to a struct
// TODO: Get queued song data
// TODO: Get queued song's metadata
// TODO: Get queued coverart
// TODO: Get queued coverart's data
// TODO: Apply metadata to the queued song
// TODO: Update the queued song with the updated queued song
// TODO: Create song
// TODO: Create coverart
// TODO: Wipe data from queued song
// TODO: Wipe data from queued coverart
} }
Err(e) => eprintln!("API call failed: {}", e), Err(e) => eprintln!("API call failed: {}", e),
} }
@@ -52,7 +43,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Sleeping"); println!("Sleeping");
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await; tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
} }
// Ok(())
} }
mod responses { mod responses {
@@ -75,14 +65,13 @@ mod responses {
} }
mod api { mod api {
pub async fn fetch_next_queue_item(base_url: &String) -> Result<reqwest::Response, reqwest::Error> { pub async fn fetch_next_queue_item(
base_url: &String,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new(); let client = reqwest::Client::new();
let fetch_endpoint = String::from("api/v2/song/queue/next"); 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);
let resp = client.get(api_url).send().await; client.get(api_url).send().await
// Ok(resp)
resp
} }
} }