Compare commits
2 Commits
e247870e4d
...
60069d9e14
Author | SHA1 | Date | |
---|---|---|---|
60069d9e14
|
|||
d4e7aba4a8
|
38
src/main.rs
38
src/main.rs
@@ -346,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:?}");
|
||||
|
||||
@@ -376,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);
|
||||
@@ -417,7 +445,7 @@ 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.value;
|
||||
|
||||
@@ -454,7 +482,7 @@ pub async fn generate_coverart_queue_dir_and_filename() -> (String, String) {
|
||||
}
|
||||
|
||||
// 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