From 055e0d8f381916ee44eca6f38c0d2e29d6ea9ece Mon Sep 17 00:00:00 2001 From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:19:26 +0200 Subject: [PATCH] add release date to AudioItem - preparation for MPRIS support - now that the data is there, also yield from player_event_handler --- metadata/src/audio/item.rs | 4 ++++ src/player_event_handler.rs | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/metadata/src/audio/item.rs b/metadata/src/audio/item.rs index b2789008..656d07cd 100644 --- a/metadata/src/audio/item.rs +++ b/metadata/src/audio/item.rs @@ -47,6 +47,7 @@ pub enum UniqueFields { Track { artists: ArtistsWithRole, album: String, + album_date: Date, album_artists: Vec, popularity: u8, number: u32, @@ -83,6 +84,8 @@ impl AudioItem { let uri = track_id.to_uri()?; let album = track.album.name; + let album_date = track.album.date; + let album_artists = track .album .artists @@ -116,6 +119,7 @@ impl AudioItem { let unique_fields = UniqueFields::Track { artists: track.artists_with_role, album, + album_date, album_artists, popularity, number, diff --git a/src/player_event_handler.rs b/src/player_event_handler.rs index 3d0a47df..400241ce 100644 --- a/src/player_event_handler.rs +++ b/src/player_event_handler.rs @@ -54,6 +54,7 @@ impl EventHandler { UniqueFields::Track { artists, album, + album_date, album_artists, popularity, number, @@ -72,6 +73,10 @@ impl EventHandler { env_vars .insert("ALBUM_ARTISTS", album_artists.join("\n")); 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("NUMBER", number.to_string()); env_vars.insert("DISC_NUMBER", disc_number.to_string());