updated dependencies and made small changes to the library

This commit is contained in:
MrDulfin 2024-03-30 00:55:56 -04:00
parent c0f71e0741
commit 7da0b1a1db
2 changed files with 11 additions and 9 deletions

View file

@ -32,7 +32,6 @@ leb128 = "0.2.5"
urlencoding = "2.1.3" urlencoding = "2.1.3"
m3u8-rs = "5.0.5" m3u8-rs = "5.0.5"
thiserror = "1.0.56" 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" serde_json = "1.0.111"
deunicode = "1.4.2" deunicode = "1.4.2"

View file

@ -7,7 +7,7 @@ use std::collections::BTreeMap;
use std::error::Error; use std::error::Error;
use std::io::Write; use std::io::Write;
use std::ops::ControlFlow::{Break, Continue}; use std::ops::ControlFlow::{Break, Continue};
use std::thread::sleep;
// Files // Files
use file_format::{FileFormat, Kind}; use file_format::{FileFormat, Kind};
@ -426,6 +426,8 @@ impl Song {
Ok(tracks) 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<dyn Error>> { pub fn open_album_art(&self, index: usize, temp_dir: &TempDir) -> Result<(), Box<dyn Error>> {
use opener::open; use opener::open;
use urlencoding::decode; use urlencoding::decode;
@ -446,14 +448,14 @@ impl Song {
let blank_tag = &lofty::Tag::new(TagType::Id3v2); let blank_tag = &lofty::Tag::new(TagType::Id3v2);
let tagged_file: lofty::TaggedFile; let tagged_file: lofty::TaggedFile;
#[cfg(windows)] #[cfg(target_family = "windows")]
let uri = urlencoding::decode( let uri = urlencoding::decode(
match self.location.as_uri().strip_prefix("file:///") { match self.location.as_uri().strip_prefix("file:///") {
Some(str) => str, Some(str) => str,
None => return Err("invalid path.. again?".into()) None => return Err("invalid path.. again?".into())
})?.into_owned(); })?.into_owned();
#[cfg(unix)] #[cfg(target_family = "unix")]
let uri = urlencoding::decode( let uri = urlencoding::decode(
match self.location.as_uri().strip_prefix("file://") { match self.location.as_uri().strip_prefix("file://") {
Some(str) => str, Some(str) => str,
@ -1149,13 +1151,14 @@ mod test {
#[test] #[test]
fn get_art_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 dir = &TempDir::new().unwrap();
let now = Instant::now(); let now = Instant::now();
_ = s.open_album_art(0, dir).inspect_err(|e| println!("{e:?}")); _ = 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() ); println!("{}ms", now.elapsed().as_millis() );
sleep(Duration::from_secs(1)); sleep(Duration::from_secs(20));
} }
} }