|
|
@ -11,6 +11,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
requestTimeout = 3000;
|
|
|
|
requestTimeout = 3000;
|
|
|
|
loading = false;
|
|
|
|
loading = false;
|
|
|
|
maxCount = false;
|
|
|
|
maxCount = false;
|
|
|
|
|
|
|
|
playSupported = false;
|
|
|
|
|
|
|
|
|
|
|
|
escapeHtml = (unsafe) => {
|
|
|
|
escapeHtml = (unsafe) => {
|
|
|
|
return unsafe
|
|
|
|
return unsafe
|
|
|
@ -58,7 +59,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
this.detailElem = document.createElement("div");
|
|
|
|
this.detailElem = document.createElement("div");
|
|
|
|
this.detailElem.className = "detail";
|
|
|
|
this.detailElem.className = "detail";
|
|
|
|
this.detailElem.innerHTML =
|
|
|
|
this.detailElem.innerHTML =
|
|
|
|
"<h1></h1><h2></h2><span class='detailDesc'></span>";
|
|
|
|
"<h1></h1><h2></h2><span class='metaInfo'></span><span class='detailDesc'></span>";
|
|
|
|
this.content.appendChild(this.detailElem);
|
|
|
|
this.content.appendChild(this.detailElem);
|
|
|
|
|
|
|
|
|
|
|
|
//todo: figure out why timeout is needed here and do it properly
|
|
|
|
//todo: figure out why timeout is needed here and do it properly
|
|
|
@ -90,6 +91,12 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
|
|
|
|
|
|
|
|
set hass(hass) {
|
|
|
|
set hass(hass) {
|
|
|
|
if (!this.content) {
|
|
|
|
if (!this.content) {
|
|
|
|
|
|
|
|
this.playSupported =
|
|
|
|
|
|
|
|
hass.states[this.config.entity_id] &&
|
|
|
|
|
|
|
|
hass.states[this.config.entity_id].attributes &&
|
|
|
|
|
|
|
|
hass.states[this.config.entity_id].attributes.adb_response !==
|
|
|
|
|
|
|
|
undefined;
|
|
|
|
|
|
|
|
|
|
|
|
const _this = this;
|
|
|
|
const _this = this;
|
|
|
|
this.error = "";
|
|
|
|
this.error = "";
|
|
|
|
if (!this.loading) {
|
|
|
|
if (!this.loading) {
|
|
|
@ -225,6 +232,12 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
art: title.attributes.art
|
|
|
|
art: title.attributes.art
|
|
|
|
? title.attributes.art.textContent
|
|
|
|
? title.attributes.art.textContent
|
|
|
|
: undefined,
|
|
|
|
: undefined,
|
|
|
|
|
|
|
|
contentRating: title.attributes.contentRating
|
|
|
|
|
|
|
|
? title.attributes.contentRating.textContent
|
|
|
|
|
|
|
|
: undefined,
|
|
|
|
|
|
|
|
duration: title.attributes.duration
|
|
|
|
|
|
|
|
? title.attributes.duration.textContent
|
|
|
|
|
|
|
|
: undefined,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -310,7 +323,9 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
|
|
|
|
|
|
|
|
_this.detailElem.children[0].innerHTML = _this.escapeHtml(data.title);
|
|
|
|
_this.detailElem.children[0].innerHTML = _this.escapeHtml(data.title);
|
|
|
|
_this.detailElem.children[1].innerHTML = _this.escapeHtml(data.year);
|
|
|
|
_this.detailElem.children[1].innerHTML = _this.escapeHtml(data.year);
|
|
|
|
_this.detailElem.children[2].innerHTML = _this.escapeHtml(data.summary);
|
|
|
|
_this.detailElem.children[2].innerHTML =
|
|
|
|
|
|
|
|
_this.escapeHtml(data.duration) / 60 / 1000 + " min";
|
|
|
|
|
|
|
|
_this.detailElem.children[3].innerHTML = _this.escapeHtml(data.summary);
|
|
|
|
_this.detailElem.style.color = "rgba(255,255,255,1)";
|
|
|
|
_this.detailElem.style.color = "rgba(255,255,255,1)";
|
|
|
|
_this.detailElem.style["z-index"] = "4";
|
|
|
|
_this.detailElem.style["z-index"] = "4";
|
|
|
|
}, 1);
|
|
|
|
}, 1);
|
|
|
@ -352,6 +367,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
|
|
|
|
|
|
|
|
const movieElem = document.createElement("div");
|
|
|
|
const movieElem = document.createElement("div");
|
|
|
|
movieElem.className = "movieElem";
|
|
|
|
movieElem.className = "movieElem";
|
|
|
|
|
|
|
|
|
|
|
|
movieElem.style =
|
|
|
|
movieElem.style =
|
|
|
|
"width:" +
|
|
|
|
"width:" +
|
|
|
|
this.width +
|
|
|
|
this.width +
|
|
|
@ -360,6 +376,9 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
"px; background-image: url('" +
|
|
|
|
"px; background-image: url('" +
|
|
|
|
thumbURL +
|
|
|
|
thumbURL +
|
|
|
|
"'); ";
|
|
|
|
"'); ";
|
|
|
|
|
|
|
|
if (!this.playSupported) {
|
|
|
|
|
|
|
|
movieElem.style.cursor = "pointer";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
movieElem.addEventListener("click", function (event) {
|
|
|
|
movieElem.addEventListener("click", function (event) {
|
|
|
|
console.log(data);
|
|
|
|
console.log(data);
|
|
|
@ -396,7 +415,9 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
const playButton = this.getPlayButton();
|
|
|
|
const playButton = this.getPlayButton();
|
|
|
|
const interactiveArea = document.createElement("div");
|
|
|
|
const interactiveArea = document.createElement("div");
|
|
|
|
interactiveArea.className = "interactiveArea";
|
|
|
|
interactiveArea.className = "interactiveArea";
|
|
|
|
interactiveArea.append(playButton);
|
|
|
|
if (this.playSupported) {
|
|
|
|
|
|
|
|
interactiveArea.append(playButton);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
movieElem.append(interactiveArea);
|
|
|
|
movieElem.append(interactiveArea);
|
|
|
|
|
|
|
|
|
|
|
@ -439,6 +460,9 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
let style = document.createElement("style");
|
|
|
|
let style = document.createElement("style");
|
|
|
|
|
|
|
|
|
|
|
|
style.textContent = `
|
|
|
|
style.textContent = `
|
|
|
|
|
|
|
|
.detail .metaInfo {
|
|
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
|
|
}
|
|
|
|
.detail h2 {
|
|
|
|
.detail h2 {
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
white-space: nowrap;
|
|
|
|