Add: Recently added tv shows episodes view

pull/16/head
Juraj Nyíri 4 years ago
parent 0e4cc18846
commit e01cbd652e

@ -31,7 +31,11 @@ More images [at the end of the readme](https://github.com/JurajNyiri/PlexMeetsHo
**port**: Enter port of your plex sever. **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". **protocol**: _Optional_ Protocol to use for Plex. Defaults to "http".

@ -18729,6 +18729,12 @@ class Plex {
}); });
return this.exportSectionsData(await Promise.all(sectionsRequests)); 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 () => { this.getContinueWatching = async () => {
const sections = await this.getSections(); const sections = await this.getSections();
let sectionsString = ''; let sectionsString = '';
@ -19869,6 +19875,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (this.plex) { if (this.plex) {
await this.plex.init(); await this.plex.init();
const continueWatching = await this.plex.getContinueWatching(); const continueWatching = await this.plex.getContinueWatching();
const recentlyAdded = await this.plex.getRecentyAdded();
const [serverID, plexSections] = await Promise.all([this.plex.getServerID(), this.plex.getSectionsData()]); const [serverID, plexSections] = await Promise.all([this.plex.getServerID(), this.plex.getSectionsData()]);
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
this.data.serverID = serverID; this.data.serverID = serverID;
@ -19876,6 +19883,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.data[section.title1] = section.Metadata; this.data[section.title1] = section.Metadata;
}); });
this.data.Deck = continueWatching.Metadata; this.data.Deck = continueWatching.Metadata;
this.data['Recently Added'] = recentlyAdded.Metadata;
if (this.data[this.config.libraryName] === undefined) { if (this.data[this.config.libraryName] === undefined) {
this.error = `Library name ${this.config.libraryName} does not exist.`; this.error = `Library name ${this.config.libraryName} does not exist.`;
} }

@ -94,6 +94,17 @@ class Plex {
return this.exportSectionsData(await Promise.all(sectionsRequests)); return this.exportSectionsData(await Promise.all(sectionsRequests));
}; };
getRecentyAdded = async (): Promise<any> => {
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<any> => { getContinueWatching = async (): Promise<any> => {
const sections = await this.getSections(); const sections = await this.getSections();
let sectionsString = ''; let sectionsString = '';

@ -144,6 +144,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (this.plex) { if (this.plex) {
await this.plex.init(); await this.plex.init();
const continueWatching = await this.plex.getContinueWatching(); const continueWatching = await this.plex.getContinueWatching();
const recentlyAdded = await this.plex.getRecentyAdded();
const [serverID, plexSections] = await Promise.all([this.plex.getServerID(), this.plex.getSectionsData()]); const [serverID, plexSections] = await Promise.all([this.plex.getServerID(), this.plex.getSectionsData()]);
// eslint-disable-next-line @typescript-eslint/camelcase // eslint-disable-next-line @typescript-eslint/camelcase
this.data.serverID = serverID; this.data.serverID = serverID;
@ -152,6 +153,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
}); });
this.data.Deck = continueWatching.Metadata; this.data.Deck = continueWatching.Metadata;
this.data['Recently Added'] = recentlyAdded.Metadata;
if (this.data[this.config.libraryName] === undefined) { if (this.data[this.config.libraryName] === undefined) {
this.error = `Library name ${this.config.libraryName} does not exist.`; this.error = `Library name ${this.config.libraryName} does not exist.`;

Loading…
Cancel
Save