Skip to content

Commit

Permalink
Merge pull request #6 from pathofleastresistor:album-songs-playlist
Browse files Browse the repository at this point in the history
Treat album songs as a playlist
  • Loading branch information
pathofleastresistor authored Jan 2, 2024
2 parents 0ea126a + 9a55101 commit c912a63
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/elements/polr-ytube-playing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ export class PoLRYTubePlaying extends LitElement {
return html`
<polr-ytube-list
.hass=${this._hass}
.entity=${this._entity}></polr-ytube-list>
.entity=${this._entity}
></polr-ytube-list>
`;
}

async _getCurrentlyPlayingItems() {
let media_content_type = this._entity?.attributes?.media_content_type;
let _media_type = this._entity?.attributes?._media_type;
let results;
let results: any = {};
if (this._entity?.state == "idle") return;

try {
Expand All @@ -42,13 +43,20 @@ export class PoLRYTubePlaying extends LitElement {
});
}

// Treat songs as a playlist
if (["album"].includes(_media_type)) {
results = await this._hass.callWS({
type: "media_player/browse_media",
entity_id: this._entity?.entity_id,
media_content_type: "album_of_track",
media_content_id: "1",
});

results?.children?.map((r: any, index: number) => {
r["media_content_type"] = "PLAYLIST_GOTO_TRACK";
r["media_content_id"] = index + 1;
return r;
});
}

if (this._entity?.attributes?.media_title == "loading...") {
Expand Down

0 comments on commit c912a63

Please sign in to comment.