|
|
@ -18670,6 +18670,10 @@ class Plex {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return this.exportSectionsData(await Promise.all(sectionsRequests));
|
|
|
|
return this.exportSectionsData(await Promise.all(sectionsRequests));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
this.getLibraryData = async (id) => {
|
|
|
|
|
|
|
|
const url = `${this.protocol}://${this.ip}:${this.port}/library/metadata/${id}/children?X-Plex-Token=${this.token}`;
|
|
|
|
|
|
|
|
return (await axios.get(url)).data.MediaContainer.Metadata;
|
|
|
|
|
|
|
|
};
|
|
|
|
this.exportSectionsData = (sectionsData) => {
|
|
|
|
this.exportSectionsData = (sectionsData) => {
|
|
|
|
const processedData = [];
|
|
|
|
const processedData = [];
|
|
|
|
lodash.forEach(sectionsData, sectionData => {
|
|
|
|
lodash.forEach(sectionsData, sectionData => {
|
|
|
@ -19149,6 +19153,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
constructor() {
|
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
|
|
|
super(...arguments);
|
|
|
|
this.plexProtocol = 'http';
|
|
|
|
this.plexProtocol = 'http';
|
|
|
|
|
|
|
|
this.plex = undefined;
|
|
|
|
this.movieElems = [];
|
|
|
|
this.movieElems = [];
|
|
|
|
this.detailElem = undefined;
|
|
|
|
this.detailElem = undefined;
|
|
|
|
this.data = {};
|
|
|
|
this.data = {};
|
|
|
@ -19162,19 +19167,23 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
this.loadInitialData = async (hass) => {
|
|
|
|
this.loadInitialData = async (hass) => {
|
|
|
|
this.loading = true;
|
|
|
|
this.loading = true;
|
|
|
|
this.renderPage(hass);
|
|
|
|
this.renderPage(hass);
|
|
|
|
const plex = new Plex(this.config.ip, this.config.port, this.config.token, this.plexProtocol);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const [plexInfo, plexSections] = await Promise.all([plex.getServerInfo(), plex.getSectionsData()]);
|
|
|
|
if (this.plex) {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
const [plexInfo, plexSections] = await Promise.all([this.plex.getServerInfo(), this.plex.getSectionsData()]);
|
|
|
|
this.data.serverID = plexInfo;
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
lodash.forEach(plexSections, section => {
|
|
|
|
this.data.serverID = plexInfo;
|
|
|
|
this.data[section.title1] = section.Metadata;
|
|
|
|
lodash.forEach(plexSections, section => {
|
|
|
|
});
|
|
|
|
this.data[section.title1] = section.Metadata;
|
|
|
|
if (this.data[this.config.libraryName] === undefined) {
|
|
|
|
});
|
|
|
|
this.error = `Library name ${this.config.libraryName} does not exist.`;
|
|
|
|
if (this.data[this.config.libraryName] === undefined) {
|
|
|
|
|
|
|
|
this.error = `Library name ${this.config.libraryName} does not exist.`;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
|
|
|
|
this.render(hass);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
throw Error('Plex not initialized.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.loading = false;
|
|
|
|
|
|
|
|
this.render(hass);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
catch (err) {
|
|
|
|
// todo: proper timeout here
|
|
|
|
// todo: proper timeout here
|
|
|
@ -19313,13 +19322,12 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
this.detailElem.style.visibility = 'hidden';
|
|
|
|
this.detailElem.style.visibility = 'hidden';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.showDetails = (data) => {
|
|
|
|
this.showDetails = async (data) => {
|
|
|
|
const doc = document.documentElement;
|
|
|
|
const doc = document.documentElement;
|
|
|
|
const top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
|
|
|
|
const top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
|
|
|
|
if (this.detailElem) {
|
|
|
|
if (this.detailElem) {
|
|
|
|
this.detailElem.style.transition = '0s';
|
|
|
|
this.detailElem.style.transition = '0s';
|
|
|
|
this.detailElem.style.top = `${top - 1000}px`;
|
|
|
|
this.detailElem.style.top = `${top - 1000}px`;
|
|
|
|
console.log(this.detailElem.style.top);
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
if (this.detailElem) {
|
|
|
|
if (this.detailElem) {
|
|
|
|
this.detailElem.style.visibility = 'visible';
|
|
|
|
this.detailElem.style.visibility = 'visible';
|
|
|
@ -19349,6 +19357,10 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 200);
|
|
|
|
}, 200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.plex) {
|
|
|
|
|
|
|
|
const seasonsData = await this.plex.getLibraryData(data.key.split('/')[3]);
|
|
|
|
|
|
|
|
console.log(seasonsData);
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.showBackground = () => {
|
|
|
|
this.showBackground = () => {
|
|
|
|
const contentbg = this.getElementsByClassName('contentbg');
|
|
|
|
const contentbg = this.getElementsByClassName('contentbg');
|
|
|
@ -19467,6 +19479,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
if (config.maxCount) {
|
|
|
|
if (config.maxCount) {
|
|
|
|
this.maxCount = config.maxCount;
|
|
|
|
this.maxCount = config.maxCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.plex = new Plex(this.config.ip, this.config.port, this.config.token, this.plexProtocol);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.getCardSize = () => {
|
|
|
|
this.getCardSize = () => {
|
|
|
|
return 3;
|
|
|
|
return 3;
|
|
|
|