From f8b8ddb6d22b5e78d0644a15dc6a2b8eda66646e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Wed, 1 Sep 2021 01:09:21 +0200 Subject: [PATCH] Add: Live TV loaded in renderer --- dist/plex-meets-homeassistant.js | 10 +++++++++- src/plex-meets-homeassistant.ts | 13 +++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index 7f2711b..27006e5 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -21151,7 +21151,6 @@ class PlexMeetsHomeAssistant extends HTMLElement { } await this.plex.init(); const plexAllSections = await this.plex.getSections(); - console.log(await this.plex.getLiveTV()); const getOnDeck = async () => { if (this.plex) { try { @@ -21229,6 +21228,14 @@ class PlexMeetsHomeAssistant extends HTMLElement { } } }; + const getLiveTV = async () => { + if (this.plex) { + const liveTV = await this.plex.getLiveTV(); + lodash.forEach(liveTV, (data, key) => { + this.data[key] = data; + }); + } + }; let sectionKey = 0; lodash.forEach(plexAllSections, (section) => { if (lodash.isEqual(section.title, this.config.libraryName)) { @@ -21253,6 +21260,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { else if (lodash.isEqual(this.config.libraryName, 'Recently Added')) { loadDataRequests.push(getRecentyAdded()); } + loadDataRequests.push(getLiveTV()); const [plexSections] = await Promise.all(loadDataRequests); if (plexSections && sectionKey) { lodash.forEach(plexSections, section => { diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 6df843f..6262e2e 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -333,8 +333,6 @@ class PlexMeetsHomeAssistant extends HTMLElement { await this.plex.init(); const plexAllSections = await this.plex.getSections(); - console.log(await this.plex.getLiveTV()); - const getOnDeck = async (): Promise => { if (this.plex) { try { @@ -405,6 +403,15 @@ class PlexMeetsHomeAssistant extends HTMLElement { } }; + const getLiveTV = async (): Promise => { + if (this.plex) { + const liveTV = await this.plex.getLiveTV(); + _.forEach(liveTV, (data, key) => { + this.data[key] = data; + }); + } + }; + let sectionKey: number | false = 0; _.forEach(plexAllSections, (section: Record) => { if (_.isEqual(section.title, this.config.libraryName)) { @@ -427,6 +434,8 @@ class PlexMeetsHomeAssistant extends HTMLElement { loadDataRequests.push(getRecentyAdded()); } + loadDataRequests.push(getLiveTV()); + const [plexSections] = await Promise.all(loadDataRequests); if (plexSections && sectionKey) {