Update: Clean up Plex IP Address / Hostname from protocol and trailing slashes

realtime_play_button 2.4.1
Juraj Nyíri 3 years ago
parent b1a8f4809d
commit c743d0a2aa

@ -19699,7 +19699,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.valueUpdated = () => { this.valueUpdated = () => {
const originalConfig = lodash.clone(this.config); const originalConfig = lodash.clone(this.config);
this.config.protocol = this.protocol.value; this.config.protocol = this.protocol.value;
this.config.ip = this.ip.value; this.config.ip = this.ip.value.replace(/^https?\:\/\//i, '').replace(/\/$/, '');
this.config.token = this.token.value; this.config.token = this.token.value;
this.config.port = this.port.value; this.config.port = this.port.value;
if (this.loaded) { if (this.loaded) {
@ -19867,8 +19867,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.protocol.value = this.config.protocol; this.protocol.value = this.config.protocol;
} }
this.content.appendChild(this.protocol); this.content.appendChild(this.protocol);
this.ip.label = 'Plex IP Address'; this.ip.label = 'Plex IP Address / Hostname';
this.ip.value = this.config.ip; this.ip.value = this.config.ip.replace(/^https?\:\/\//i, '').replace(/\/$/, '');
this.ip.addEventListener('change', this.valueUpdated); this.ip.addEventListener('change', this.valueUpdated);
this.content.appendChild(this.ip); this.content.appendChild(this.ip);
this.port.label = 'Plex Port (Optional)'; this.port.label = 'Plex Port (Optional)';
@ -19898,7 +19898,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.content.appendChild(this.libraryName); this.content.appendChild(this.libraryName);
this.content.appendChild(warningLibrary); this.content.appendChild(warningLibrary);
this.appendChild(this.content); this.appendChild(this.content);
this.plex = new Plex(this.config.ip, this.plexPort, this.config.token, this.plexProtocol, this.config.sort); this.plex = new Plex(this.config.ip.replace(/^https?\:\/\//i, '').replace(/\/$/, ''), this.plexPort, this.config.token, this.plexProtocol, this.config.sort);
this.sections = await this.plex.getSections(); this.sections = await this.plex.getSections();
this.livetv = await this.plex.getLiveTV(); this.livetv = await this.plex.getLiveTV();
this.collections = await this.plex.getCollections(); this.collections = await this.plex.getCollections();

@ -95,7 +95,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
valueUpdated = (): void => { valueUpdated = (): void => {
const originalConfig = _.clone(this.config); const originalConfig = _.clone(this.config);
this.config.protocol = this.protocol.value; this.config.protocol = this.protocol.value;
this.config.ip = this.ip.value; this.config.ip = this.ip.value.replace(/^https?\:\/\//i, '').replace(/\/$/, '');
this.config.token = this.token.value; this.config.token = this.token.value;
this.config.port = this.port.value; this.config.port = this.port.value;
if (this.loaded) { if (this.loaded) {
@ -266,8 +266,8 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
} }
this.content.appendChild(this.protocol); this.content.appendChild(this.protocol);
this.ip.label = 'Plex IP Address'; this.ip.label = 'Plex IP Address / Hostname';
this.ip.value = this.config.ip; this.ip.value = this.config.ip.replace(/^https?\:\/\//i, '').replace(/\/$/, '');
this.ip.addEventListener('change', this.valueUpdated); this.ip.addEventListener('change', this.valueUpdated);
this.content.appendChild(this.ip); this.content.appendChild(this.ip);
@ -304,7 +304,13 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
this.appendChild(this.content); this.appendChild(this.content);
this.plex = new Plex(this.config.ip, this.plexPort, this.config.token, this.plexProtocol, this.config.sort); this.plex = new Plex(
this.config.ip.replace(/^https?\:\/\//i, '').replace(/\/$/, ''),
this.plexPort,
this.config.token,
this.plexProtocol,
this.config.sort
);
this.sections = await this.plex.getSections(); this.sections = await this.plex.getSections();
this.livetv = await this.plex.getLiveTV(); this.livetv = await this.plex.getLiveTV();
this.collections = await this.plex.getCollections(); this.collections = await this.plex.getCollections();

Loading…
Cancel
Save