Skip to content

Commit

Permalink
Feature: Adding mediaArtistEquals and mediaAlbumNameEquals options to…
Browse files Browse the repository at this point in the history
… mediaArtworkOverrides (#349)
  • Loading branch information
gminco authored Apr 11, 2024
1 parent 8ab43d6 commit 02b7e13
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/editor/artwork-override-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ class ArtworkOverrideEditor extends BaseEditor {
name: 'mediaTitleEquals',
type: 'string',
},
{
name: 'mediaArtistEquals',
type: 'string',
},
{
name: 'mediaAlbumNameEquals',
type: 'string',
},
{
name: 'mediaContentIdEquals',
type: 'string',
Expand Down
2 changes: 2 additions & 0 deletions src/editor/artwork-overrides-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') ||
Expand Down
4 changes: 3 additions & 1 deletion src/sections/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ 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;
if (overrides) {
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),
);
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 02b7e13

Please sign in to comment.