|
|
@ -18671,10 +18671,19 @@ class Plex {
|
|
|
|
constructor(ip, port = 32400, token, protocol = 'http') {
|
|
|
|
constructor(ip, port = 32400, token, protocol = 'http') {
|
|
|
|
this.serverInfo = {};
|
|
|
|
this.serverInfo = {};
|
|
|
|
this.clients = [];
|
|
|
|
this.clients = [];
|
|
|
|
|
|
|
|
this.init = async () => {
|
|
|
|
|
|
|
|
await this.getClients();
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
|
|
|
this.getClients();
|
|
|
|
|
|
|
|
}, 30000);
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
};
|
|
|
|
this.getClients = async () => {
|
|
|
|
this.getClients = async () => {
|
|
|
|
const url = `${this.protocol}://${this.ip}:${this.port}/clients?X-Plex-Token=${this.token}`;
|
|
|
|
const url = `${this.protocol}://${this.ip}:${this.port}/clients?X-Plex-Token=${this.token}`;
|
|
|
|
const result = await axios.get(url);
|
|
|
|
const result = await axios.get(url);
|
|
|
|
return result;
|
|
|
|
this.clients = result.data.MediaContainer.Server;
|
|
|
|
|
|
|
|
return this.clients;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.getServerID = async () => {
|
|
|
|
this.getServerID = async () => {
|
|
|
|
if (lodash.isEmpty(this.serverInfo)) {
|
|
|
|
if (lodash.isEmpty(this.serverInfo)) {
|
|
|
@ -18907,9 +18916,15 @@ class PlayController {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return service;
|
|
|
|
return service;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
// todo: finish check
|
|
|
|
|
|
|
|
this.isPlexPlayerSupported = () => {
|
|
|
|
this.isPlexPlayerSupported = () => {
|
|
|
|
return true;
|
|
|
|
let found = false;
|
|
|
|
|
|
|
|
lodash.forEach(this.plex.clients, plexClient => {
|
|
|
|
|
|
|
|
if (lodash.isEqual(plexClient.machineIdentifier, this.entity.plexPlayer)) {
|
|
|
|
|
|
|
|
found = true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return found;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.isPlaySupported = (data) => {
|
|
|
|
this.isPlaySupported = (data) => {
|
|
|
|
return !lodash.isEmpty(this.getPlayService(data));
|
|
|
|
return !lodash.isEmpty(this.getPlayService(data));
|
|
|
@ -19539,6 +19554,9 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
this.loadInitialData = async () => {
|
|
|
|
this.loadInitialData = async () => {
|
|
|
|
this.loading = true;
|
|
|
|
this.loading = true;
|
|
|
|
this.renderPage();
|
|
|
|
this.renderPage();
|
|
|
|
|
|
|
|
if (this.plex) {
|
|
|
|
|
|
|
|
await this.plex.init();
|
|
|
|
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (this.plex) {
|
|
|
|
if (this.plex) {
|
|
|
|
const [serverID, plexSections] = await Promise.all([this.plex.getServerID(), this.plex.getSectionsData()]);
|
|
|
|
const [serverID, plexSections] = await Promise.all([this.plex.getServerID(), this.plex.getSectionsData()]);
|
|
|
|