|
|
@ -112,36 +112,41 @@ class PlayController {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'cast':
|
|
|
|
case 'cast':
|
|
|
|
if (this.hass.services.plex) {
|
|
|
|
if (this.hass.services.plex) {
|
|
|
|
switch (data.type) {
|
|
|
|
try {
|
|
|
|
case 'movie':
|
|
|
|
switch (data.type) {
|
|
|
|
this.playViaCastPlex(
|
|
|
|
case 'movie':
|
|
|
|
entity.value,
|
|
|
|
await this.playViaCastPlex(
|
|
|
|
'movie',
|
|
|
|
entity.value,
|
|
|
|
`plex://${JSON.stringify({
|
|
|
|
'movie',
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
`plex://${JSON.stringify({
|
|
|
|
library_name: data.librarySectionTitle,
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
title: data.title
|
|
|
|
library_name: data.librarySectionTitle,
|
|
|
|
})}`
|
|
|
|
title: data.title
|
|
|
|
);
|
|
|
|
})}`
|
|
|
|
break;
|
|
|
|
);
|
|
|
|
case 'episode':
|
|
|
|
break;
|
|
|
|
this.playViaCastPlex(
|
|
|
|
case 'episode':
|
|
|
|
entity.value,
|
|
|
|
await this.playViaCastPlex(
|
|
|
|
'EPISODE',
|
|
|
|
entity.value,
|
|
|
|
`plex://${JSON.stringify({
|
|
|
|
'EPISODE',
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
`plex://${JSON.stringify({
|
|
|
|
library_name: data.librarySectionTitle,
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
library_name: data.librarySectionTitle,
|
|
|
|
show_name: data.grandparentTitle,
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
show_name: data.grandparentTitle,
|
|
|
|
season_number: data.parentIndex,
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
season_number: data.parentIndex,
|
|
|
|
episode_number: data.index
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
})}`
|
|
|
|
episode_number: data.index
|
|
|
|
);
|
|
|
|
})}`
|
|
|
|
break;
|
|
|
|
);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
this.playViaCast(entity.value, data.Media[0].Part[0].key);
|
|
|
|
default:
|
|
|
|
|
|
|
|
this.playViaCast(entity.value, data.Media[0].Part[0].key);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
console.log(err);
|
|
|
|
|
|
|
|
this.playViaCast(entity.value, data.Media[0].Part[0].key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.playViaCast(entity.value, data.Media[0].Part[0].key);
|
|
|
|
this.playViaCast(entity.value, data.Media[0].Part[0].key);
|
|
|
@ -287,8 +292,8 @@ class PlayController {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private playViaCastPlex = (entityName: string, contentType: string, mediaLink: string): void => {
|
|
|
|
private playViaCastPlex = (entityName: string, contentType: string, mediaLink: string): Promise<void> => {
|
|
|
|
this.hass.callService('media_player', 'play_media', {
|
|
|
|
return this.hass.callService('media_player', 'play_media', {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
entity_id: entityName,
|
|
|
|
entity_id: entityName,
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|