diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index 238ece4..bc09a4f 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -17207,7 +17207,7 @@ const supported = { kodi: ['movie', 'episode', 'epg'], androidtv: ['movie', 'show', 'season', 'episode', 'clip', 'track', 'artist', 'album'], plexPlayer: ['movie', 'show', 'season', 'episode', 'clip', 'track', 'artist', 'album'], - cast: ['movie', 'episode'] + cast: ['movie', 'episode', 'artist', 'album', 'track'] }; var bind = function bind(fn, thisArg) { @@ -19450,6 +19450,39 @@ class PlayController { : processData.librarySectionTitle; try { switch (processData.type) { + case 'artist': + await this.playViaCastPlex(entity.value, 'MUSIC', `plex://${JSON.stringify({ + // eslint-disable-next-line @typescript-eslint/camelcase + library_name: libraryName, + // eslint-disable-next-line @typescript-eslint/camelcase + artist_name: processData.title, + shuffle: 1 + })}`); + break; + case 'album': + await this.playViaCastPlex(entity.value, 'MUSIC', `plex://${JSON.stringify({ + // eslint-disable-next-line @typescript-eslint/camelcase + library_name: libraryName, + // eslint-disable-next-line @typescript-eslint/camelcase + artist_name: processData.parentTitle, + // eslint-disable-next-line @typescript-eslint/camelcase + album_name: processData.title, + shuffle: 1 + })}`); + break; + case 'track': + await this.playViaCastPlex(entity.value, 'MUSIC', `plex://${JSON.stringify({ + // eslint-disable-next-line @typescript-eslint/camelcase + library_name: libraryName, + // eslint-disable-next-line @typescript-eslint/camelcase + artist_name: processData.grandparentTitle, + // eslint-disable-next-line @typescript-eslint/camelcase + album_name: processData.parentTitle, + // eslint-disable-next-line @typescript-eslint/camelcase + track_name: processData.title, + shuffle: 1 + })}`); + break; case 'movie': await this.playViaCastPlex(entity.value, 'movie', `plex://${JSON.stringify({ // eslint-disable-next-line @typescript-eslint/camelcase @@ -19470,7 +19503,12 @@ class PlayController { })}`); break; default: - this.playViaCast(entity.value, processData.Media[0].Part[0].key); + if (!lodash.isNil(processData.Media)) { + this.playViaCast(entity.value, processData.Media[0].Part[0].key); + } + else { + console.error('Casting this content directly is not possible. Consider using Plex integration.'); + } } } catch (err) { diff --git a/src/const.ts b/src/const.ts index a30c2d5..0357f21 100644 --- a/src/const.ts +++ b/src/const.ts @@ -12,7 +12,7 @@ const supported: any = { kodi: ['movie', 'episode', 'epg'], androidtv: ['movie', 'show', 'season', 'episode', 'clip', 'track', 'artist', 'album'], plexPlayer: ['movie', 'show', 'season', 'episode', 'clip', 'track', 'artist', 'album'], - cast: ['movie', 'episode'] + cast: ['movie', 'episode', 'artist', 'album', 'track'] }; const LOREM_IPSUM = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec semper risus vitae aliquet interdum. Nulla facilisi. Pellentesque viverra sagittis lorem eget aliquet. Cras vehicula, purus vel consectetur mattis, ipsum arcu ullamcorper mi, id viverra purus ex eu dolor. Integer vehicula lacinia sem convallis iaculis. Nulla fermentum erat interdum, efficitur felis in, mollis neque. Vivamus luctus metus eget nisl pellentesque, placerat elementum magna eleifend. diff --git a/src/modules/PlayController.ts b/src/modules/PlayController.ts index ca9017d..890f271 100644 --- a/src/modules/PlayController.ts +++ b/src/modules/PlayController.ts @@ -173,6 +173,51 @@ class PlayController { : processData.librarySectionTitle; try { switch (processData.type) { + case 'artist': + await this.playViaCastPlex( + entity.value, + 'MUSIC', + `plex://${JSON.stringify({ + // eslint-disable-next-line @typescript-eslint/camelcase + library_name: libraryName, + // eslint-disable-next-line @typescript-eslint/camelcase + artist_name: processData.title, + shuffle: 1 + })}` + ); + break; + case 'album': + await this.playViaCastPlex( + entity.value, + 'MUSIC', + `plex://${JSON.stringify({ + // eslint-disable-next-line @typescript-eslint/camelcase + library_name: libraryName, + // eslint-disable-next-line @typescript-eslint/camelcase + artist_name: processData.parentTitle, + // eslint-disable-next-line @typescript-eslint/camelcase + album_name: processData.title, + shuffle: 1 + })}` + ); + break; + case 'track': + await this.playViaCastPlex( + entity.value, + 'MUSIC', + `plex://${JSON.stringify({ + // eslint-disable-next-line @typescript-eslint/camelcase + library_name: libraryName, + // eslint-disable-next-line @typescript-eslint/camelcase + artist_name: processData.grandparentTitle, + // eslint-disable-next-line @typescript-eslint/camelcase + album_name: processData.parentTitle, + // eslint-disable-next-line @typescript-eslint/camelcase + track_name: processData.title, + shuffle: 1 + })}` + ); + break; case 'movie': await this.playViaCastPlex( entity.value, @@ -201,7 +246,11 @@ class PlayController { ); break; default: - this.playViaCast(entity.value, processData.Media[0].Part[0].key); + if (!_.isNil(processData.Media)) { + this.playViaCast(entity.value, processData.Media[0].Part[0].key); + } else { + console.error('Casting this content directly is not possible. Consider using Plex integration.'); + } } } catch (err) { console.log(err);