Skip to content

Commit 180b753

Browse files
committed
Exclude selected librarie(s) from now screening.
1 parent 37e213f commit 180b753

File tree

7 files changed

+36
-9
lines changed

7 files changed

+36
-9
lines changed

classes/core/settings.js

+3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class Settings {
8383
this.enableLinks = DEFAULT_SETTINGS.enableLinks;
8484
this.links = DEFAULT_SETTINGS.links;
8585
this.rotate = DEFAULT_SETTINGS.rotate;
86+
this.excludeLibs = DEFAULT_SETTINGS.excludeLibs;
8687
return;
8788
}
8889

@@ -377,6 +378,8 @@ class Settings {
377378
else this.awtrixIP = cs.awtrixIP;
378379
if (jsonObject.rotate) this.rotate = jsonObject.rotate;
379380
else this.rotate = cs.rotate;
381+
if (jsonObject.excludeLibs) this.excludeLibs = jsonObject.excludeLibs;
382+
else this.excludeLibs = cs.excludeLibs;
380383

381384
// convert JSON object to string (pretty format)
382385
const data = JSON.stringify(this, null, 4);

classes/mediaservers/plex.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Plex {
5959
* @desc Gets now screening cards
6060
* @returns {object} mediaCard[] - Returns an array of mediaCards
6161
*/
62-
async GetNowScreening(playThemes, playGenenericThemes, hasArt, filterRemote, filterLocal, filterDevices, filterUsers, hideUser) {
62+
async GetNowScreening(playThemes, playGenenericThemes, hasArt, filterRemote, filterLocal, filterDevices, filterUsers, hideUser, excludeLibs) {
6363
// get raw data first
6464
let nsCards = [];
6565
let nsRaw;
@@ -478,6 +478,10 @@ class Plex {
478478
if(filterLocal=='true' && medCard.playerLocal == true) okToAdd = true;
479479
if(users.length > 0 && users.includes(md.User.title.toLowerCase())==false && users[0] !== "") okToAdd = false;
480480
if(devices.length > 0 && devices.includes(medCard.playerDevice.toLowerCase())==false && devices[0] !== "") okToAdd = false;
481+
if(excludeLibs !== undefined && excludeLibs !== "" && excludeLibs.includes(md.librarySectionTitle)) {
482+
//console.log('Now Screening - Excluded library:', md.librarySectionTitle);
483+
okToAdd = false;
484+
}
481485

482486
// add if all criteria matched
483487
if(okToAdd) {

consts.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ const DEFAULT_SETTINGS = {
6868
enableAwtrix: "false",
6969
awtrixIP: "",
7070
enableLinks: "false",
71-
links: ""
71+
links: "",
72+
excludeLibs: ""
7273
};
7374

7475
module.exports = DEFAULT_SETTINGS;

index.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ let oldAwtrixApps = [];
120120
let isAwtrixEnabled = false;
121121
let awtrixIP = "";
122122
let restartSeconds = 86400000;
123+
let excludeLibs = "";
123124

124125
// create working folders if they do not exist
125126
// needed for package binaries
@@ -482,6 +483,16 @@ async function loadNowScreening() {
482483
plexToken: loadedSettings.plexToken,
483484
});
484485

486+
let excludeLibraries;
487+
if(loadedSettings.excludeLibs !== undefined && loadedSettings.excludeLibs !== ""){
488+
excludeLibraries = loadedSettings.excludeLibs.split(",");
489+
490+
// trim leading and trailing spaces
491+
excludeLibraries = excludeLibraries.map(function (el) {
492+
return el.trim();
493+
});
494+
}
495+
485496

486497
let pollInterval = nsCheckSeconds;
487498
// call now screening method
@@ -494,7 +505,8 @@ async function loadNowScreening() {
494505
loadedSettings.filterLocal,
495506
loadedSettings.filterDevices,
496507
loadedSettings.filterUsers,
497-
loadedSettings.hideUser
508+
loadedSettings.hideUser,
509+
excludeLibraries
498510
);
499511
// Send to Awtrix, if enabled
500512
if(isAwtrixEnabled){
@@ -1894,6 +1906,7 @@ app.post(
18941906
enableLinks: req.body.enableLinks,
18951907
links: req.body.links,
18961908
rotate: req.body.rotate,
1909+
excludeLibs: req.body.excludeLibs,
18971910
saved: false
18981911
};
18991912

myviews/settings.ejs

+6
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,12 @@
684684
<small id="filterUsersHelp" class="form-text text-muted">Enter user names to include (Comma seperated and no spaces. Leave blank for all users)</small>
685685
</div>
686686
687+
<div class="form-group">
688+
<label for="excludeLibs">Exclude libraries</label>
689+
<input type="text" class="form-control" id="excludeLibs" name="excludeLibs" aria-describedby="excludeLibsHelp"
690+
placeholder="examples -> TV Shows,Movies" value="<% if(typeof formData !== 'undefined' && errors){%><%=formData.excludeLibs%>"<%}else{%><%=settings.excludeLibs%>"<%}%>>
691+
<small id="excludeLibsHelp" class="form-text text-muted">Enter any libraries to exclude (Comma seperated and no leading or trailing spaces. Leave blank to include all libraries)</small>
692+
</div>
687693
688694
<div class="form-group">
689695
<div class="custom-control custom-control-nolabel custom-switch ml-auto">

package-lock.json

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "posterr",
3-
"version": "1.20.0",
3+
"version": "1.21.0",
44
"description": "A digital display for your media",
55
"main": "index.js",
66
"bin": "index.js",

0 commit comments

Comments
 (0)