Compare commits
2 Commits
v0.1.0-dev
...
v0.1.0-dev
Author | SHA1 | Date | |
---|---|---|---|
eaa3c6f40e | |||
79eea81e28 |
33
Cargo.lock
generated
33
Cargo.lock
generated
@@ -83,6 +83,26 @@ version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "const_format"
|
||||
version = "0.2.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd"
|
||||
dependencies = [
|
||||
"const_format_proc_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "const_format_proc_macros"
|
||||
version = "0.2.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.9.4"
|
||||
@@ -450,9 +470,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icarus_envy"
|
||||
version = "0.2.0"
|
||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.2.0#3ee8c1e573ba9637769aa0538d2c11335e39ed9f"
|
||||
version = "0.2.2"
|
||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.2.2-devel-84ea6e4c22-006#84ea6e4c223f19ff96f6b7cae944e831ef4aa831"
|
||||
dependencies = [
|
||||
"const_format",
|
||||
"dotenvy",
|
||||
]
|
||||
|
||||
@@ -1148,13 +1169,13 @@ dependencies = [
|
||||
name = "songparser"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dotenvy",
|
||||
"futures",
|
||||
"icarus_envy",
|
||||
"icarus_models",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"time",
|
||||
"tokio",
|
||||
"uuid",
|
||||
]
|
||||
@@ -1415,6 +1436,12 @@ version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
||||
|
||||
[[package]]
|
||||
name = "untrusted"
|
||||
version = "0.9.0"
|
||||
|
@@ -10,7 +10,7 @@ futures = { version = "0.3.31" }
|
||||
reqwest = { version = "0.12.19", features = ["json", "stream"] }
|
||||
serde = { version = "1.0.218", features = ["derive"] }
|
||||
serde_json = { version = "1.0.139" }
|
||||
time = { version = "0.3.41", features = ["macros", "serde"] }
|
||||
uuid = { version = "1.16.0", features = ["v4", "serde"] }
|
||||
dotenvy = { version = "0.15.7" }
|
||||
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.4.3" }
|
||||
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.2.0" }
|
||||
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.2.2-devel-84ea6e4c22-006" }
|
||||
|
101
src/main.rs
101
src/main.rs
@@ -4,7 +4,7 @@ pub const SECONDS_TO_SLEEP: u64 = 5;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let app_base_url = get_icarus_url().await;
|
||||
let app_base_url = icarus_envy::environment::get_icarus_base_api_url().await;
|
||||
|
||||
loop {
|
||||
println!("Base URL: {}", app_base_url);
|
||||
@@ -18,11 +18,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Ok(song_queue_item) => {
|
||||
if !song_queue_item.data.is_empty() {
|
||||
println!("Song queue item: {:?}", song_queue_item);
|
||||
let song_queue_id = song_queue_item.data[0].id;
|
||||
|
||||
println!("Fetching song queue data");
|
||||
match api::fetch_song_queue_data::get_data(
|
||||
&app_base_url,
|
||||
&song_queue_item.data[0].id,
|
||||
&song_queue_id,
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -41,15 +42,39 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
println!("Saved at: {:?}", save_path);
|
||||
|
||||
// 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
|
||||
match api::get_metadata_queue::get(
|
||||
&app_base_url,
|
||||
&song_queue_id,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(response) => {
|
||||
match response.json::<api::get_metadata_queue::response::Response>().await {
|
||||
Ok(response) => {
|
||||
let id = &response.data[0].id;
|
||||
let metadata = &response.data[0].metadata;
|
||||
let created_at = &response.data[0].created_at;
|
||||
println!("Id: {:?}", id);
|
||||
println!("Metadata: {:?}", metadata);
|
||||
println!("Created at: {:?}", created_at);
|
||||
// TODO: Get queued coverart
|
||||
// TODO: Get queued coverart's data
|
||||
// TODO: Apply metadata to the queued song (modifying file)
|
||||
// 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) => {
|
||||
eprintln!("Error: {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error fetching song queue data: {:?}", err);
|
||||
@@ -159,9 +184,55 @@ mod api {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_icarus_url() -> String {
|
||||
dotenvy::dotenv().ok();
|
||||
std::env::var("ICARUS_BASE_API_URL").expect("Could not find url")
|
||||
pub mod get_metadata_queue {
|
||||
pub async fn get(
|
||||
base_url: &String,
|
||||
song_queue_id: &uuid::Uuid,
|
||||
) -> 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);
|
||||
client
|
||||
.get(api_url)
|
||||
.query(&[("song_queue_id", song_queue_id)])
|
||||
.send()
|
||||
.await
|
||||
}
|
||||
|
||||
pub mod response {
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct Metadata {
|
||||
pub id: uuid::Uuid,
|
||||
pub album: String,
|
||||
pub album_artist: String,
|
||||
pub artist: String,
|
||||
pub disc: i32,
|
||||
pub disc_count: i32,
|
||||
pub duration: i64,
|
||||
pub genre: String,
|
||||
pub title: String,
|
||||
pub track: i32,
|
||||
pub track_count: i32,
|
||||
pub year: i32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct QueueItem {
|
||||
pub id: uuid::Uuid,
|
||||
pub metadata: Metadata,
|
||||
#[serde(with = "time::serde::rfc3339")]
|
||||
pub created_at: time::OffsetDateTime,
|
||||
pub song_queue_id: uuid::Uuid,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct Response {
|
||||
pub message: String,
|
||||
pub data: Vec<QueueItem>,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user