Compare commits
6 Commits
v0.3.0
...
60069d9e14
Author | SHA1 | Date | |
---|---|---|---|
60069d9e14
|
|||
d4e7aba4a8
|
|||
e247870e4d
|
|||
038f8dbd9a
|
|||
b2f702c24c | |||
ea6f65a206
|
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -516,8 +516,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icarus_envy"
|
||||
version = "0.3.2"
|
||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.3.2#d84a8144aedf02e1b459d67c4023a7e0833f89fd"
|
||||
version = "0.4.1"
|
||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.4.1-main-8f0d123db5-006#8f0d123db51b18e9cc4ab5bd39a474ba99bd39c3"
|
||||
dependencies = [
|
||||
"const_format",
|
||||
"dotenvy",
|
||||
@@ -533,8 +533,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icarus_models"
|
||||
version = "0.5.6"
|
||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_models.git?tag=v0.5.6#2d6b550ae6721b41ecc3039799f6a5e873869077"
|
||||
version = "0.6.6"
|
||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_models.git?tag=v0.6.6-65-eac7562b80-111#eac7562b80b9f82d21ab737d1e84ba4f12e472dd"
|
||||
dependencies = [
|
||||
"josekit",
|
||||
"rand",
|
||||
@@ -1320,7 +1320,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "songparser"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"icarus_envy",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "songparser"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
edition = "2024"
|
||||
rust-version = "1.88"
|
||||
|
||||
@@ -14,5 +14,5 @@ time = { version = "0.3.41", features = ["macros", "serde"] }
|
||||
uuid = { version = "1.17.0", features = ["v4", "serde"] }
|
||||
rand = { version = "0.9.1" }
|
||||
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.3.0" }
|
||||
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.5.6" }
|
||||
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.3.2" }
|
||||
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.6.6-65-eac7562b80-111" }
|
||||
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.4.1-main-8f0d123db5-006" }
|
||||
|
52
src/main.rs
52
src/main.rs
@@ -12,8 +12,12 @@ pub const SECONDS_TO_SLEEP: u64 = 5;
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut app = config::App {
|
||||
uri: icarus_envy::environment::get_icarus_base_api_url().await,
|
||||
auth_uri: icarus_envy::environment::get_icarus_auth_base_api_url().await,
|
||||
uri: icarus_envy::environment::get_icarus_base_api_url()
|
||||
.await
|
||||
.value,
|
||||
auth_uri: icarus_envy::environment::get_icarus_auth_base_api_url()
|
||||
.await
|
||||
.value,
|
||||
..Default::default()
|
||||
};
|
||||
println!("Base URL: {:?}", app.uri);
|
||||
@@ -110,7 +114,7 @@ mod auth {
|
||||
let api_url = format!("{}/{endpoint}", app.auth_uri);
|
||||
|
||||
let payload = serde_json::json!({
|
||||
"passphrase": icarus_envy::environment::get_service_passphrase().await,
|
||||
"passphrase": icarus_envy::environment::get_service_passphrase().await.value,
|
||||
});
|
||||
|
||||
match client.post(api_url).json(&payload).send().await {
|
||||
@@ -342,7 +346,29 @@ async fn prep_song(
|
||||
match api::parsing::parse_response_into_bytes(response).await {
|
||||
Ok(song_bytes) => {
|
||||
let (directory, filename) = generate_song_queue_dir_and_filename().await;
|
||||
let song_queue_path = save_file_to_fs(&directory, &filename, &song_bytes).await;
|
||||
let song = icarus_models::song::Song {
|
||||
directory: directory,
|
||||
filename: filename,
|
||||
data: song_bytes,
|
||||
..Default::default()
|
||||
};
|
||||
let songpath = match song.song_path() {
|
||||
Ok(songpath) => {
|
||||
songpath
|
||||
}
|
||||
Err(_err) => {
|
||||
String::new()
|
||||
}
|
||||
};
|
||||
|
||||
let song_queue_path = match song.save_to_filesystem() {
|
||||
Ok(_) => {
|
||||
std::path::Path::new(&songpath)
|
||||
}
|
||||
Err(_err) => {
|
||||
std::path::Path::new("")
|
||||
}
|
||||
};
|
||||
|
||||
println!("Saved at: {song_queue_path:?}");
|
||||
|
||||
@@ -372,8 +398,14 @@ async fn prep_song(
|
||||
Ok(response) => match api::parsing::parse_response_into_bytes(response).await {
|
||||
Ok(coverart_queue_bytes) => {
|
||||
let (directory, filename) = generate_coverart_queue_dir_and_filename().await;
|
||||
let coverart_queue_path = save_file_to_fs(&directory, &filename, &coverart_queue_bytes).await;
|
||||
|
||||
let coverart = icarus_models::coverart::CoverArt {
|
||||
path: directory + "/" + &filename,
|
||||
data: coverart_queue_bytes,
|
||||
..Default::default()
|
||||
};
|
||||
// let coverart_queue_path = save_file_to_fs(&directory, &filename, &coverart_queue_bytes).await;
|
||||
coverart.save_to_filesystem().unwrap();
|
||||
let coverart_queue_path = std::path::Path::new(&coverart.path);
|
||||
println!("Saved coverart queue file at: {coverart_queue_path:?}");
|
||||
|
||||
let c_path = util::path_buf_to_string(&coverart_queue_path);
|
||||
@@ -413,9 +445,9 @@ async fn prep_song(
|
||||
// TODO: Consider having something like this in icarus_models
|
||||
pub async fn generate_song_queue_dir_and_filename() -> (String, String) {
|
||||
let mut song = icarus_models::song::Song::default();
|
||||
song.filename = song.generate_filename(icarus_models::types::MusicTypes::FlacExtension, true);
|
||||
song.filename = icarus_models::song::generate_filename(icarus_models::types::MusicTypes::FlacExtension, true);
|
||||
|
||||
song.directory = icarus_envy::environment::get_root_directory().await;
|
||||
song.directory = icarus_envy::environment::get_root_directory().await.value;
|
||||
|
||||
(song.directory, song.filename)
|
||||
}
|
||||
@@ -444,13 +476,13 @@ pub async fn generate_coverart_queue_dir_and_filename() -> (String, String) {
|
||||
filename += ".jpeg";
|
||||
|
||||
// TODO: Consider separating song and coverart when saving to the filesystem
|
||||
let directory = icarus_envy::environment::get_root_directory().await;
|
||||
let directory = icarus_envy::environment::get_root_directory().await.value;
|
||||
|
||||
(directory, filename)
|
||||
}
|
||||
|
||||
// TODO: Check to see if this is available in icarus_models
|
||||
pub async fn save_file_to_fs(
|
||||
async fn save_file_to_fs(
|
||||
directory: &String,
|
||||
filename: &String,
|
||||
data: &[u8],
|
||||
|
Reference in New Issue
Block a user