Skip to content

Commit

Permalink
Exclude selected librarie(s) from now screening.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersem committed Sep 25, 2024
1 parent 37e213f commit 180b753
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 9 deletions.
3 changes: 3 additions & 0 deletions classes/core/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion classes/mediaservers/plex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ const DEFAULT_SETTINGS = {
enableAwtrix: "false",
awtrixIP: "",
enableLinks: "false",
links: ""
links: "",
excludeLibs: ""
};

module.exports = DEFAULT_SETTINGS;
15 changes: 14 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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){
Expand Down Expand Up @@ -1894,6 +1906,7 @@ app.post(
enableLinks: req.body.enableLinks,
links: req.body.links,
rotate: req.body.rotate,
excludeLibs: req.body.excludeLibs,
saved: false
};

Expand Down
6 changes: 6 additions & 0 deletions myviews/settings.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,12 @@
<small id="filterUsersHelp" class="form-text text-muted">Enter user names to include (Comma seperated and no spaces. Leave blank for all users)</small>
</div>
<div class="form-group">
<label for="excludeLibs">Exclude libraries</label>
<input type="text" class="form-control" id="excludeLibs" name="excludeLibs" aria-describedby="excludeLibsHelp"
placeholder="examples -> TV Shows,Movies" value="<% if(typeof formData !== 'undefined' && errors){%><%=formData.excludeLibs%>"<%}else{%><%=settings.excludeLibs%>"<%}%>>
<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>
</div>
<div class="form-group">
<div class="custom-control custom-control-nolabel custom-switch ml-auto">
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "posterr",
"version": "1.20.0",
"version": "1.21.0",
"description": "A digital display for your media",
"main": "index.js",
"bin": "index.js",
Expand Down

0 comments on commit 180b753

Please sign in to comment.