tsk-81: Simplify downloading song (#89)

* tsk-81: Using method in Song to save to filesystem

* tsk-81: icaurs_models version bump

* tsk-81: Code formatting

* tsk-81: icarus_models version bump

* tsk-81: Version bump
This commit was merged in pull request #89.
This commit is contained in:
KD
2025-10-24 13:34:55 -04:00
committed by GitHub
parent 05a9134aaa
commit 686e0d8f1f
3 changed files with 21 additions and 12 deletions
+16 -7
View File
@@ -192,7 +192,7 @@ impl CommitManager {
let api = prsr.retrieve_api(parsers::api_parser::APIType::Main);
let mut dwn_loader = syncers::download::Download { api: api.clone() };
let song = icarus_models::song::Song {
let mut song = icarus_models::song::Song {
id: song_id,
..Default::default()
};
@@ -200,12 +200,21 @@ impl CommitManager {
match dwn_loader.download_song(&token, &song).await {
Ok(o) => {
println!("Success");
let filename = String::from("audio")
+ icarus_models::constants::file_extensions::audio::DEFAULTMUSICEXTENSION;
let data = o.as_bytes();
let mut file = std::fs::File::create(filename).expect("Failed to save");
file.write_all(data)
.expect("Failed to save downloaded song");
song.data = o.as_bytes().to_vec();
song.directory = String::from(".");
song.filename = icarus_models::song::generate_filename(
icarus_models::types::MusicTypes::FlacExtension,
true,
);
match song.save_to_filesystem() {
Ok(_) => {
println!("Song saved");
}
Err(err) => {
eprintln!("Error saving song: {err:?}");
}
}
}
Err(er) => {
println!("Error {er:?}");