diff --git a/classes/core/settings.js b/classes/core/settings.js index f106181..a54fced 100644 --- a/classes/core/settings.js +++ b/classes/core/settings.js @@ -83,6 +83,7 @@ class Settings { this.enableLinks = DEFAULT_SETTINGS.enableLinks; this.links = DEFAULT_SETTINGS.links; this.rotate = DEFAULT_SETTINGS.rotate; + this.excludeLibs = DEFAULT_SETTINGS.excludeLibs; return; } @@ -377,6 +378,8 @@ class Settings { else this.awtrixIP = cs.awtrixIP; if (jsonObject.rotate) this.rotate = jsonObject.rotate; else this.rotate = cs.rotate; + if (jsonObject.excludeLibs) this.excludeLibs = jsonObject.excludeLibs; + else this.excludeLibs = cs.excludeLibs; // convert JSON object to string (pretty format) const data = JSON.stringify(this, null, 4); diff --git a/classes/mediaservers/plex.js b/classes/mediaservers/plex.js index 7f8bbe9..ac2314a 100644 --- a/classes/mediaservers/plex.js +++ b/classes/mediaservers/plex.js @@ -59,7 +59,7 @@ class Plex { * @desc Gets now screening cards * @returns {object} mediaCard[] - Returns an array of mediaCards */ - async GetNowScreening(playThemes, playGenenericThemes, hasArt, filterRemote, filterLocal, filterDevices, filterUsers, hideUser) { + async GetNowScreening(playThemes, playGenenericThemes, hasArt, filterRemote, filterLocal, filterDevices, filterUsers, hideUser, excludeLibs) { // get raw data first let nsCards = []; let nsRaw; @@ -478,6 +478,10 @@ class Plex { if(filterLocal=='true' && medCard.playerLocal == true) okToAdd = true; if(users.length > 0 && users.includes(md.User.title.toLowerCase())==false && users[0] !== "") okToAdd = false; if(devices.length > 0 && devices.includes(medCard.playerDevice.toLowerCase())==false && devices[0] !== "") okToAdd = false; + if(excludeLibs !== undefined && excludeLibs !== "" && excludeLibs.includes(md.librarySectionTitle)) { + //console.log('Now Screening - Excluded library:', md.librarySectionTitle); + okToAdd = false; + } // add if all criteria matched if(okToAdd) { diff --git a/consts.js b/consts.js index dde63d6..5bac179 100644 --- a/consts.js +++ b/consts.js @@ -68,7 +68,8 @@ const DEFAULT_SETTINGS = { enableAwtrix: "false", awtrixIP: "", enableLinks: "false", - links: "" + links: "", + excludeLibs: "" }; module.exports = DEFAULT_SETTINGS; \ No newline at end of file diff --git a/index.js b/index.js index b20eac6..b6605a0 100644 --- a/index.js +++ b/index.js @@ -120,6 +120,7 @@ let oldAwtrixApps = []; let isAwtrixEnabled = false; let awtrixIP = ""; let restartSeconds = 86400000; +let excludeLibs = ""; // create working folders if they do not exist // needed for package binaries @@ -482,6 +483,16 @@ async function loadNowScreening() { plexToken: loadedSettings.plexToken, }); + let excludeLibraries; + if(loadedSettings.excludeLibs !== undefined && loadedSettings.excludeLibs !== ""){ + excludeLibraries = loadedSettings.excludeLibs.split(","); + + // trim leading and trailing spaces + excludeLibraries = excludeLibraries.map(function (el) { + return el.trim(); + }); + } + let pollInterval = nsCheckSeconds; // call now screening method @@ -494,7 +505,8 @@ async function loadNowScreening() { loadedSettings.filterLocal, loadedSettings.filterDevices, loadedSettings.filterUsers, - loadedSettings.hideUser + loadedSettings.hideUser, + excludeLibraries ); // Send to Awtrix, if enabled if(isAwtrixEnabled){ @@ -1894,6 +1906,7 @@ app.post( enableLinks: req.body.enableLinks, links: req.body.links, rotate: req.body.rotate, + excludeLibs: req.body.excludeLibs, saved: false }; diff --git a/myviews/settings.ejs b/myviews/settings.ejs index 0866621..859c2cf 100644 --- a/myviews/settings.ejs +++ b/myviews/settings.ejs @@ -684,6 +684,12 @@ Enter user names to include (Comma seperated and no spaces. Leave blank for all users) +