From 7da0b1a1dbff0af4e5ae1c6d02c1b1a82cc0ae8f Mon Sep 17 00:00:00 2001 From: MrDulfin Date: Sat, 30 Mar 2024 00:55:56 -0400 Subject: [PATCH] updated dependencies and made small changes to the library --- Cargo.toml | 7 +++---- src/music_storage/library.rs | 13 ++++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 266e022..2d106a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,9 +32,8 @@ leb128 = "0.2.5" urlencoding = "2.1.3" m3u8-rs = "5.0.5" thiserror = "1.0.56" -font = "0.27.0" -uuid = { version = "1.6.1", features = ["v4", "serde"]} +uuid = { version = "1.6.1", features = ["v4", "serde"] } serde_json = "1.0.111" deunicode = "1.4.2" -opener = { version = "0.7.0", features = ["reveal"]} -tempfile = "3.10.1" +opener = { version = "0.7.0", features = ["reveal"] } +tempfile = "3.10.1" \ No newline at end of file diff --git a/src/music_storage/library.rs b/src/music_storage/library.rs index 2095821..1afc991 100644 --- a/src/music_storage/library.rs +++ b/src/music_storage/library.rs @@ -7,7 +7,7 @@ use std::collections::BTreeMap; use std::error::Error; use std::io::Write; use std::ops::ControlFlow::{Break, Continue}; -use std::thread::sleep; + // Files use file_format::{FileFormat, Kind}; @@ -426,6 +426,8 @@ impl Song { Ok(tracks) } + /// Takes the AlbumArt[index] and opens it in the native file viewer + pub fn open_album_art(&self, index: usize, temp_dir: &TempDir) -> Result<(), Box> { use opener::open; use urlencoding::decode; @@ -446,14 +448,14 @@ impl Song { let blank_tag = &lofty::Tag::new(TagType::Id3v2); let tagged_file: lofty::TaggedFile; - #[cfg(windows)] + #[cfg(target_family = "windows")] let uri = urlencoding::decode( match self.location.as_uri().strip_prefix("file:///") { Some(str) => str, None => return Err("invalid path.. again?".into()) })?.into_owned(); - #[cfg(unix)] + #[cfg(target_family = "unix")] let uri = urlencoding::decode( match self.location.as_uri().strip_prefix("file://") { Some(str) => str, @@ -1149,13 +1151,14 @@ mod test { #[test] fn get_art_test() { - let s = Song::from_file(Path::new(".\\test-config\\music\\Snail_s House - Hot Milk.mp3")).unwrap(); + let s = Song::from_file(Path::new("")).unwrap(); let dir = &TempDir::new().unwrap(); let now = Instant::now(); _ = s.open_album_art(0, dir).inspect_err(|e| println!("{e:?}")); + _ = s.open_album_art(1, dir).inspect_err(|e| println!("{e:?}")); println!("{}ms", now.elapsed().as_millis() ); - sleep(Duration::from_secs(1)); + sleep(Duration::from_secs(20)); } } \ No newline at end of file