From 74fe0bae96d91af66dff5eebd50bae010e57103b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Sat, 5 Jun 2021 14:51:18 +0200 Subject: [PATCH] Add: List support for kodi --- dist/plex-meets-homeassistant.js | 19 ++++--------------- src/modules/PlayController.ts | 12 ++++-------- src/plex-meets-homeassistant.ts | 7 ------- 3 files changed, 8 insertions(+), 30 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index 035094a..0287567 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -18808,7 +18808,7 @@ class PlayController { const entity = this.getPlayService(data); switch (entity.key) { case 'kodi': - await this.playViaKodi(data, data.type); + await this.playViaKodi(entity.value, data, data.type); break; case 'androidtv': await this.playViaAndroidTV(entity.value, data.key.split('/')[3], instantPlay); @@ -18867,12 +18867,12 @@ class PlayController { } } }; - this.playViaKodi = async (data, type) => { + this.playViaKodi = async (entityName, data, type) => { if (type === 'movie') { const kodiData = await this.getKodiSearch(data.title); await this.hass.callService('kodi', 'call_method', { // eslint-disable-next-line @typescript-eslint/camelcase - entity_id: this.entity.kodi, + entity_id: entityName, method: 'Player.Open', item: { movieid: kodiData.movieid @@ -18894,7 +18894,7 @@ class PlayController { } await this.hass.callService('kodi', 'call_method', { // eslint-disable-next-line @typescript-eslint/camelcase - entity_id: this.entity.kodi, + entity_id: entityName, method: 'Player.Open', item: { episodeid: foundEpisode.episodeid @@ -18906,7 +18906,6 @@ class PlayController { } }; this.playViaAndroidTV = async (entityName, mediaID, instantPlay = false) => { - console.log(entityName); const serverID = await this.plex.getServerID(); let command = `am start`; if (instantPlay) { @@ -18951,8 +18950,6 @@ class PlayController { } } }); - console.log('service'); - console.log(service); return service; }; this.isPlexPlayerSupported = (entityName) => { @@ -18998,7 +18995,6 @@ class PlayController { this.hass = hass; this.plex = plex; this.entity = entity; - console.log(entity); } } @@ -19732,7 +19728,6 @@ class PlexMeetsHomeAssistant extends HTMLElement { }; this.renderMovieElems = () => { if (this.data[this.config.libraryName] && this.renderedItems < this.data[this.config.libraryName].length) { - console.log('renderMovieElems'); let count = 0; // eslint-disable-next-line consistent-return const searchValues = lodash.split(this.searchValue, ' '); @@ -20241,26 +20236,20 @@ class PlexMeetsHomeAssistant extends HTMLElement { } }; this.resizeBackground = () => { - console.log('resizeBackground'); if (this.seasonsElem && this.episodesElem && this.card) { const contentbg = this.getElementsByClassName('contentbg')[0]; - console.log(contentbg); if (this.contentBGHeight === 0) { this.contentBGHeight = getHeight(contentbg); } const requiredSeasonBodyHeight = parseInt(this.seasonsElem.style.top.replace('px', ''), 10) + this.seasonsElem.scrollHeight; const requiredEpisodeBodyHeight = parseInt(this.episodesElem.style.top.replace('px', ''), 10) + this.episodesElem.scrollHeight; if (requiredSeasonBodyHeight > this.contentBGHeight && !this.seasonsElemHidden) { - console.log(`${requiredSeasonBodyHeight} > ${this.contentBGHeight}`); - console.log('1'); this.card.style.height = `${requiredSeasonBodyHeight + 16}px`; } else if (requiredEpisodeBodyHeight > this.contentBGHeight && !this.episodesElemHidden) { - console.log('2'); this.card.style.height = `${requiredEpisodeBodyHeight + 16}px`; } else { - console.log('3'); this.card.style.height = '100%'; } } diff --git a/src/modules/PlayController.ts b/src/modules/PlayController.ts index b43d143..22cbce9 100644 --- a/src/modules/PlayController.ts +++ b/src/modules/PlayController.ts @@ -21,7 +21,6 @@ class PlayController { this.hass = hass; this.plex = plex; this.entity = entity; - console.log(entity); } private getState = async (entityID: string): Promise> => { @@ -87,7 +86,7 @@ class PlayController { const entity = this.getPlayService(data); switch (entity.key) { case 'kodi': - await this.playViaKodi(data, data.type); + await this.playViaKodi(entity.value, data, data.type); break; case 'androidtv': await this.playViaAndroidTV(entity.value, data.key.split('/')[3], instantPlay); @@ -155,12 +154,12 @@ class PlayController { } }; - private playViaKodi = async (data: Record, type: string): Promise => { + private playViaKodi = async (entityName: string, data: Record, type: string): Promise => { if (type === 'movie') { const kodiData = await this.getKodiSearch(data.title); await this.hass.callService('kodi', 'call_method', { // eslint-disable-next-line @typescript-eslint/camelcase - entity_id: this.entity.kodi, + entity_id: entityName, method: 'Player.Open', item: { movieid: kodiData.movieid @@ -184,7 +183,7 @@ class PlayController { } await this.hass.callService('kodi', 'call_method', { // eslint-disable-next-line @typescript-eslint/camelcase - entity_id: this.entity.kodi, + entity_id: entityName, method: 'Player.Open', item: { episodeid: foundEpisode.episodeid @@ -196,7 +195,6 @@ class PlayController { }; private playViaAndroidTV = async (entityName: string, mediaID: number, instantPlay = false): Promise => { - console.log(entityName); const serverID = await this.plex.getServerID(); let command = `am start`; @@ -248,8 +246,6 @@ class PlayController { } } }); - console.log('service'); - console.log(service); return service; }; diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index a2602b2..618ccfa 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -196,7 +196,6 @@ class PlexMeetsHomeAssistant extends HTMLElement { renderMovieElems = (): void => { if (this.data[this.config.libraryName] && this.renderedItems < this.data[this.config.libraryName].length) { - console.log('renderMovieElems'); let count = 0; // eslint-disable-next-line consistent-return const searchValues = _.split(this.searchValue, ' '); @@ -765,10 +764,8 @@ class PlexMeetsHomeAssistant extends HTMLElement { }; resizeBackground = (): void => { - console.log('resizeBackground'); if (this.seasonsElem && this.episodesElem && this.card) { const contentbg = this.getElementsByClassName('contentbg')[0] as HTMLElement; - console.log(contentbg); if (this.contentBGHeight === 0) { this.contentBGHeight = getHeight(contentbg); } @@ -778,14 +775,10 @@ class PlexMeetsHomeAssistant extends HTMLElement { parseInt(this.episodesElem.style.top.replace('px', ''), 10) + this.episodesElem.scrollHeight; if (requiredSeasonBodyHeight > this.contentBGHeight && !this.seasonsElemHidden) { - console.log(`${requiredSeasonBodyHeight} > ${this.contentBGHeight}`); - console.log('1'); this.card.style.height = `${requiredSeasonBodyHeight + 16}px`; } else if (requiredEpisodeBodyHeight > this.contentBGHeight && !this.episodesElemHidden) { - console.log('2'); this.card.style.height = `${requiredEpisodeBodyHeight + 16}px`; } else { - console.log('3'); this.card.style.height = '100%'; } }