Compare commits

..

No commits in common. "c0f71e07410ddd505144e160e28ecca405abe994" and "9da9b00befa600d6694e5b7ec7989580848f9008" have entirely different histories.

4 changed files with 157 additions and 235 deletions

View file

@ -37,4 +37,5 @@ 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"
opener = { version = "0.7.0", features = ["reveal"]} opener = { version = "0.7.0", features = ["reveal"]}
image = "0.25.0"
tempfile = "3.10.1" tempfile = "3.10.1"

View file

@ -1,3 +1,5 @@
#[allow(dead_code)]
pub mod music_storage { pub mod music_storage {
pub mod library; pub mod library;
pub mod music_collection; pub mod music_collection;

View file

@ -1,6 +1,6 @@
use uuid::Uuid; use uuid::Uuid;
use crate::{ use crate::{
music_player::{Player, PlayerError}, music_player::Player,
music_storage::library::{Album, MusicLibrary, URI} music_storage::library::{Album, MusicLibrary, URI}
}; };
use std::{ use std::{
@ -8,25 +8,13 @@ use std::{
sync::{Arc, RwLock} sync::{Arc, RwLock}
}; };
use thiserror::Error;
#[derive(Error, Debug)]
pub enum QueueError {
#[error("Index out of bounds! Index {0} is over len {1}")]
OutOfBounds(usize, usize),
#[error("The Queue is empty!")]
EmptyQueue
}
#[derive(Debug, PartialEq, Clone, Copy)] #[derive(Debug, PartialEq, Clone, Copy)]
pub enum QueueState { pub enum QueueState {
Played, Played,
First, Current,
AddHere, AddHere,
NoState, NoState,
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] #[non_exhaustive]
pub enum QueueItemType<'a> { pub enum QueueItemType<'a> {
@ -35,20 +23,12 @@ pub enum QueueItemType<'a> {
Album{ Album{
album: Album<'a>, album: Album<'a>,
shuffled: bool, shuffled: bool,
order: Option<Vec<Uuid>>,
// disc #, track # // disc #, track #
current: (i32, i32) current: (i32, i32)
}, },
Playlist {
uuid: Uuid,
shuffled: bool,
order: Option<Vec<Uuid>>,
current: Uuid
},
None, None,
Test Test
} }
impl QueueItemType<'_> { impl QueueItemType<'_> {
fn get_uri(&self, lib: Arc<RwLock<MusicLibrary>>) -> Option<URI> { fn get_uri(&self, lib: Arc<RwLock<MusicLibrary>>) -> Option<URI> {
use QueueItemType::*; use QueueItemType::*;
@ -62,7 +42,7 @@ impl QueueItemType<'_> {
Option::None Option::None
} }
}, },
Album{album, shuffled, current: (disc, index), ..} => { Album{album, shuffled, current: (disc, index)} => {
if !shuffled { if !shuffled {
Some(album.track(*disc as usize, *index as usize).unwrap().location.clone()) Some(album.track(*disc as usize, *index as usize).unwrap().location.clone())
}else { }else {
@ -75,23 +55,19 @@ impl QueueItemType<'_> {
} }
} }
// TODO: move this to a different location to be used elsewhere
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] #[non_exhaustive]
pub enum PlayerLocation { pub enum QueueSource {
Test,
Library, Library,
Playlist(Uuid), Playlist(Uuid),
File, File,
Custom
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] #[non_exhaustive]
pub struct QueueItem<'a> { pub struct QueueItem<'a> {
item: QueueItemType<'a>, item: QueueItemType<'a>,
state: QueueState, state: QueueState,
source: PlayerLocation, source: QueueSource,
by_human: bool by_human: bool
} }
impl QueueItem<'_> { impl QueueItem<'_> {
@ -99,7 +75,7 @@ impl QueueItem<'_> {
QueueItem { QueueItem {
item: QueueItemType::None, item: QueueItemType::None,
state: QueueState::NoState, state: QueueState::NoState,
source: PlayerLocation::Library, source: QueueSource::Library,
by_human: false by_human: false
} }
} }
@ -111,83 +87,111 @@ pub struct Queue<'a> {
pub player: Player, pub player: Player,
pub name: String, pub name: String,
pub items: Vec<QueueItem<'a>>, pub items: Vec<QueueItem<'a>>,
pub played: Vec<QueueItem<'a>>,
pub loop_: bool
} }
impl<'a> Queue<'a> { impl<'a> Queue<'a> {
fn has_addhere(&self) -> bool {
for item in &self.items {
if item.state == QueueState::AddHere {
return true
}
}
false
}
fn dbg_items(&self) { fn dbg_items(&self) {
dbg!(self.items.iter().map(|item| item.item.clone() ).collect::<Vec<QueueItemType>>(), self.items.len()); dbg!(self.items.iter().map(|item| item.item.clone() ).collect::<Vec<QueueItemType>>(), self.items.len());
} }
pub fn new() -> Result<Self, Box<dyn Error>> {
pub fn new() -> Result<Self, PlayerError> {
Ok( Ok(
Queue { Queue {
player: Player::new()?, player: Player::new()?,
name: String::new(), name: String::new(),
items: Vec::new(), items: Vec::new()
played: Vec::new(),
loop_: false,
} }
) )
} }
pub fn current_index(&mut self/* , max: usize */) -> Option<usize> {
let mut e = self.items.iter().filter(|song| song.state == QueueState::Played ).collect::<Vec<&QueueItem>>().len();
// TODO: make the max number of past songs modular
while e > 50 {
self.items.remove(0);
e -=1;
}
if e == 0 {
None
}else {
Some(e - 1)
}
}
fn contains_state(&self, state: QueueState) -> bool {
!self.items.iter().filter(|item| item.state == state ).collect::<Vec<_>>().is_empty()
}
fn is_empty(&self) -> bool {
self.items.iter().filter(|item| item.state != QueueState::Played).collect::<Vec<_>>().is_empty()
}
pub fn set_items(&mut self, tracks: Vec<QueueItem<'a>>) { pub fn set_items(&mut self, tracks: Vec<QueueItem<'a>>) {
let mut tracks = tracks; let mut tracks = tracks;
self.items.clear(); self.items.clear();
self.items.append(&mut tracks); self.items.append(&mut tracks);
} }
pub fn add_item(&mut self, item: QueueItemType<'a>, source: PlayerLocation, by_human: bool) { pub fn add_item(&mut self, item: QueueItemType<'a>, source: QueueSource, by_human: bool) -> Result<(), Box<dyn Error>> {
use QueueState::*;
let mut i: usize = 0; let mut i: usize = 0;
let ind = self.current_index();
self.items = self.items.iter().enumerate().map(|(j, item_)| { self.items = self.items.iter().enumerate().map(|(j, item_)| {
let mut item_ = item_.to_owned(); let mut item_ = item_.to_owned();
// get the index of the current AddHere item and give it to i // get the index of the current AddHere item and give it to i
if item_.state == QueueState::AddHere { if item_.state == AddHere {
i = j; i = j - ind.unwrap_or(0);
item_.state = QueueState::NoState; item_.state = NoState;
} else if item_.state == Current {
i = j - ind.unwrap_or(0);
} }
item_ item_
}).collect::<Vec<QueueItem>>(); }).collect::<Vec<QueueItem>>();
self.items.insert(i + if self.items.is_empty() { 0 } else { 1 }, QueueItem { let pos = ind.unwrap_or(0) + i + if !self.is_empty() || (self.is_empty() && ind == None) { 0 } else { 1 };
item, // dbg!(&pos, &i, &ind);
state: QueueState::AddHere, self.items.insert(
pos,
QueueItem {
item: item.clone(),
state: if pos == self.items.len() && i == 0 {
Current
}else {
AddHere
},
source, source,
by_human by_human
}); }
);
Ok(())
} }
pub fn add_item_next(&mut self, item: QueueItemType<'a>, source: PlayerLocation) { pub fn add_item_next(&mut self, item: QueueItemType<'a>, source: QueueSource) {
use QueueState::*; use QueueState::*;
let empty = self.items.is_empty(); let ind_ = self.current_index();
let ind = ind_.unwrap_or(0);
let empty = self.is_empty();
self.items.insert( self.items.insert(
(if empty { 0 } else { 1 }), ind + if !empty && ind_ == None { 1 } else { 2 },
QueueItem { QueueItem {
item, item,
state: if (self.items.get(1).is_none() || (!self.has_addhere() && self.items.get(1).is_some()) || empty) { AddHere } else { NoState }, state: if empty {
Current
}else if self.items.get(ind + 1).is_none() || (!self.contains_state(AddHere) && self.items.get(ind + 1).is_some()) {
AddHere
}else {
NoState
},
source, source,
by_human: true by_human: true
} }
) )
} }
pub fn add_multi(&mut self, items: Vec<QueueItemType>, source: PlayerLocation, by_human: bool) { pub fn remove_item(&mut self, index: usize) -> Result<(), Box<dyn Error>> {
use QueueState::*;
} let remove_index: usize = (if let Some(current_index) = self.current_index() { dbg!(&current_index); current_index } else { 0 } + index );
pub fn remove_item(&mut self, remove_index: usize) -> Result<(), QueueError> {
// dbg!(/*&remove_index, self.current_index(), &index,*/ &self.items[remove_index]); // dbg!(/*&remove_index, self.current_index(), &index,*/ &self.items[remove_index]);
@ -195,29 +199,39 @@ impl<'a> Queue<'a> {
// update the state of the next item to replace the item being removed // update the state of the next item to replace the item being removed
if self.items.get(remove_index + 1).is_some() { if self.items.get(remove_index + 1).is_some() {
self.items[remove_index + 1].state = self.items[remove_index].state; self.items[remove_index + 1].state = self.items[remove_index].state;
}else if self.items[remove_index].state != Current {
self.items[remove_index - 1].state = self.items[remove_index].state;
} }
self.items[remove_index].state = QueueState::NoState; self.items[remove_index].state = NoState;
self.items.remove(remove_index); self.items.remove(remove_index);
Ok(()) Ok(())
}else { }else {
Err(QueueError::EmptyQueue) Err("No Songs to remove!".into())
} }
} }
pub fn clear(&mut self) { pub fn clear(&mut self) {
self.items.clear(); self.items.retain(|item| item.state == QueueState::Played );
} }
pub fn clear_except(&mut self, index: usize) -> Result<(), Box<dyn Error>> { pub fn clear_except(&mut self, index: usize) -> Result<(), Box<dyn Error>> {
use QueueState::*; let mut index = index;
let empty = self.items.is_empty(); let ind = match self.current_index() {
Some(e) => e,
None => return Err("nothing to clear!".into())
};
let empty = self.is_empty();
if !empty {
index += ind;
}else {
index -=1
}
if !empty && index < self.items.len() { if !empty && index < self.items.len() {
let i = self.items[index].clone(); let i = self.items[index].clone();
self.items.retain(|item| *item == i ); self.items.retain(|item| item.state == QueueState::Played || *item == i );
self.items[0].state = AddHere; self.items[ind+1].state = QueueState::Current
}else if empty {
return Err("Queue is empty!".into());
}else { }else {
return Err("index out of bounds!".into()); return Err("index out of bounds!".into());
} }
@ -225,117 +239,49 @@ impl<'a> Queue<'a> {
} }
pub fn clear_played(&mut self) { pub fn clear_played(&mut self) {
self.played.clear(); self.items.retain(|item| item.state != QueueState::Played );
} }
pub fn clear_all(&mut self) { pub fn clear_all(&mut self) {
self.items.clear(); self.items.clear()
self.played.clear();
} }
fn move_to(&mut self, index: usize) -> Result<(), Box<dyn Error>> {
let empty = self.is_empty();
let nothing_error = Err("Nothing in the queue to move to!".into());
let ind = self.current_index().unwrap_or(0);
let index = if !empty { index + ind } else { return nothing_error; };
// TODO: uh, fix this? if !empty && index < self.items.len() -1 {
fn move_to(&mut self, index: usize) -> Result<(), QueueError> {
use QueueState::*;
let empty = self.items.is_empty();
let nothing_error = Err(QueueError::EmptyQueue);
let index = if !empty { index } else { return nothing_error; };
if !empty && index < self.items.len() {
let position = self.player.position(); let position = self.player.position();
if position.is_some_and(|dur| !dur.is_zero() ) { if position.is_some_and(|dur| !dur.is_zero() ) {
self.played.push(self.items[0].clone()); self.items[ind].state = QueueState::Played;
} }
let to_item = self.items[index].clone(); let to_item = self.items[index].clone();
let ind = self.current_index().unwrap_or(0);
loop { loop {
let empty = !self.items.is_empty(); if self.items[ind].item != to_item.item {
let item = self.items[0].item.to_owned();
if item != to_item.item && !empty {
if self.items[0].state == AddHere && self.items.get(1).is_some() {
self.items[1].state = AddHere;
}
if let Err(e) = self.remove_item(0) { if let Err(e) = self.remove_item(0) {
dbg!(&e); self.dbg_items(); return Err(e); dbg!(&e); self.dbg_items(); return Err(e);
} }
// dbg!(&to_item.item, &self.items[ind].item); // dbg!(&to_item.item, &self.items[ind].item);
}else if empty {
return nothing_error;
}else { }else {
break; break;
} }
} }
}else { }else {
return Err(QueueError::EmptyQueue.into()); return Err("index out of bounds!".into());
} }
Ok(()) Ok(())
} }
pub fn swap(&mut self, a: usize, b: usize) { pub fn swap(&mut self, index1: usize, index2: usize) {}
self.items.swap(a, b)
}
pub fn move_item(&mut self, a: usize, b: usize) { pub fn move_item(&mut self, item: usize, to_index: usize) {}
let item = self.items[a].to_owned();
if a != b {
self.items.remove(a);
}
self.items.insert(b, item);
}
#[allow(clippy::should_implement_trait)] pub fn next() {}
pub fn next(&mut self, lib: Arc<RwLock<MusicLibrary>>) -> Result<OutQueue, Box<dyn Error>> {
if self.items.is_empty() {
if self.loop_ {
return Err(QueueError::EmptyQueue.into()); // TODO: add function to loop the queue
}else {
return Err(QueueError::EmptyQueue.into());
}
}
// TODO: add an algorithm to detect if the song should be skipped
let item = self.items[0].clone();
let uri: URI = match &self.items[1].item {
QueueItemType::Song(uuid) => {
// TODO: Refactor later for multiple URIs
match &lib.read().unwrap().query_uuid(uuid) {
Some(song) => song.0.location.clone(),
None => return Err("Uuid does not exist!".into()),
}
},
QueueItemType::Album { album, current, ..} => {
let (disc, track) = (current.0 as usize, current.1 as usize);
match album.track(disc, track) {
Some(track) => track.location.clone(),
None => return Err(format!("Track in Album {} at disc {} track {} does not exist!", album.title(), disc, track).into())
}
},
QueueItemType::Playlist { current, .. } => {
// TODO: Refactor later for multiple URIs
match &lib.read().unwrap().query_uuid(current) {
Some(song) => song.0.location.clone(),
None => return Err("Uuid does not exist!".into()),
}
},
_ => todo!()
};
if !self.player.is_paused() {
self.player.enqueue_next(&uri)?;
self.player.play()?
}
if self.items[0].state == QueueState::AddHere || !self.has_addhere() {
self.items[1].state = QueueState::AddHere;
}
self.played.push(item);
self.items.remove(0);
Ok(todo!())
}
pub fn prev() {} pub fn prev() {}
@ -347,42 +293,40 @@ impl<'a> Queue<'a> {
} }
Ok(()) Ok(())
} }
pub fn check_played(&mut self) {
while self.played.len() > 50 {
self.played.remove(0);
}
}
}
pub struct OutQueue {
}
pub enum OutQueueItem {
} }
#[test] #[test]
fn item_add_test() { fn item_add_test() {
let mut q = Queue::new().unwrap(); let mut q = Queue::new().unwrap();
dbg!(1);
for _ in 0..1 {
q.items.push(QueueItem { item: QueueItemType::Song(Uuid::new_v4()), state: QueueState::Played, source: QueueSource::File, by_human: false });
}
dbg!(2);
// q.clear();
dbg!(3);
for _ in 0..5 { for _ in 0..5 {
// dbg!("tick!"); // dbg!("tick!");
q.add_item(QueueItemType::Song(Uuid::new_v4()), PlayerLocation::Library, true); q.add_item(QueueItemType::Song(Uuid::new_v4()), QueueSource::Library, true).unwrap();
// dbg!(&q.items, &q.items.len()); // dbg!(&q.items, &q.items.len());
} }
dbg!(4);
dbg!(&q.items, &q.items.len());
// q.clear_played();
for _ in 0..1 { for _ in 0..1 {
q.remove_item(0).inspect_err(|e| println!("{e:?}")); q.remove_item(0).inspect_err(|e| println!("{e:?}"));
} }
for _ in 0..2 { // for _ in 0..2 {
q.items.push(QueueItem { item: QueueItemType::Test, state: QueueState::NoState, source: PlayerLocation::Library, by_human: false }); // q.items.push(QueueItem { item: QueueItemType::Test, state: QueueState::NoState, source: QueueSource::Library, by_human: false });
} // }
dbg!(5); // dbg!(5);
q.add_item_next(QueueItemType::Test, PlayerLocation::Test); // q.add_item_next(QueueItemType::Test, QueueSource::File);
dbg!(6); // dbg!(6);
dbg!(&q.items, &q.items.len()); dbg!(&q.items, &q.items.len());
} }
@ -391,23 +335,25 @@ fn item_add_test() {
fn test_() { fn test_() {
let mut q = Queue::new().unwrap(); let mut q = Queue::new().unwrap();
for _ in 0..400 { for _ in 0..400 {
q.items.push(QueueItem { item: QueueItemType::Song(Uuid::new_v4()), state: QueueState::NoState, source: PlayerLocation::File, by_human: false }); q.items.push(QueueItem { item: QueueItemType::Song(Uuid::new_v4()), state: QueueState::Played, source: QueueSource::File, by_human: false });
} }
for _ in 0..50000 { for _ in 0..50000 {
q.add_item(QueueItemType::Song(Uuid::new_v4()), PlayerLocation::Library, true); q.add_item(QueueItemType::Song(Uuid::new_v4()), QueueSource::Library, true).unwrap();
} }
// q.add_item_next(QueueItemType::Test, PlayerLocation::File); q.add_item_next(QueueItemType::Test, QueueSource::File);
// dbg!(&q.items, &q.items.len()); dbg!(&q.items, &q.items.len());
} }
#[test] #[test]
fn move_test() { fn move_test() {
let mut q = Queue::new().unwrap(); let mut q = Queue::new().unwrap();
for _ in 0..1 {
q.items.push(QueueItem { item: QueueItemType::Song(Uuid::new_v4()), state: QueueState::Played, source: QueueSource::File, by_human: false });
}
for _ in 0..5 { for _ in 0..5 {
q.add_item(QueueItemType::Song(Uuid::new_v4()), PlayerLocation::Library, true); q.add_item(QueueItemType::Song(Uuid::new_v4()), QueueSource::Library, true).unwrap();
} }
// q.add_item(QueueItemType::Test, QueueSource::Library, true).unwrap(); // q.add_item(QueueItemType::Test, QueueSource::Library, true).unwrap();
dbg!(&q.items, &q.items.len()); dbg!(&q.items, &q.items.len());

View file

@ -5,20 +5,20 @@ use crate::config::config::Config;
// Various std things // Various std things
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::error::Error; use std::error::Error;
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};
use glib::filename_to_uri; use glib::filename_to_uri;
use image::guess_format;
use lofty::{AudioFile, ItemKey, ItemValue, ParseOptions, Probe, TagType, TaggedFileExt}; use lofty::{AudioFile, ItemKey, ItemValue, ParseOptions, Probe, TagType, TaggedFileExt};
use rcue::parser::parse_from_file; use rcue::parser::parse_from_file;
use uuid::Uuid; use uuid::Uuid;
use std::fs::{self, File}; use std::fs;
use tempfile::TempDir; use tempfile::TempDir;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use walkdir::WalkDir; use walkdir::WalkDir;
use image::ImageFormat::*;
// Time // Time
use chrono::{serde::ts_milliseconds_option, DateTime, Utc}; use chrono::{serde::ts_milliseconds_option, DateTime, Utc};
@ -160,6 +160,11 @@ pub struct Song {
pub tags: BTreeMap<Tag, String>, pub tags: BTreeMap<Tag, String>,
} }
#[test]
fn get_art_test() {
let s = Song::from_file(Path::new("F:\\Music\\Mp3\\ななひら\\Colory Starry\\05 - Fly Away!.mp3")).unwrap();
s.open_album_art(0).inspect_err(|e| println!("{e:?}")).unwrap();
}
impl Song { impl Song {
/// Get a tag's value /// Get a tag's value
@ -426,7 +431,7 @@ impl Song {
Ok(tracks) Ok(tracks)
} }
pub fn open_album_art(&self, index: usize, temp_dir: &TempDir) -> Result<(), Box<dyn Error>> { pub fn open_album_art(&self, index: usize) -> Result<(), Box<dyn Error>> {
use opener::open; use opener::open;
use urlencoding::decode; use urlencoding::decode;
@ -446,21 +451,9 @@ 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)] let uri = urlencoding::decode(self.location.as_uri().strip_prefix("file://").unwrap())?.into_owned();
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)] let tag = match Probe::open(uri).unwrap().options(normal_options).read() {
let uri = urlencoding::decode(
match self.location.as_uri().strip_prefix("file://") {
Some(str) => str,
None => return Err("invalid path.. again?".into())
})?.into_owned();
let tag = match Probe::open(uri)?.options(normal_options).read() {
Ok(file) => { Ok(file) => {
tagged_file = file; tagged_file = file;
@ -478,16 +471,26 @@ impl Song {
}; };
let data = tag.pictures()[index].data(); let data = tag.pictures()[index].data();
let format = dbg!(guess_format(data)?);
let img = image::load_from_memory(data)?;
let fmt = FileFormat::from_bytes(data); let tmp_dir = TempDir::new()?;
let file_path = temp_dir.path().join(format!("{}_{index}.{}", self.uuid, fmt.extension())); let fmt = match format {
Jpeg => "jpeg",
Png => "png",
_ => todo!(),
};
File::create(&file_path)?.write_all(data)?; let file_path = tmp_dir.path().join(format!("{}.{fmt}", self.uuid));
open(&file_path).unwrap();
img.save_with_format(&file_path, format).unwrap();
file_path file_path
}, },
}; };
dbg!(open(dbg!(uri))?); dbg!(open(uri)?);
Ok(()) Ok(())
} }
} }
@ -555,14 +558,6 @@ impl URI {
path_str.to_string() path_str.to_string()
} }
pub fn as_path(&self) -> Result<&PathBuf, Box<dyn Error>> {
if let Self::Local(path) = self {
Ok(path)
}else {
Err("This URI is not local!".into())
}
}
pub fn exists(&self) -> Result<bool, std::io::Error> { pub fn exists(&self) -> Result<bool, std::io::Error> {
match self { match self {
URI::Local(loc) => loc.try_exists(), URI::Local(loc) => loc.try_exists(),
@ -1137,25 +1132,3 @@ impl MusicLibrary {
Ok(albums) Ok(albums)
} }
} }
#[cfg(test)]
mod test {
use std::{path::Path, thread::sleep, time::{Duration, Instant}};
use tempfile::TempDir;
use super::Song;
#[test]
fn get_art_test() {
let s = Song::from_file(Path::new(".\\test-config\\music\\Snail_s House - Hot Milk.mp3")).unwrap();
let dir = &TempDir::new().unwrap();
let now = Instant::now();
_ = s.open_album_art(0, dir).inspect_err(|e| println!("{e:?}"));
println!("{}ms", now.elapsed().as_millis() );
sleep(Duration::from_secs(1));
}
}