From 33cf97aec51ef0bad5a2336cf2ac03565c0b6c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Sat, 10 Jul 2021 23:14:16 +0200 Subject: [PATCH] Fix: Special libraries not working with cast through Plex --- dist/plex-meets-homeassistant.js | 9 ++++----- src/modules/PlayController.ts | 16 +++------------- src/plex-meets-homeassistant.ts | 9 +-------- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index 909cd31..d4a2f41 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -18830,7 +18830,7 @@ class Plex { } class PlayController { - constructor(hass, plex, entity, runBefore, runAfter, libraryName) { + constructor(hass, plex, entity, runBefore, runAfter) { this.plexPlayerEntity = ''; this.runBefore = false; this.runAfter = false; @@ -18913,14 +18913,14 @@ class PlayController { case 'movie': this.playViaCastPlex(entity.value, 'movie', `plex://${JSON.stringify({ // eslint-disable-next-line @typescript-eslint/camelcase - library_name: this.libraryName, + library_name: data.librarySectionTitle, title: data.title })}`); break; case 'episode': this.playViaCastPlex(entity.value, 'EPISODE', `plex://${JSON.stringify({ // eslint-disable-next-line @typescript-eslint/camelcase - library_name: this.libraryName, + library_name: data.librarySectionTitle, // eslint-disable-next-line @typescript-eslint/camelcase show_name: data.grandparentTitle, // eslint-disable-next-line @typescript-eslint/camelcase @@ -19229,7 +19229,6 @@ class PlayController { this.hass = hass; this.plex = plex; this.entity = entity; - this.libraryName = libraryName; if (!lodash.isEmpty(runBefore) && this.hass.states[runBefore]) { this.runBefore = runBefore.split('.'); } @@ -20308,7 +20307,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { try { if (this.plex) { 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) { await this.playController.init(); } diff --git a/src/modules/PlayController.ts b/src/modules/PlayController.ts index b715b22..eba5f2b 100644 --- a/src/modules/PlayController.ts +++ b/src/modules/PlayController.ts @@ -16,26 +16,16 @@ class PlayController { plex: Plex; - libraryName: string; - runBefore: Array | false = false; runAfter: Array | false = false; supported: any = supported; - constructor( - hass: HomeAssistant, - plex: Plex, - entity: Record, - runBefore: string, - runAfter: string, - libraryName: string - ) { + constructor(hass: HomeAssistant, plex: Plex, entity: Record, runBefore: string, runAfter: string) { this.hass = hass; this.plex = plex; this.entity = entity; - this.libraryName = libraryName; if (!_.isEmpty(runBefore) && this.hass.states[runBefore]) { this.runBefore = runBefore.split('.'); } @@ -129,7 +119,7 @@ class PlayController { 'movie', `plex://${JSON.stringify({ // eslint-disable-next-line @typescript-eslint/camelcase - library_name: this.libraryName, + library_name: data.librarySectionTitle, title: data.title })}` ); @@ -140,7 +130,7 @@ class PlayController { 'EPISODE', `plex://${JSON.stringify({ // eslint-disable-next-line @typescript-eslint/camelcase - library_name: this.libraryName, + library_name: data.librarySectionTitle, // eslint-disable-next-line @typescript-eslint/camelcase show_name: data.grandparentTitle, // eslint-disable-next-line @typescript-eslint/camelcase diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 0e55e96..44276e3 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -269,14 +269,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { try { if (this.plex) { 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) { await this.playController.init(); }