made a few minor changes

This commit is contained in:
MrDulfin 2024-05-07 18:28:03 -04:00
parent ab529f4c9b
commit 94e6c25219
4 changed files with 13 additions and 4 deletions

View file

@ -38,3 +38,4 @@ deunicode = "1.4.2"
opener = { version = "0.7.0", features = ["reveal"] }
tempfile = "3.10.1"
listenbrainz = "0.7.0"
discord-rpc-client = "0.4.0"

View file

@ -3,6 +3,7 @@ use std::{
error::Error,
};
use discord_rpc_client::Client;
use listenbrainz::ListenBrainz;
use uuid::Uuid;
@ -65,6 +66,13 @@ impl Controller {
client.listen(artist, track, release)?;
Ok(())
}
pub fn discord_song_change(client: &mut Client,song: Song) {
client.set_activity(|a| {
a.state(format!("Listening to {}", song.get_tag(&Tag::Title).unwrap()))
.into()
});
}
}
#[cfg(test)]

View file

@ -66,7 +66,7 @@ impl QueueItemType<'_> {
if !shuffled {
Some(album.track(*disc as usize, *index as usize).unwrap().location.clone())
}else {
todo!()
todo!() //what to do for non shuffled album
}
},
ExternalSong(uri) => { Some(uri.clone()) },

View file

@ -25,12 +25,12 @@ pub(super) fn normalize(input_string: &str) -> String {
/// Write any data structure which implements [serde::Serialize]
/// out to a [bincode] encoded file compressed using [snap]
pub(super) fn write_file<T: serde::Serialize>(
pub(super) fn write_file<T: serde::Serialize, U: std::convert::AsRef<Path>+std::convert::AsRef<std::ffi::OsStr>+Clone>(
library: T,
path: PathBuf,
path: U,
) -> Result<(), Box<dyn Error>> {
// Create a temporary name for writing out
let mut writer_name = path.clone();
let mut writer_name = PathBuf::from(&path);
writer_name.set_extension("tmp");
// Create a new BufWriter on the file and a snap frame encoder