Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding mediaArtistEquals and mediaAlbumNameEquals options to mediaArtworkOverrides #349

Merged
merged 7 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) ||
punxaphil marked this conversation as resolved.
Show resolved Hide resolved
(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
Loading