Fix: Special libraries not working with cast through Plex

pull/30/head 1.5.1
Juraj Nyíri 3 years ago
parent 6f7da0e80f
commit 33cf97aec5

@ -18830,7 +18830,7 @@ class Plex {
} }
class PlayController { class PlayController {
constructor(hass, plex, entity, runBefore, runAfter, libraryName) { constructor(hass, plex, entity, runBefore, runAfter) {
this.plexPlayerEntity = ''; this.plexPlayerEntity = '';
this.runBefore = false; this.runBefore = false;
this.runAfter = false; this.runAfter = false;
@ -18913,14 +18913,14 @@ class PlayController {
case 'movie': case 'movie':
this.playViaCastPlex(entity.value, 'movie', `plex://${JSON.stringify({ this.playViaCastPlex(entity.value, 'movie', `plex://${JSON.stringify({
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
library_name: this.libraryName, library_name: data.librarySectionTitle,
title: data.title title: data.title
})}`); })}`);
break; break;
case 'episode': case 'episode':
this.playViaCastPlex(entity.value, 'EPISODE', `plex://${JSON.stringify({ this.playViaCastPlex(entity.value, 'EPISODE', `plex://${JSON.stringify({
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
library_name: this.libraryName, library_name: data.librarySectionTitle,
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
show_name: data.grandparentTitle, show_name: data.grandparentTitle,
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
@ -19229,7 +19229,6 @@ class PlayController {
this.hass = hass; this.hass = hass;
this.plex = plex; this.plex = plex;
this.entity = entity; this.entity = entity;
this.libraryName = libraryName;
if (!lodash.isEmpty(runBefore) && this.hass.states[runBefore]) { if (!lodash.isEmpty(runBefore) && this.hass.states[runBefore]) {
this.runBefore = runBefore.split('.'); this.runBefore = runBefore.split('.');
} }
@ -20308,7 +20307,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
try { try {
if (this.plex) { if (this.plex) {
if (this.hassObj) { if (this.hassObj) {
this.playController = new PlayController(this.hassObj, this.plex, entity, this.runBefore, this.runAfter, this.config.libraryName); this.playController = new PlayController(this.hassObj, this.plex, entity, this.runBefore, this.runAfter);
if (this.playController) { if (this.playController) {
await this.playController.init(); await this.playController.init();
} }

@ -16,26 +16,16 @@ class PlayController {
plex: Plex; plex: Plex;
libraryName: string;
runBefore: Array<string> | false = false; runBefore: Array<string> | false = false;
runAfter: Array<string> | false = false; runAfter: Array<string> | false = false;
supported: any = supported; supported: any = supported;
constructor( constructor(hass: HomeAssistant, plex: Plex, entity: Record<string, any>, runBefore: string, runAfter: string) {
hass: HomeAssistant,
plex: Plex,
entity: Record<string, any>,
runBefore: string,
runAfter: string,
libraryName: string
) {
this.hass = hass; this.hass = hass;
this.plex = plex; this.plex = plex;
this.entity = entity; this.entity = entity;
this.libraryName = libraryName;
if (!_.isEmpty(runBefore) && this.hass.states[runBefore]) { if (!_.isEmpty(runBefore) && this.hass.states[runBefore]) {
this.runBefore = runBefore.split('.'); this.runBefore = runBefore.split('.');
} }
@ -129,7 +119,7 @@ class PlayController {
'movie', 'movie',
`plex://${JSON.stringify({ `plex://${JSON.stringify({
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
library_name: this.libraryName, library_name: data.librarySectionTitle,
title: data.title title: data.title
})}` })}`
); );
@ -140,7 +130,7 @@ class PlayController {
'EPISODE', 'EPISODE',
`plex://${JSON.stringify({ `plex://${JSON.stringify({
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
library_name: this.libraryName, library_name: data.librarySectionTitle,
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
show_name: data.grandparentTitle, show_name: data.grandparentTitle,
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase

@ -269,14 +269,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
try { try {
if (this.plex) { if (this.plex) {
if (this.hassObj) { if (this.hassObj) {
this.playController = new PlayController( this.playController = new PlayController(this.hassObj, this.plex, entity, this.runBefore, this.runAfter);
this.hassObj,
this.plex,
entity,
this.runBefore,
this.runAfter,
this.config.libraryName
);
if (this.playController) { if (this.playController) {
await this.playController.init(); await this.playController.init();
} }

Loading…
Cancel
Save