Add: API endpoint for movie details

pull/16/head
Juraj Nyíri 3 years ago
parent c5f2f51f81
commit e44f141c64

@ -18724,6 +18724,12 @@ class Plex {
}); });
return this.exportSectionsData(await Promise.all(sectionsRequests)); return this.exportSectionsData(await Promise.all(sectionsRequests));
}; };
this.getDetails = async (id) => {
const url = `${this.protocol}://${this.ip}:${this.port}/library/metadata/${id}?includeConcerts=1&includeExtras=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeReviews=1&includeChapters=1&includeStations=1&includeExternalMedia=1&asyncAugmentMetadata=1&asyncCheckFiles=1&asyncRefreshAnalysis=1&asyncRefreshLocalMediaAgent=1&X-Plex-Token=${this.token}`;
return (await axios.get(url, {
timeout: this.requestTimeout
})).data.MediaContainer.Metadata[0];
};
this.getLibraryData = async (id) => { this.getLibraryData = async (id) => {
const url = `${this.protocol}://${this.ip}:${this.port}/library/metadata/${id}/children?X-Plex-Token=${this.token}`; const url = `${this.protocol}://${this.ip}:${this.port}/library/metadata/${id}/children?X-Plex-Token=${this.token}`;
return (await axios.get(url, { return (await axios.get(url, {
@ -20032,7 +20038,8 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
}, 200); }, 200);
} }
if (this.plex && data.childCount > 0) { if (this.plex) {
if (data.childCount > 0) {
this.seasonElemFreshlyLoaded = true; this.seasonElemFreshlyLoaded = true;
const seasonsData = await this.plex.getLibraryData(data.key.split('/')[3]); const seasonsData = await this.plex.getLibraryData(data.key.split('/')[3]);
if (this.seasonsElem) { if (this.seasonsElem) {
@ -20237,6 +20244,10 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
}, 200); }, 200);
} }
else {
console.log(await this.plex.getDetails(data.key.split('/')[3]));
}
}
}; };
this.resizeBackground = () => { this.resizeBackground = () => {
if (this.seasonsElem && this.episodesElem && this.card) { if (this.seasonsElem && this.episodesElem && this.card) {

@ -90,6 +90,15 @@ class Plex {
return this.exportSectionsData(await Promise.all(sectionsRequests)); return this.exportSectionsData(await Promise.all(sectionsRequests));
}; };
getDetails = async (id: number): Promise<any> => {
const url = `${this.protocol}://${this.ip}:${this.port}/library/metadata/${id}?includeConcerts=1&includeExtras=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeReviews=1&includeChapters=1&includeStations=1&includeExternalMedia=1&asyncAugmentMetadata=1&asyncCheckFiles=1&asyncRefreshAnalysis=1&asyncRefreshLocalMediaAgent=1&X-Plex-Token=${this.token}`;
return (
await axios.get(url, {
timeout: this.requestTimeout
})
).data.MediaContainer.Metadata[0];
};
getLibraryData = async (id: number): Promise<any> => { getLibraryData = async (id: number): Promise<any> => {
const url = `${this.protocol}://${this.ip}:${this.port}/library/metadata/${id}/children?X-Plex-Token=${this.token}`; const url = `${this.protocol}://${this.ip}:${this.port}/library/metadata/${id}/children?X-Plex-Token=${this.token}`;
return ( return (

@ -526,7 +526,8 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
}, 200); }, 200);
} }
if (this.plex && data.childCount > 0) { if (this.plex) {
if (data.childCount > 0) {
this.seasonElemFreshlyLoaded = true; this.seasonElemFreshlyLoaded = true;
const seasonsData = await this.plex.getLibraryData(data.key.split('/')[3]); const seasonsData = await this.plex.getLibraryData(data.key.split('/')[3]);
if (this.seasonsElem) { if (this.seasonsElem) {
@ -760,6 +761,9 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.resizeBackground(); this.resizeBackground();
} }
}, 200); }, 200);
} else {
console.log(await this.plex.getDetails(data.key.split('/')[3]));
}
} }
}; };

Loading…
Cancel
Save