Fix: Deck now automatically figures section ids

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

@ -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.`;
}

@ -94,16 +94,21 @@ class Plex {
return this.exportSectionsData(await Promise.all(sectionsRequests));
};
getContinueWatching = async (sections: string): Promise<any> => {
const cleanedUpSections = sections.replace(' ', '');
getContinueWatching = async (): Promise<any> => {
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 => {

@ -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.`;

Loading…
Cancel
Save