Some cleanup
All checks were successful
Rust Build / Check (pull_request) Successful in 44s
Rust Build / Test Suite (pull_request) Successful in 57s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Clippy (pull_request) Successful in 46s
Rust Build / build (pull_request) Successful in 1m16s
All checks were successful
Rust Build / Check (pull_request) Successful in 44s
Rust Build / Test Suite (pull_request) Successful in 57s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Clippy (pull_request) Successful in 46s
Rust Build / build (pull_request) Successful in 1m16s
This commit is contained in:
45
src/main.rs
45
src/main.rs
@@ -19,7 +19,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
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);
|
||||||
|
|
||||||
match api::fetch_song_queue_data::get_data(&app_base_url, &song_queue_item.data[0].id).await {
|
match api::fetch_song_queue_data::get_data(
|
||||||
|
&app_base_url,
|
||||||
|
&song_queue_item.data[0].id,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
// TODO: At some point, handle the flow if the size is small or
|
// TODO: At some point, handle the flow if the size is small or
|
||||||
// large
|
// large
|
||||||
@@ -33,11 +38,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
let mut song = icarus_models::song::Song::default();
|
let mut song = icarus_models::song::Song::default();
|
||||||
song.data = all_bytes;
|
song.data = all_bytes;
|
||||||
song.filename = song.generate_filename(icarus_models::types::MusicTypes::FlacExtension, true);
|
song.filename = song.generate_filename(
|
||||||
|
icarus_models::types::MusicTypes::FlacExtension,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
// TODO: Add function to save bytes to a file in icarus_models
|
// TODO: Add function to save bytes to a file in icarus_models
|
||||||
|
// repo
|
||||||
|
|
||||||
song.directory = icarus_envy::environment::get_root_directory().await;
|
song.directory =
|
||||||
|
icarus_envy::environment::get_root_directory().await;
|
||||||
|
|
||||||
let dir = std::path::Path::new(&song.directory);
|
let dir = std::path::Path::new(&song.directory);
|
||||||
let save_path = dir.join(&song.filename);
|
let save_path = dir.join(&song.filename);
|
||||||
@@ -46,26 +56,22 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
file.write_all(&song.data).unwrap();
|
file.write_all(&song.data).unwrap();
|
||||||
println!("File saved to: {:?}", save_path);
|
println!("File saved to: {:?}", save_path);
|
||||||
|
|
||||||
// Process data here...
|
// 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
|
|
||||||
|
|
||||||
|
// 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(err) => {
|
Err(err) => {
|
||||||
eprintln!("Error fetching song queue data: {:?}", err);
|
eprintln!("Error fetching song queue data: {:?}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
println!("No data to fetch");
|
println!("No data to fetch");
|
||||||
}
|
}
|
||||||
@@ -113,7 +119,10 @@ mod api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod fetch_song_queue_data {
|
pub mod fetch_song_queue_data {
|
||||||
pub async fn get_data(base_url: &String, id: &uuid::Uuid) -> Result<reqwest::Response, reqwest::Error> {
|
pub async fn get_data(
|
||||||
|
base_url: &String,
|
||||||
|
id: &uuid::Uuid,
|
||||||
|
) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let endpoint = String::from("api/v2/song/queue");
|
let endpoint = String::from("api/v2/song/queue");
|
||||||
let api_url = format!("{}/{}/{}", base_url, endpoint, id);
|
let api_url = format!("{}/{}/{}", base_url, endpoint, id);
|
||||||
|
Reference in New Issue
Block a user