add release date to AudioItem

- preparation for MPRIS support
- now that the data is there, also yield from player_event_handler
This commit is contained in:
wisp3rwind 2024-09-17 15:19:26 +02:00
parent 949a886f62
commit 055e0d8f38
2 changed files with 9 additions and 0 deletions

View file

@ -47,6 +47,7 @@ pub enum UniqueFields {
Track { Track {
artists: ArtistsWithRole, artists: ArtistsWithRole,
album: String, album: String,
album_date: Date,
album_artists: Vec<String>, album_artists: Vec<String>,
popularity: u8, popularity: u8,
number: u32, number: u32,
@ -83,6 +84,8 @@ impl AudioItem {
let uri = track_id.to_uri()?; let uri = track_id.to_uri()?;
let album = track.album.name; let album = track.album.name;
let album_date = track.album.date;
let album_artists = track let album_artists = track
.album .album
.artists .artists
@ -116,6 +119,7 @@ impl AudioItem {
let unique_fields = UniqueFields::Track { let unique_fields = UniqueFields::Track {
artists: track.artists_with_role, artists: track.artists_with_role,
album, album,
album_date,
album_artists, album_artists,
popularity, popularity,
number, number,

View file

@ -54,6 +54,7 @@ impl EventHandler {
UniqueFields::Track { UniqueFields::Track {
artists, artists,
album, album,
album_date,
album_artists, album_artists,
popularity, popularity,
number, number,
@ -72,6 +73,10 @@ impl EventHandler {
env_vars env_vars
.insert("ALBUM_ARTISTS", album_artists.join("\n")); .insert("ALBUM_ARTISTS", album_artists.join("\n"));
env_vars.insert("ALBUM", album); env_vars.insert("ALBUM", album);
env_vars.insert(
"ALBUM_DATE",
album_date.unix_timestamp().to_string(),
);
env_vars.insert("POPULARITY", popularity.to_string()); env_vars.insert("POPULARITY", popularity.to_string());
env_vars.insert("NUMBER", number.to_string()); env_vars.insert("NUMBER", number.to_string());
env_vars.insert("DISC_NUMBER", disc_number.to_string()); env_vars.insert("DISC_NUMBER", disc_number.to_string());