Skip to content

Commit

Permalink
feature: add option to use media_channel in mediaArtworkOverrides
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Mar 17, 2024
1 parent ea163cc commit 5f38d5d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ 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
- 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
imageUrl: https://cdn-icons-png.flaticon.com/512/651/651758.png
customSources: # Main use case is probably to set tv media player to play TV sound
Expand Down
4 changes: 4 additions & 0 deletions src/editor/artwork-override-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class ArtworkOverrideEditor extends BaseEditor {
name: 'mediaContentIdEquals',
type: 'string',
},
{
name: 'mediaChannelEquals',
type: 'string',
},
{
name: 'imageUrl',
type: 'string',
Expand Down
6 changes: 5 additions & 1 deletion src/editor/artwork-overrides-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class ArtworkOverridesEditor extends BaseEditor {
<ha-control-button-group>
${items?.map((pg, index) => {
const itemName =
pg.mediaTitleEquals || pg.mediaContentIdEquals || (pg.ifMissing && 'if missing') || index;
pg.mediaTitleEquals ||
pg.mediaContentIdEquals ||
pg.mediaChannelEquals ||
(pg.ifMissing && 'if missing') ||
index;
return html`
<ha-control-button @click=${() => (this.editItem = index)}>
${itemName}<ha-svg-icon .path=${mdiPen} label="Edit"></ha-svg-icon>
Expand Down
3 changes: 2 additions & 1 deletion src/sections/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ export class Player extends LitElement {

private getArtworkImage() {
const prefix = this.config.artworkHostname || '';
const { media_title, media_content_id, entity_picture } = this.activePlayer.attributes;
const { media_title, 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_channel && media_channel === value.mediaChannelEquals) ||
(media_content_id && media_content_id === value.mediaContentIdEquals),
);
if (!override) {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface MediaArtworkOverride {
ifMissing?: boolean;
mediaTitleEquals?: string;
mediaContentIdEquals?: string;
mediaChannelEquals?: string;
imageUrl?: string;
sizePercentage?: number;
}
Expand Down

0 comments on commit 5f38d5d

Please sign in to comment.