Add: Live TV loaded in renderer

live_tv
Juraj Nyíri 3 years ago
parent 4dda13c2dc
commit f8b8ddb6d2

@ -21151,7 +21151,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
await this.plex.init(); await this.plex.init();
const plexAllSections = await this.plex.getSections(); const plexAllSections = await this.plex.getSections();
console.log(await this.plex.getLiveTV());
const getOnDeck = async () => { const getOnDeck = async () => {
if (this.plex) { if (this.plex) {
try { 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; let sectionKey = 0;
lodash.forEach(plexAllSections, (section) => { lodash.forEach(plexAllSections, (section) => {
if (lodash.isEqual(section.title, this.config.libraryName)) { 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')) { else if (lodash.isEqual(this.config.libraryName, 'Recently Added')) {
loadDataRequests.push(getRecentyAdded()); loadDataRequests.push(getRecentyAdded());
} }
loadDataRequests.push(getLiveTV());
const [plexSections] = await Promise.all(loadDataRequests); const [plexSections] = await Promise.all(loadDataRequests);
if (plexSections && sectionKey) { if (plexSections && sectionKey) {
lodash.forEach(plexSections, section => { lodash.forEach(plexSections, section => {

@ -333,8 +333,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
await this.plex.init(); await this.plex.init();
const plexAllSections = await this.plex.getSections(); const plexAllSections = await this.plex.getSections();
console.log(await this.plex.getLiveTV());
const getOnDeck = async (): Promise<void> => { const getOnDeck = async (): Promise<void> => {
if (this.plex) { if (this.plex) {
try { try {
@ -405,6 +403,15 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
}; };
const getLiveTV = async (): Promise<void> => {
if (this.plex) {
const liveTV = await this.plex.getLiveTV();
_.forEach(liveTV, (data, key) => {
this.data[key] = data;
});
}
};
let sectionKey: number | false = 0; let sectionKey: number | false = 0;
_.forEach(plexAllSections, (section: Record<string, any>) => { _.forEach(plexAllSections, (section: Record<string, any>) => {
if (_.isEqual(section.title, this.config.libraryName)) { if (_.isEqual(section.title, this.config.libraryName)) {
@ -427,6 +434,8 @@ class PlexMeetsHomeAssistant extends HTMLElement {
loadDataRequests.push(getRecentyAdded()); loadDataRequests.push(getRecentyAdded());
} }
loadDataRequests.push(getLiveTV());
const [plexSections] = await Promise.all(loadDataRequests); const [plexSections] = await Promise.all(loadDataRequests);
if (plexSections && sectionKey) { if (plexSections && sectionKey) {

Loading…
Cancel
Save