|
|
@ -18676,6 +18676,7 @@ class Plex {
|
|
|
|
this.sections = [];
|
|
|
|
this.sections = [];
|
|
|
|
this.providers = [];
|
|
|
|
this.providers = [];
|
|
|
|
this.livetv = {};
|
|
|
|
this.livetv = {};
|
|
|
|
|
|
|
|
this.livetvepg = {};
|
|
|
|
this.collections = false;
|
|
|
|
this.collections = false;
|
|
|
|
this.playlists = [];
|
|
|
|
this.playlists = [];
|
|
|
|
this.init = async () => {
|
|
|
|
this.init = async () => {
|
|
|
@ -18727,6 +18728,34 @@ class Plex {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this.livetv;
|
|
|
|
return this.livetv;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
this.getEPG = async () => {
|
|
|
|
|
|
|
|
if (lodash.isEmpty(this.livetvepg)) {
|
|
|
|
|
|
|
|
const returnData = {};
|
|
|
|
|
|
|
|
const providers = await this.getProviders();
|
|
|
|
|
|
|
|
const liveTVRequests = [];
|
|
|
|
|
|
|
|
const liveTVRequestsNames = [];
|
|
|
|
|
|
|
|
lodash.forEach(providers, provider => {
|
|
|
|
|
|
|
|
if (lodash.isEqual(provider.protocols, 'livetv')) {
|
|
|
|
|
|
|
|
let url = this.authorizeURL(`${this.getBasicURL()}/${provider.identifier}/grid?type=1&sort=beginsAt`);
|
|
|
|
|
|
|
|
url += `&endsAt>=${Math.floor(Date.now() / 1000)}`;
|
|
|
|
|
|
|
|
url += `&beginsAt<=${Math.floor(Date.now() / 1000)}`;
|
|
|
|
|
|
|
|
liveTVRequests.push(axios.get(url, {
|
|
|
|
|
|
|
|
timeout: this.requestTimeout
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
liveTVRequestsNames.push(provider.title);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const allResults = await Promise.all(liveTVRequests);
|
|
|
|
|
|
|
|
lodash.forEach(allResults, (result, key) => {
|
|
|
|
|
|
|
|
returnData[liveTVRequestsNames[key]] = {};
|
|
|
|
|
|
|
|
lodash.forEach(result.data.MediaContainer.Metadata, data => {
|
|
|
|
|
|
|
|
returnData[liveTVRequestsNames[key]][data.Media[0].channelCallSign] = data;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.livetvepg = returnData;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.livetvepg;
|
|
|
|
|
|
|
|
};
|
|
|
|
this.getServerID = async () => {
|
|
|
|
this.getServerID = async () => {
|
|
|
|
if (lodash.isEmpty(this.serverInfo)) {
|
|
|
|
if (lodash.isEmpty(this.serverInfo)) {
|
|
|
|
await this.getServerInfo();
|
|
|
|
await this.getServerInfo();
|
|
|
@ -21231,6 +21260,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
const getLiveTV = async () => {
|
|
|
|
const getLiveTV = async () => {
|
|
|
|
if (this.plex) {
|
|
|
|
if (this.plex) {
|
|
|
|
const liveTV = await this.plex.getLiveTV();
|
|
|
|
const liveTV = await this.plex.getLiveTV();
|
|
|
|
|
|
|
|
console.log(await this.plex.getEPG());
|
|
|
|
lodash.forEach(liveTV, (data, key) => {
|
|
|
|
lodash.forEach(liveTV, (data, key) => {
|
|
|
|
this.data[key] = data;
|
|
|
|
this.data[key] = data;
|
|
|
|
});
|
|
|
|
});
|
|
|
|