Skip to content

Commit

Permalink
fix: improve fetching list of favorites by allowing media_content_typ…
Browse files Browse the repository at this point in the history
…e/id/title
  • Loading branch information
punxaphil committed Jan 2, 2025
1 parent 351d570 commit 20214e9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/services/media-browse-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,17 @@ export default class MediaBrowseService {

private async getFavoritesForPlayer(player: MediaPlayer) {
try {
const favoritesRoot = await this.hassService.browseMedia(player, 'favorites', '');
const root = await this.hassService.browseMedia(player);
const favorites = root.children?.find(
(child) =>
child.media_content_type?.toLowerCase() === 'favorites' ||
child.media_content_id?.toLowerCase() === 'favorites' ||
child.title.toLowerCase() === 'favorites',
);
if (!favorites) {
return [];
}
const favoritesRoot = await this.hassService.browseMedia(player, favorites.media_content_type, '');
const favoriteTypesPromise = favoritesRoot.children?.map((favoriteItem) =>
this.hassService.browseMedia(player, favoriteItem.media_content_type, favoriteItem.media_content_id),
);
Expand Down

0 comments on commit 20214e9

Please sign in to comment.