Merge pull request #52 from JurajNyiri/3.3.1

3.3.1
sonos 3.3.1
Juraj Nyíri 3 years ago committed by GitHub
commit a25f03029c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18863,11 +18863,21 @@ class Plex {
}; };
this.getSectionDataWithoutProcessing = async (sectionID, type = false) => { this.getSectionDataWithoutProcessing = async (sectionID, type = false) => {
const bulkItems = 50; const bulkItems = 50;
let url = this.authorizeURL(`${this.getBasicURL()}/library/sections/${sectionID}/all`); let url = `${this.getBasicURL()}/library/sections/${sectionID}`;
url += `&sort=${this.sort}`;
if (type) { if (type) {
url += `&type=${type}`; if (lodash.isEqual(type, 'folder')) {
url += `/folder`;
}
else {
url += `/all`;
url += `?type=${type}`;
} }
}
else {
url += `/all`;
}
url = this.authorizeURL(url);
url += `&sort=${this.sort}`;
url += `&includeCollections=1&includeExternalMedia=1&includeAdvanced=1&includeMeta=1`; url += `&includeCollections=1&includeExternalMedia=1&includeAdvanced=1&includeMeta=1`;
let result = {}; let result = {};
try { try {
@ -19091,8 +19101,8 @@ class Plex {
timeout: this.requestTimeout timeout: this.requestTimeout
})).data.MediaContainer.Metadata[0]; })).data.MediaContainer.Metadata[0];
}; };
this.getLibraryData = async (id) => { this.getLibraryData = async (path) => {
const url = this.authorizeURL(`${this.getBasicURL()}/library/metadata/${id}/children`); const url = this.authorizeURL(`${this.getBasicURL()}${path}`);
return (await axios.get(url, { return (await axios.get(url, {
timeout: this.requestTimeout timeout: this.requestTimeout
})).data.MediaContainer.Metadata; })).data.MediaContainer.Metadata;
@ -19293,7 +19303,12 @@ const createTrackView = (playController, plex, data, fontSize1, fontSize2, isEve
trackContainer.append(trackIndexElem); trackContainer.append(trackIndexElem);
const trackTitleElem = document.createElement('td'); const trackTitleElem = document.createElement('td');
trackTitleElem.className = 'trackTitleElem'; trackTitleElem.className = 'trackTitleElem';
if (!lodash.isEmpty(data.title)) {
trackTitleElem.innerHTML = escapeHtml(data.title); trackTitleElem.innerHTML = escapeHtml(data.title);
}
else if (!lodash.isEmpty(data.titleSort)) {
trackTitleElem.innerHTML = escapeHtml(data.titleSort);
}
trackTitleElem.style.fontSize = `${fontSize1}px`; trackTitleElem.style.fontSize = `${fontSize1}px`;
trackTitleElem.style.lineHeight = `${fontSize1}px`; trackTitleElem.style.lineHeight = `${fontSize1}px`;
trackTitleElem.style.marginBottom = `${margin1}px`; trackTitleElem.style.marginBottom = `${margin1}px`;
@ -19811,6 +19826,10 @@ class PlayController {
this.playButtons.push(playButton); this.playButtons.push(playButton);
return playButton; return playButton;
}; };
this.setPlayActionDisplay = (displayValue) => {
const playActionButton = this.updateDetailPlayAction();
playActionButton.style.display = displayValue;
};
this.setPlayActionButtonType = (mediaType) => { this.setPlayActionButtonType = (mediaType) => {
const playActionButton = this.updateDetailPlayAction(); const playActionButton = this.updateDetailPlayAction();
playActionButton.setAttribute('data-mediaType', mediaType); playActionButton.setAttribute('data-mediaType', mediaType);
@ -20833,8 +20852,14 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
typeItems.appendChild(addDropdownItem('', '')); typeItems.appendChild(addDropdownItem('', ''));
let typeAvailable = false; let typeAvailable = false;
lodash.forEach(types, (sectionType) => { lodash.forEach(types, (sectionType) => {
if (sectionType.type !== 'folder' && sectionType.type !== 'track' && sectionType.type !== 'episode') { if (sectionType.type !== 'track' &&
const key = sectionType.key.split('type=')[1]; sectionType.type !== 'episode' &&
(sectionType.type !== 'folder' ||
(sectionType.type === 'folder' && lodash.isEqual(lodash.get(libraryData, '[0].viewGroup'), 'artist')))) {
let key = sectionType.key.split('type=')[1];
if (sectionType.type === 'folder') {
key = 'folder';
}
if (lodash.isEqual(key, this.config.displayType)) { if (lodash.isEqual(key, this.config.displayType)) {
typeAvailable = true; typeAvailable = true;
} }
@ -20872,7 +20897,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
}); });
} }
const sortFields = lodash.get(libraryData, `[0].Meta.Type[${displayTypeIndex}].Sort`); const sortFields = lodash.get(libraryData, `[0].Meta.Type[${displayTypeIndex}].Sort`);
if (!lodash.isNil(sortFields) && sortFields.length > 0) { if (!lodash.isNil(sortFields) && sortFields.length > 0 && this.config.displayType !== 'folder') {
lodash.forEach(sortFields, (sortField) => { lodash.forEach(sortFields, (sortField) => {
sortItems.appendChild(addDropdownItem(sortField.key)); sortItems.appendChild(addDropdownItem(sortField.key));
}); });
@ -21885,6 +21910,26 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.calculatePositions(); this.calculatePositions();
} }
}; };
this.resizeHandler = () => {
if (this.isVisible) {
if (!this.detailsShown) {
const videoPlayer = this.getElementsByClassName('videoPlayer')[0];
let isFullScreen = false;
if (videoPlayer.children.length > 0) {
isFullScreen = isVideoFullScreen(this);
}
if (this.card && this.movieElems.length > 0 && !isFullScreen) {
if (this.previousPageWidth !== this.card.offsetWidth) {
this.previousPageWidth = this.card.offsetWidth;
this.renderPage();
const contentbg = this.getElementsByClassName('contentbg');
this.contentBGHeight = getHeight(contentbg[0]);
}
}
}
this.renderNewElementsIfNeeded();
}
};
this.loadInitialData = async () => { this.loadInitialData = async () => {
this.initialDataLoaded = true; this.initialDataLoaded = true;
setInterval(() => { setInterval(() => {
@ -21939,24 +21984,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.renderNewElementsIfNeeded(); this.renderNewElementsIfNeeded();
}); });
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
if (this.isVisible) { this.resizeHandler();
if (!this.detailsShown) {
const videoPlayer = this.getElementsByClassName('videoPlayer')[0];
let isFullScreen = false;
if (videoPlayer.children.length > 0) {
isFullScreen = isVideoFullScreen(this);
}
if (this.card && this.movieElems.length > 0 && !isFullScreen) {
if (this.previousPageWidth !== this.card.offsetWidth) {
this.previousPageWidth = this.card.offsetWidth;
this.renderPage();
const contentbg = this.getElementsByClassName('contentbg');
this.contentBGHeight = getHeight(contentbg[0]);
}
}
}
this.renderNewElementsIfNeeded();
}
}); });
if (this.card) { if (this.card) {
this.previousPageWidth = this.card.offsetWidth; this.previousPageWidth = this.card.offsetWidth;
@ -22599,15 +22627,9 @@ class PlexMeetsHomeAssistant extends HTMLElement {
break; break;
} }
else { else {
this.resizeHandler();
clearInterval(setLeftOffsetsInterval); clearInterval(setLeftOffsetsInterval);
} }
/*
this.movieElems[i].style.left = `${this.movieElems[i].offsetLeft}px`;
this.movieElems[i].dataset.left = this.movieElems[i].offsetLeft;
this.movieElems[i].style.top = `${this.movieElems[i].offsetTop}px`;
this.movieElems[i].dataset.top = this.movieElems[i].offsetTop;
this.movieElems[i].style.position = 'absolute';
*/
} }
}, 100); }, 100);
}; };
@ -22801,7 +22823,12 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
this.detailElem.style.transition = '0s'; this.detailElem.style.transition = '0s';
this.detailElem.style.top = `${top - 1000}px`; this.detailElem.style.top = `${top - 1000}px`;
if (!lodash.isEmpty(lodash.get(data, 'thumb'))) {
this.detailElem.style.left = `${this.minExpandedWidth + 30}px`; this.detailElem.style.left = `${this.minExpandedWidth + 30}px`;
}
else {
this.detailElem.style.left = `16px`;
}
clearInterval(this.showDetailsTimeout); clearInterval(this.showDetailsTimeout);
// eslint-disable-next-line @typescript-eslint/no-misused-promises // eslint-disable-next-line @typescript-eslint/no-misused-promises
this.showDetailsTimeout = setTimeout(async () => { this.showDetailsTimeout = setTimeout(async () => {
@ -22947,14 +22974,27 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (this.plex) { if (this.plex) {
let childrenData = {}; let childrenData = {};
if (lodash.isEqual(data.type, 'episode')) { if (lodash.isEqual(data.type, 'episode')) {
childrenData = await this.plex.getLibraryData(data.grandparentKey.split('/')[3]); childrenData = await this.plex.getLibraryData(`${data.grandparentKey}/children`);
}
else if (data.childCount > 0 ||
lodash.isEqual(data.type, 'artist') ||
lodash.isEqual(data.type, 'album') ||
lodash.includes(data.key, 'folder')) {
childrenData = await this.plex.getLibraryData(data.key);
}
if (this.playController) {
if (lodash.includes(data.key, 'folder')) {
this.playController.setPlayActionDisplay('none');
}
else {
this.playController.setPlayActionDisplay('block');
} }
else if (data.childCount > 0 || lodash.isEqual(data.type, 'artist') || lodash.isEqual(data.type, 'album')) {
childrenData = await this.plex.getLibraryData(data.key.split('/')[3]);
} }
let dataDetails = {}; let dataDetails = {};
if (!lodash.isNil(data.key)) { if (!lodash.isNil(data.key)) {
if (!lodash.includes(data.key, 'folder')) {
dataDetails = await this.plex.getDetails(data.key.split('/')[3]); dataDetails = await this.plex.getDetails(data.key.split('/')[3]);
}
if (this.videoElem) { if (this.videoElem) {
const art = this.plex.authorizeURL(this.plex.getBasicURL() + data.art); const art = this.plex.authorizeURL(this.plex.getBasicURL() + data.art);
const trailerURL = findTrailerURL(dataDetails); const trailerURL = findTrailerURL(dataDetails);
@ -23074,9 +23114,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
tableView.style.border = 'none'; tableView.style.border = 'none';
tableView.cellSpacing = '0'; tableView.cellSpacing = '0';
tableView.cellPadding = '0'; tableView.cellPadding = '0';
if (lodash.isEqual(data.type, 'album')) {
this.episodesElem.append(tableView); this.episodesElem.append(tableView);
}
let isEven = false; let isEven = false;
lodash.forEach(childrenData, childData => { lodash.forEach(childrenData, childData => {
if (this.episodesElem && this.playController && this.plex) { if (this.episodesElem && this.playController && this.plex) {
@ -23094,8 +23132,16 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (this.episodesElem) { if (this.episodesElem) {
this.episodesElem.style.transition = `0.7s`; this.episodesElem.style.transition = `0.7s`;
if (this.activeMovieElem) { if (this.activeMovieElem) {
if (!lodash.isEmpty(lodash.get(data, 'thumb'))) {
this.episodesElem.style.top = `${top + getHeight(this.activeMovieElem) + 16 * 2}px`; this.episodesElem.style.top = `${top + getHeight(this.activeMovieElem) + 16 * 2}px`;
} }
else if (this.detailElem) {
this.episodesElem.style.top = `${top + getHeight(this.detailElem)}px`;
}
else {
this.episodesElem.style.top = `${top}px`;
}
}
else { else {
this.episodesElem.style.top = `${top + this.minExpandedHeight + 16}px`; this.episodesElem.style.top = `${top + this.minExpandedHeight + 16}px`;
} }
@ -23111,7 +23157,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
else { else {
lodash.forEach(childrenData, childData => { lodash.forEach(childrenData, childData => {
if (this.seasonsElem && this.plex) { if (this.seasonsElem && this.plex) {
console.log(childData);
this.seasonsElemHidden = false; this.seasonsElemHidden = false;
const seasonContainer = document.createElement('div'); const seasonContainer = document.createElement('div');
seasonContainer.className = 'seasonContainer'; seasonContainer.className = 'seasonContainer';
@ -23229,7 +23274,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
(async () => { (async () => {
if (this.plex && (childData.leafCount > 0 || lodash.isEqual(childData.type, 'album'))) { if (this.plex && (childData.leafCount > 0 || lodash.isEqual(childData.type, 'album'))) {
this.episodesElemFreshlyLoaded = true; this.episodesElemFreshlyLoaded = true;
const episodesData = await this.plex.getLibraryData(childData.key.split('/')[3]); const episodesData = await this.plex.getLibraryData(childData.key);
if (this.episodesElem) { if (this.episodesElem) {
this.episodesElemHidden = false; this.episodesElemHidden = false;
this.episodesElem.style.display = 'block'; this.episodesElem.style.display = 'block';
@ -23345,7 +23390,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.episodesElem.style.transition = `0s`; this.episodesElem.style.transition = `0s`;
this.episodesElem.style.top = `${top + 2000}px`; this.episodesElem.style.top = `${top + 2000}px`;
if (lodash.isEqual(data.type, 'season')) { if (lodash.isEqual(data.type, 'season')) {
const episodesData = await this.plex.getLibraryData(data.key.split('/')[3]); const episodesData = await this.plex.getLibraryData(data.key);
lodash.forEach(episodesData, episodeData => { lodash.forEach(episodesData, episodeData => {
if (this.episodesElem && this.playController && this.plex) { if (this.episodesElem && this.playController && this.plex) {
this.episodesElem.append(createEpisodesView(this.playController, this.plex, episodeData, this.fontSize1, this.fontSize2)); this.episodesElem.append(createEpisodesView(this.playController, this.plex, episodeData, this.fontSize1, this.fontSize2));
@ -23485,8 +23530,11 @@ class PlexMeetsHomeAssistant extends HTMLElement {
movieElem.className = 'movieElem'; movieElem.className = 'movieElem';
movieElem.style.width = `${CSS_STYLE.width}px`; movieElem.style.width = `${CSS_STYLE.width}px`;
movieElem.style.height = `${CSS_STYLE.height}px`; movieElem.style.height = `${CSS_STYLE.height}px`;
if (!lodash.isNil(data.channelCallSign) || lodash.isEqual(data.type, 'artist') || lodash.isEqual(data.type, 'album')) { if (!lodash.isNil(data.channelCallSign) ||
if (!lodash.isEqual(data.type, 'artist') && !lodash.isEqual(data.type, 'album')) { lodash.isEqual(data.type, 'artist') ||
lodash.isEqual(data.type, 'album') ||
lodash.includes(data.key, 'folder')) {
if (!lodash.isEqual(data.type, 'artist') && !lodash.isEqual(data.type, 'album') && !lodash.includes(data.key, 'folder')) {
movieElem.style.backgroundSize = '80%'; movieElem.style.backgroundSize = '80%';
} }
movieElem.style.backgroundColor = 'rgba(0,0,0,0.2)'; movieElem.style.backgroundColor = 'rgba(0,0,0,0.2)';

@ -797,8 +797,16 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
typeItems.appendChild(addDropdownItem('', '')); typeItems.appendChild(addDropdownItem('', ''));
let typeAvailable = false; let typeAvailable = false;
_.forEach(types, (sectionType: Record<string, any>) => { _.forEach(types, (sectionType: Record<string, any>) => {
if (sectionType.type !== 'folder' && sectionType.type !== 'track' && sectionType.type !== 'episode') { if (
const key = sectionType.key.split('type=')[1]; sectionType.type !== 'track' &&
sectionType.type !== 'episode' &&
(sectionType.type !== 'folder' ||
(sectionType.type === 'folder' && _.isEqual(_.get(libraryData, '[0].viewGroup'), 'artist')))
) {
let key = sectionType.key.split('type=')[1];
if (sectionType.type === 'folder') {
key = 'folder';
}
if (_.isEqual(key, this.config.displayType)) { if (_.isEqual(key, this.config.displayType)) {
typeAvailable = true; typeAvailable = true;
} }
@ -835,7 +843,7 @@ class PlexMeetsHomeAssistantEditor extends HTMLElement {
}); });
} }
const sortFields = _.get(libraryData, `[0].Meta.Type[${displayTypeIndex}].Sort`); const sortFields = _.get(libraryData, `[0].Meta.Type[${displayTypeIndex}].Sort`);
if (!_.isNil(sortFields) && sortFields.length > 0) { if (!_.isNil(sortFields) && sortFields.length > 0 && this.config.displayType !== 'folder') {
_.forEach(sortFields, (sortField: Record<string, any>) => { _.forEach(sortFields, (sortField: Record<string, any>) => {
sortItems.appendChild(addDropdownItem(sortField.key)); sortItems.appendChild(addDropdownItem(sortField.key));
}); });

@ -507,6 +507,11 @@ class PlayController {
return playButton; return playButton;
}; };
setPlayActionDisplay = (displayValue: string): void => {
const playActionButton = this.updateDetailPlayAction();
playActionButton.style.display = displayValue;
};
setPlayActionButtonType = (mediaType: string): void => { setPlayActionButtonType = (mediaType: string): void => {
const playActionButton = this.updateDetailPlayAction(); const playActionButton = this.updateDetailPlayAction();
playActionButton.setAttribute('data-mediaType', mediaType); playActionButton.setAttribute('data-mediaType', mediaType);

@ -259,11 +259,19 @@ class Plex {
private getSectionDataWithoutProcessing = async (sectionID: string, type: string | false = false): Promise<any> => { private getSectionDataWithoutProcessing = async (sectionID: string, type: string | false = false): Promise<any> => {
const bulkItems = 50; const bulkItems = 50;
let url = this.authorizeURL(`${this.getBasicURL()}/library/sections/${sectionID}/all`); let url = `${this.getBasicURL()}/library/sections/${sectionID}`;
url += `&sort=${this.sort}`;
if (type) { if (type) {
url += `&type=${type}`; if (_.isEqual(type, 'folder')) {
url += `/folder`;
} else {
url += `/all`;
url += `?type=${type}`;
} }
} else {
url += `/all`;
}
url = this.authorizeURL(url);
url += `&sort=${this.sort}`;
url += `&includeCollections=1&includeExternalMedia=1&includeAdvanced=1&includeMeta=1`; url += `&includeCollections=1&includeExternalMedia=1&includeAdvanced=1&includeMeta=1`;
let result: Record<string, any> = {}; let result: Record<string, any> = {};
try { try {
@ -543,8 +551,8 @@ class Plex {
).data.MediaContainer.Metadata[0]; ).data.MediaContainer.Metadata[0];
}; };
getLibraryData = async (id: number): Promise<any> => { getLibraryData = async (path: string): Promise<any> => {
const url = this.authorizeURL(`${this.getBasicURL()}/library/metadata/${id}/children`); const url = this.authorizeURL(`${this.getBasicURL()}${path}`);
return ( return (
await axios.get(url, { await axios.get(url, {
timeout: this.requestTimeout timeout: this.requestTimeout

@ -232,7 +232,11 @@ const createTrackView = (
const trackTitleElem = document.createElement('td'); const trackTitleElem = document.createElement('td');
trackTitleElem.className = 'trackTitleElem'; trackTitleElem.className = 'trackTitleElem';
if (!_.isEmpty(data.title)) {
trackTitleElem.innerHTML = escapeHtml(data.title); trackTitleElem.innerHTML = escapeHtml(data.title);
} else if (!_.isEmpty(data.titleSort)) {
trackTitleElem.innerHTML = escapeHtml(data.titleSort);
}
trackTitleElem.style.fontSize = `${fontSize1}px`; trackTitleElem.style.fontSize = `${fontSize1}px`;
trackTitleElem.style.lineHeight = `${fontSize1}px`; trackTitleElem.style.lineHeight = `${fontSize1}px`;

@ -197,6 +197,28 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
}; };
resizeHandler = (): void => {
if (this.isVisible) {
if (!this.detailsShown) {
const videoPlayer = this.getElementsByClassName('videoPlayer')[0] as HTMLElement;
let isFullScreen = false;
if (videoPlayer.children.length > 0) {
isFullScreen = isVideoFullScreen(this);
}
if (this.card && this.movieElems.length > 0 && !isFullScreen) {
if (this.previousPageWidth !== this.card.offsetWidth) {
this.previousPageWidth = this.card.offsetWidth;
this.renderPage();
const contentbg = this.getElementsByClassName('contentbg');
this.contentBGHeight = getHeight(contentbg[0] as HTMLElement);
}
}
}
this.renderNewElementsIfNeeded();
}
};
loadInitialData = async (): Promise<void> => { loadInitialData = async (): Promise<void> => {
this.initialDataLoaded = true; this.initialDataLoaded = true;
setInterval(() => { setInterval(() => {
@ -252,25 +274,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.renderNewElementsIfNeeded(); this.renderNewElementsIfNeeded();
}); });
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
if (this.isVisible) { this.resizeHandler();
if (!this.detailsShown) {
const videoPlayer = this.getElementsByClassName('videoPlayer')[0] as HTMLElement;
let isFullScreen = false;
if (videoPlayer.children.length > 0) {
isFullScreen = isVideoFullScreen(this);
}
if (this.card && this.movieElems.length > 0 && !isFullScreen) {
if (this.previousPageWidth !== this.card.offsetWidth) {
this.previousPageWidth = this.card.offsetWidth;
this.renderPage();
const contentbg = this.getElementsByClassName('contentbg');
this.contentBGHeight = getHeight(contentbg[0] as HTMLElement);
}
}
}
this.renderNewElementsIfNeeded();
}
}); });
if (this.card) { if (this.card) {
@ -968,15 +972,9 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (this.movieElems[i].offsetLeft === 0) { if (this.movieElems[i].offsetLeft === 0) {
break; break;
} else { } else {
this.resizeHandler();
clearInterval(setLeftOffsetsInterval); clearInterval(setLeftOffsetsInterval);
} }
/*
this.movieElems[i].style.left = `${this.movieElems[i].offsetLeft}px`;
this.movieElems[i].dataset.left = this.movieElems[i].offsetLeft;
this.movieElems[i].style.top = `${this.movieElems[i].offsetTop}px`;
this.movieElems[i].dataset.top = this.movieElems[i].offsetTop;
this.movieElems[i].style.position = 'absolute';
*/
} }
}, 100); }, 100);
}; };
@ -1185,7 +1183,12 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.detailElem.style.transition = '0s'; this.detailElem.style.transition = '0s';
this.detailElem.style.top = `${top - 1000}px`; this.detailElem.style.top = `${top - 1000}px`;
if (!_.isEmpty(_.get(data, 'thumb'))) {
this.detailElem.style.left = `${this.minExpandedWidth + 30}px`; this.detailElem.style.left = `${this.minExpandedWidth + 30}px`;
} else {
this.detailElem.style.left = `16px`;
}
clearInterval(this.showDetailsTimeout); clearInterval(this.showDetailsTimeout);
// eslint-disable-next-line @typescript-eslint/no-misused-promises // eslint-disable-next-line @typescript-eslint/no-misused-promises
this.showDetailsTimeout = setTimeout(async () => { this.showDetailsTimeout = setTimeout(async () => {
@ -1339,13 +1342,28 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (this.plex) { if (this.plex) {
let childrenData: Record<string, any> = {}; let childrenData: Record<string, any> = {};
if (_.isEqual(data.type, 'episode')) { if (_.isEqual(data.type, 'episode')) {
childrenData = await this.plex.getLibraryData(data.grandparentKey.split('/')[3]); childrenData = await this.plex.getLibraryData(`${data.grandparentKey}/children`);
} else if (data.childCount > 0 || _.isEqual(data.type, 'artist') || _.isEqual(data.type, 'album')) { } else if (
childrenData = await this.plex.getLibraryData(data.key.split('/')[3]); data.childCount > 0 ||
_.isEqual(data.type, 'artist') ||
_.isEqual(data.type, 'album') ||
_.includes(data.key, 'folder')
) {
childrenData = await this.plex.getLibraryData(data.key);
}
if (this.playController) {
if (_.includes(data.key, 'folder')) {
this.playController.setPlayActionDisplay('none');
} else {
this.playController.setPlayActionDisplay('block');
}
} }
let dataDetails: Record<string, any> = {}; let dataDetails: Record<string, any> = {};
if (!_.isNil(data.key)) { if (!_.isNil(data.key)) {
if (!_.includes(data.key, 'folder')) {
dataDetails = await this.plex.getDetails(data.key.split('/')[3]); dataDetails = await this.plex.getDetails(data.key.split('/')[3]);
}
if (this.videoElem) { if (this.videoElem) {
const art = this.plex.authorizeURL(this.plex.getBasicURL() + data.art); const art = this.plex.authorizeURL(this.plex.getBasicURL() + data.art);
const trailerURL = findTrailerURL(dataDetails); const trailerURL = findTrailerURL(dataDetails);
@ -1474,9 +1492,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
tableView.style.border = 'none'; tableView.style.border = 'none';
tableView.cellSpacing = '0'; tableView.cellSpacing = '0';
tableView.cellPadding = '0'; tableView.cellPadding = '0';
if (_.isEqual(data.type, 'album')) {
this.episodesElem.append(tableView); this.episodesElem.append(tableView);
}
let isEven = false; let isEven = false;
_.forEach(childrenData, childData => { _.forEach(childrenData, childData => {
if (this.episodesElem && this.playController && this.plex) { if (this.episodesElem && this.playController && this.plex) {
@ -1497,7 +1513,13 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (this.episodesElem) { if (this.episodesElem) {
this.episodesElem.style.transition = `0.7s`; this.episodesElem.style.transition = `0.7s`;
if (this.activeMovieElem) { if (this.activeMovieElem) {
if (!_.isEmpty(_.get(data, 'thumb'))) {
this.episodesElem.style.top = `${top + getHeight(this.activeMovieElem) + 16 * 2}px`; this.episodesElem.style.top = `${top + getHeight(this.activeMovieElem) + 16 * 2}px`;
} else if (this.detailElem) {
this.episodesElem.style.top = `${top + getHeight(this.detailElem)}px`;
} else {
this.episodesElem.style.top = `${top}px`;
}
} else { } else {
this.episodesElem.style.top = `${top + this.minExpandedHeight + 16}px`; this.episodesElem.style.top = `${top + this.minExpandedHeight + 16}px`;
} }
@ -1513,7 +1535,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} else { } else {
_.forEach(childrenData, childData => { _.forEach(childrenData, childData => {
if (this.seasonsElem && this.plex) { if (this.seasonsElem && this.plex) {
console.log(childData);
this.seasonsElemHidden = false; this.seasonsElemHidden = false;
const seasonContainer = document.createElement('div'); const seasonContainer = document.createElement('div');
seasonContainer.className = 'seasonContainer'; seasonContainer.className = 'seasonContainer';
@ -1649,7 +1670,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
(async (): Promise<void> => { (async (): Promise<void> => {
if (this.plex && (childData.leafCount > 0 || _.isEqual(childData.type, 'album'))) { if (this.plex && (childData.leafCount > 0 || _.isEqual(childData.type, 'album'))) {
this.episodesElemFreshlyLoaded = true; this.episodesElemFreshlyLoaded = true;
const episodesData = await this.plex.getLibraryData(childData.key.split('/')[3]); const episodesData = await this.plex.getLibraryData(childData.key);
if (this.episodesElem) { if (this.episodesElem) {
this.episodesElemHidden = false; this.episodesElemHidden = false;
this.episodesElem.style.display = 'block'; this.episodesElem.style.display = 'block';
@ -1784,7 +1805,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.episodesElem.style.transition = `0s`; this.episodesElem.style.transition = `0s`;
this.episodesElem.style.top = `${top + 2000}px`; this.episodesElem.style.top = `${top + 2000}px`;
if (_.isEqual(data.type, 'season')) { if (_.isEqual(data.type, 'season')) {
const episodesData = await this.plex.getLibraryData(data.key.split('/')[3]); const episodesData = await this.plex.getLibraryData(data.key);
_.forEach(episodesData, episodeData => { _.forEach(episodesData, episodeData => {
if (this.episodesElem && this.playController && this.plex) { if (this.episodesElem && this.playController && this.plex) {
this.episodesElem.append( this.episodesElem.append(
@ -1946,8 +1967,13 @@ class PlexMeetsHomeAssistant extends HTMLElement {
movieElem.style.width = `${CSS_STYLE.width}px`; movieElem.style.width = `${CSS_STYLE.width}px`;
movieElem.style.height = `${CSS_STYLE.height}px`; movieElem.style.height = `${CSS_STYLE.height}px`;
if (!_.isNil(data.channelCallSign) || _.isEqual(data.type, 'artist') || _.isEqual(data.type, 'album')) { if (
if (!_.isEqual(data.type, 'artist') && !_.isEqual(data.type, 'album')) { !_.isNil(data.channelCallSign) ||
_.isEqual(data.type, 'artist') ||
_.isEqual(data.type, 'album') ||
_.includes(data.key, 'folder')
) {
if (!_.isEqual(data.type, 'artist') && !_.isEqual(data.type, 'album') && !_.includes(data.key, 'folder')) {
movieElem.style.backgroundSize = '80%'; movieElem.style.backgroundSize = '80%';
} }
movieElem.style.backgroundColor = 'rgba(0,0,0,0.2)'; movieElem.style.backgroundColor = 'rgba(0,0,0,0.2)';

Loading…
Cancel
Save