|
|
|
@ -143,8 +143,21 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
|
try {
|
|
|
|
|
if (this.plex) {
|
|
|
|
|
await this.plex.init();
|
|
|
|
|
try {
|
|
|
|
|
const continueWatching = await this.plex.getContinueWatching();
|
|
|
|
|
const recentlyAdded = await this.plex.getRecentyAdded();
|
|
|
|
|
this.data.Deck = continueWatching.Metadata;
|
|
|
|
|
this.data['Recently Added'] = recentlyAdded.Metadata;
|
|
|
|
|
} catch (err) {
|
|
|
|
|
if (_.includes(err.message, 'Request failed with status code 404')) {
|
|
|
|
|
console.warn(
|
|
|
|
|
'PlexMeetsHomeAssistant: You are using outdated Plex server. Recently added and continue watching is not available.'
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const [serverID, plexSections] = await Promise.all([this.plex.getServerID(), this.plex.getSectionsData()]);
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
|
this.data.serverID = serverID;
|
|
|
|
@ -152,9 +165,6 @@ 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.`;
|
|
|
|
|
}
|
|
|
|
|