From 736fa3e413a78a39484df2a71c64eda0df3bb98e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Fri, 3 Sep 2021 00:17:59 +0200 Subject: [PATCH] More cleanup --- dist/plex-meets-homeassistant.js | 10 ++++++---- src/modules/PlayController.ts | 6 +++--- src/plex-meets-homeassistant.ts | 4 +++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index b3c5a59..06a9a97 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19407,7 +19407,7 @@ class PlayController { } switch (entity.key) { case 'kodi': - await this.playViaKodi(entity.value, data, processData.type); + await this.playViaKodi(entity.value, data, data.type); break; case 'androidtv': if (!lodash.isNil(data.epg)) { @@ -19553,9 +19553,9 @@ class PlayController { } }; this.playViaKodi = async (entityName, data, type) => { - if (!lodash.isNil(lodash.get(data, 'epg.Media[0].channelCallSign'))) { + if (type === 'epg') { try { - const kodiData = await this.getKodiSearch(lodash.get(data, 'epg.Media[0].channelCallSign'), true); + const kodiData = await this.getKodiSearch(lodash.get(data, 'channelCallSign'), true); await this.hass.callService('kodi', 'call_method', { // eslint-disable-next-line @typescript-eslint/camelcase entity_id: entityName, @@ -21452,6 +21452,9 @@ class PlexMeetsHomeAssistant extends HTMLElement { const liveTV = await this.plex.getLiveTV(); lodash.forEach(liveTV, (data, key) => { this.data[key] = data; + lodash.forEach(this.data[key], (value, innerKey) => { + this.data[key][innerKey].type = 'epg'; + }); }); } }; @@ -21491,7 +21494,6 @@ class PlexMeetsHomeAssistant extends HTMLElement { lodash.forEach(this.data[key], (libraryData, libraryKey) => { if (!lodash.isNil(this.epgData[key][libraryData.channelCallSign])) { this.data[key][libraryKey].epg = this.epgData[key][libraryData.channelCallSign]; - this.data[key][libraryKey].type = 'epg'; } }); }); diff --git a/src/modules/PlayController.ts b/src/modules/PlayController.ts index d42f2f4..80f62f5 100644 --- a/src/modules/PlayController.ts +++ b/src/modules/PlayController.ts @@ -126,7 +126,7 @@ class PlayController { } switch (entity.key) { case 'kodi': - await this.playViaKodi(entity.value, data, processData.type); + await this.playViaKodi(entity.value, data, data.type); break; case 'androidtv': if (!_.isNil(data.epg)) { @@ -283,9 +283,9 @@ class PlayController { }; private playViaKodi = async (entityName: string, data: Record, type: string): Promise => { - if (!_.isNil(_.get(data, 'epg.Media[0].channelCallSign'))) { + if (type === 'epg') { try { - const kodiData = await this.getKodiSearch(_.get(data, 'epg.Media[0].channelCallSign'), true); + const kodiData = await this.getKodiSearch(_.get(data, 'channelCallSign'), true); await this.hass.callService('kodi', 'call_method', { // eslint-disable-next-line @typescript-eslint/camelcase diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 5d684b9..7648217 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -410,6 +410,9 @@ class PlexMeetsHomeAssistant extends HTMLElement { const liveTV = await this.plex.getLiveTV(); _.forEach(liveTV, (data, key) => { this.data[key] = data; + _.forEach(this.data[key], (value, innerKey) => { + this.data[key][innerKey].type = 'epg'; + }); }); } }; @@ -450,7 +453,6 @@ class PlexMeetsHomeAssistant extends HTMLElement { _.forEach(this.data[key], (libraryData, libraryKey) => { if (!_.isNil(this.epgData[key][libraryData.channelCallSign])) { this.data[key][libraryKey].epg = this.epgData[key][libraryData.channelCallSign]; - this.data[key][libraryKey].type = 'epg'; } }); });