|
|
@ -18729,12 +18729,17 @@ class Plex {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return this.exportSectionsData(await Promise.all(sectionsRequests));
|
|
|
|
return this.exportSectionsData(await Promise.all(sectionsRequests));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.getContinueWatching = async (sections) => {
|
|
|
|
this.getContinueWatching = async () => {
|
|
|
|
const cleanedUpSections = sections.replace(' ', '');
|
|
|
|
const sections = await this.getSections();
|
|
|
|
const url = this.authorizeURL(`${this.getBasicURL()}/hubs/continueWatching/items?contentDirectoryID=${cleanedUpSections}`);
|
|
|
|
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, {
|
|
|
|
return (await axios.get(url, {
|
|
|
|
timeout: this.requestTimeout
|
|
|
|
timeout: this.requestTimeout
|
|
|
|
})).data;
|
|
|
|
})).data.MediaContainer;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.getBasicURL = () => {
|
|
|
|
this.getBasicURL = () => {
|
|
|
|
return `${this.protocol}://${this.ip}:${this.port}`;
|
|
|
|
return `${this.protocol}://${this.ip}:${this.port}`;
|
|
|
@ -19863,14 +19868,14 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (this.plex) {
|
|
|
|
if (this.plex) {
|
|
|
|
await this.plex.init();
|
|
|
|
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()]);
|
|
|
|
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;
|
|
|
|
lodash.forEach(plexSections, section => {
|
|
|
|
lodash.forEach(plexSections, section => {
|
|
|
|
this.data[section.title1] = section.Metadata;
|
|
|
|
this.data[section.title1] = section.Metadata;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.data.Deck = continueWatching.MediaContainer.Metadata;
|
|
|
|
this.data.Deck = continueWatching.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.`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|