diff --git a/README.md b/README.md index a060ed4..feefe67 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,11 @@ More images [at the end of the readme](https://github.com/JurajNyiri/PlexMeetsHo **port**: Enter port of your plex sever. -**libraryName**: Name of the library you wish to render. Available special libraries: _Deck_ +**libraryName**: Name of the library you wish to render. + +Available special libraries: +_Deck_: Shows Continue Watching +_Recently Added_: Shows recently added episodes of TV Shows. Tip: For movies, just put in your library name and use sort. **protocol**: _Optional_ Protocol to use for Plex. Defaults to "http". diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index ff30f5c..23dc673 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -18729,6 +18729,12 @@ class Plex { }); return this.exportSectionsData(await Promise.all(sectionsRequests)); }; + this.getRecentyAdded = async () => { + const url = this.authorizeURL(`${this.getBasicURL()}/hubs/home/recentlyAdded?type=2&X-Plex-Container-Start=0&X-Plex-Container-Size=50`); + return (await axios.get(url, { + timeout: this.requestTimeout + })).data.MediaContainer; + }; this.getContinueWatching = async () => { const sections = await this.getSections(); let sectionsString = ''; @@ -19869,6 +19875,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { if (this.plex) { await this.plex.init(); const continueWatching = await this.plex.getContinueWatching(); + const recentlyAdded = await this.plex.getRecentyAdded(); const [serverID, plexSections] = await Promise.all([this.plex.getServerID(), this.plex.getSectionsData()]); // eslint-disable-next-line @typescript-eslint/camelcase this.data.serverID = serverID; @@ -19876,6 +19883,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { this.data[section.title1] = section.Metadata; }); this.data.Deck = continueWatching.Metadata; + this.data['Recently Added'] = recentlyAdded.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 a2f5c1d..4a07f54 100644 --- a/src/modules/Plex.ts +++ b/src/modules/Plex.ts @@ -94,6 +94,17 @@ class Plex { return this.exportSectionsData(await Promise.all(sectionsRequests)); }; + getRecentyAdded = async (): Promise => { + const url = this.authorizeURL( + `${this.getBasicURL()}/hubs/home/recentlyAdded?type=2&X-Plex-Container-Start=0&X-Plex-Container-Size=50` + ); + return ( + await axios.get(url, { + timeout: this.requestTimeout + }) + ).data.MediaContainer; + }; + getContinueWatching = async (): Promise => { const sections = await this.getSections(); let sectionsString = ''; diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index b904d64..7925cfd 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -144,6 +144,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { if (this.plex) { await this.plex.init(); const continueWatching = await this.plex.getContinueWatching(); + const recentlyAdded = await this.plex.getRecentyAdded(); const [serverID, plexSections] = await Promise.all([this.plex.getServerID(), this.plex.getSectionsData()]); // eslint-disable-next-line @typescript-eslint/camelcase this.data.serverID = serverID; @@ -152,6 +153,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { }); this.data.Deck = continueWatching.Metadata; + this.data['Recently Added'] = recentlyAdded.Metadata; if (this.data[this.config.libraryName] === undefined) { this.error = `Library name ${this.config.libraryName} does not exist.`;