From 02b7e13ec621884c6a26bf0eda9cdb37a36b7179 Mon Sep 17 00:00:00 2001 From: German <96509060+gminco@users.noreply.github.com> Date: Thu, 11 Apr 2024 16:09:55 -0400 Subject: [PATCH] Feature: Adding mediaArtistEquals and mediaAlbumNameEquals options to mediaArtworkOverrides (#349) --- README.md | 6 ++++++ src/editor/artwork-override-editor.ts | 8 ++++++++ src/editor/artwork-overrides-editor.ts | 2 ++ src/sections/player.ts | 4 +++- src/types.ts | 2 ++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 58422cca..fc58580d 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,12 @@ mediaArtworkOverrides: # Show your own selected artwork if certain rules match - mediaTitleEquals: p4malmo-aac-192 imageUrl: >- https://mytuner.global.ssl.fastly.net/media/tvos_radios/2BDTPrpMbn_cTdteqo.jpg + - mediaArtistEquals: Metallica + imageUrl: >- + https://mytuner.global.ssl.fastly.net/media/tvos_radios/2BDTPrpMbn_cTdteqo.jpg + - mediaAlbumNameEquals: "Master of Puppets" + imageUrl: >- + https://mytuner.global.ssl.fastly.net/media/tvos_radios/2BDTPrpMbn_cTdteqo.jpg - mediaChannelEquals: "Sky Radio Smooth Hits" imageUrl: https://cdn-icons-png.flaticon.com/512/4108/4108794.png - ifMissing: true # ifMissing will only be used if none of the "Equals" overrides above resulted in a match diff --git a/src/editor/artwork-override-editor.ts b/src/editor/artwork-override-editor.ts index 87d71f08..f5740ccf 100644 --- a/src/editor/artwork-override-editor.ts +++ b/src/editor/artwork-override-editor.ts @@ -14,6 +14,14 @@ class ArtworkOverrideEditor extends BaseEditor { name: 'mediaTitleEquals', type: 'string', }, + { + name: 'mediaArtistEquals', + type: 'string', + }, + { + name: 'mediaAlbumNameEquals', + type: 'string', + }, { name: 'mediaContentIdEquals', type: 'string', diff --git a/src/editor/artwork-overrides-editor.ts b/src/editor/artwork-overrides-editor.ts index b52f854c..66019833 100644 --- a/src/editor/artwork-overrides-editor.ts +++ b/src/editor/artwork-overrides-editor.ts @@ -23,6 +23,8 @@ class ArtworkOverridesEditor extends BaseEditor { ${items?.map((pg, index) => { const itemName = pg.mediaTitleEquals || + pg.mediaArtistEquals || + pg.mediaAlbumNameEquals || pg.mediaContentIdEquals || pg.mediaChannelEquals || (pg.ifMissing && 'if missing') || diff --git a/src/sections/player.ts b/src/sections/player.ts index 5160fe6a..a14b218e 100755 --- a/src/sections/player.ts +++ b/src/sections/player.ts @@ -60,7 +60,7 @@ export class Player extends LitElement { private getArtworkImage() { const prefix = this.config.artworkHostname || ''; - const { media_title, media_content_id, media_channel, entity_picture } = this.activePlayer.attributes; + const { media_title, media_artist, media_album_name, media_content_id, media_channel, entity_picture } = this.activePlayer.attributes; let entityImage = entity_picture ? prefix + entity_picture : entity_picture; let sizePercentage = undefined; const overrides = this.config.mediaArtworkOverrides; @@ -68,6 +68,8 @@ export class Player extends LitElement { let override = overrides.find( (value) => (media_title && media_title === value.mediaTitleEquals) || + (media_artist && media_artist === value.mediaArtistEquals) || + (media_album_name && media_album_name === value.mediaAlbumNameEquals) || (media_channel && media_channel === value.mediaChannelEquals) || (media_content_id && media_content_id === value.mediaContentIdEquals), ); diff --git a/src/types.ts b/src/types.ts index 99a6297a..90f10046 100644 --- a/src/types.ts +++ b/src/types.ts @@ -67,6 +67,8 @@ export interface CardConfig extends LovelaceCardConfig { export interface MediaArtworkOverride { ifMissing?: boolean; mediaTitleEquals?: string; + mediaArtistEquals?: string; + mediaAlbumNameEquals?: string; mediaContentIdEquals?: string; mediaChannelEquals?: string; imageUrl?: string;