diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index e0506d9..ff30f5c 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -18729,12 +18729,17 @@ class Plex { }); return this.exportSectionsData(await Promise.all(sectionsRequests)); }; - this.getContinueWatching = async (sections) => { - const cleanedUpSections = sections.replace(' ', ''); - const url = this.authorizeURL(`${this.getBasicURL()}/hubs/continueWatching/items?contentDirectoryID=${cleanedUpSections}`); + this.getContinueWatching = async () => { + const sections = await this.getSections(); + let sectionsString = ''; + lodash.forEach(sections, section => { + sectionsString += `${section.key},`; + }); + sectionsString = sectionsString.slice(0, -1); + const url = this.authorizeURL(`${this.getBasicURL()}/hubs/continueWatching/items?contentDirectoryID=${sectionsString}`); return (await axios.get(url, { timeout: this.requestTimeout - })).data; + })).data.MediaContainer; }; this.getBasicURL = () => { return `${this.protocol}://${this.ip}:${this.port}`; @@ -19863,14 +19868,14 @@ class PlexMeetsHomeAssistant extends HTMLElement { try { if (this.plex) { await this.plex.init(); - const continueWatching = await this.plex.getContinueWatching('3,5,6'); + const continueWatching = await this.plex.getContinueWatching(); const [serverID, plexSections] = await Promise.all([this.plex.getServerID(), this.plex.getSectionsData()]); // eslint-disable-next-line @typescript-eslint/camelcase this.data.serverID = serverID; lodash.forEach(plexSections, section => { this.data[section.title1] = section.Metadata; }); - this.data.Deck = continueWatching.MediaContainer.Metadata; + this.data.Deck = continueWatching.Metadata; if (this.data[this.config.libraryName] === undefined) { this.error = `Library name ${this.config.libraryName} does not exist.`; } diff --git a/src/modules/Plex.ts b/src/modules/Plex.ts index aa7db3c..a2f5c1d 100644 --- a/src/modules/Plex.ts +++ b/src/modules/Plex.ts @@ -94,16 +94,21 @@ class Plex { return this.exportSectionsData(await Promise.all(sectionsRequests)); }; - getContinueWatching = async (sections: string): Promise => { - const cleanedUpSections = sections.replace(' ', ''); + getContinueWatching = async (): Promise => { + const sections = await this.getSections(); + let sectionsString = ''; + _.forEach(sections, section => { + sectionsString += `${section.key},`; + }); + sectionsString = sectionsString.slice(0, -1); const url = this.authorizeURL( - `${this.getBasicURL()}/hubs/continueWatching/items?contentDirectoryID=${cleanedUpSections}` + `${this.getBasicURL()}/hubs/continueWatching/items?contentDirectoryID=${sectionsString}` ); return ( await axios.get(url, { timeout: this.requestTimeout }) - ).data; + ).data.MediaContainer; }; getBasicURL = (): string => { diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index db958ef..b904d64 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -143,7 +143,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { try { if (this.plex) { await this.plex.init(); - const continueWatching = await this.plex.getContinueWatching('3,5,6'); + const continueWatching = await this.plex.getContinueWatching(); const [serverID, plexSections] = await Promise.all([this.plex.getServerID(), this.plex.getSectionsData()]); // eslint-disable-next-line @typescript-eslint/camelcase this.data.serverID = serverID; @@ -151,7 +151,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { this.data[section.title1] = section.Metadata; }); - this.data.Deck = continueWatching.MediaContainer.Metadata; + this.data.Deck = continueWatching.Metadata; if (this.data[this.config.libraryName] === undefined) { this.error = `Library name ${this.config.libraryName} does not exist.`;