Skip to content

Commit

Permalink
removing links
Browse files Browse the repository at this point in the history
  • Loading branch information
petersem committed Nov 29, 2023
1 parent efa2747 commit 42cee8c
Show file tree
Hide file tree
Showing 11 changed files with 899 additions and 2,085 deletions.
3 changes: 2 additions & 1 deletion classes/cards/CardType.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class CardType {
Picture: ["Picture", ""],
EBook: ["E-Book Release", ""],
Trivia: ["Trivia Question", ""],
RecentlyAdded: ["Recently Added", ""]
RecentlyAdded: ["Recently Added", ""],
WebURL: ["WebURL", ""]
};
}

Expand Down
15 changes: 14 additions & 1 deletion classes/cards/MediaCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class MediaCard {
this.triviaDifficulty = "";
this.runDuration = "";
this.runProgress = "";
this.linkUrl = "";
}

/**
Expand All @@ -64,7 +65,7 @@ class MediaCard {
if(hideTitle=='true' && this.cardType[0] == "On-demand") hiddenTitle = "hidden";
if(hideFooter=='true' && this.cardType[0] == "On-demand") hiddenFooter = "hidden";
if(hiddenTitle !== "" && hiddenFooter !== "") fullScreen="fullscreen";
if(this.cardType[0] == "Picture" || this.cardType == "Trivia Question"){
if(this.cardType[0] == "Picture" || this.cardType == "Trivia Question" || this.cardType == "WebURL"){
hiddenTitle="hidden";
hiddenFooter="hidden";
if(hasArt && this.posterArtURL !== ""){
Expand Down Expand Up @@ -118,6 +119,15 @@ class MediaCard {
</div>`;
}

if(this.cardType[0] == "WebURL"){
hiddenFooter = "hidden";
fullScreen="fullscreen";
hiddenTitle="hidden";
//this.linkRender = `<embed type="text/html" src="` + this.linkUrl + `" width=100% height=100%>`
this.linkRender = `<iframe scrolling="no" src="` + this.linkUrl + `" width=100% height=100% style="border: none; overflow: hidden;" >`
}


// pill variables
let contentRatingPill = "";
let resCodecPill = "";
Expand Down Expand Up @@ -291,6 +301,9 @@ class MediaCard {
<div class="hidden" id="poster` + this.ID + `AR">`+this.posterAR+`</div>` +
this.triviaRender +
`</div>
<div class="hidden" id="link` + this.ID + `AR"></div>` +
this.linkRender +
`</div>
<div class="bottomBanner mx-auto transparent` +
` ` + hiddenFooter +
Expand Down
2 changes: 1 addition & 1 deletion classes/core/globalPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class globalPage {
} else {
card.active = "";
}
// console.log(card);
// console.log(card);
await card.Render(hasArt,baseUrl,hideTitle,hideFooter);
}, undefined);
}
Expand Down
13 changes: 12 additions & 1 deletion classes/core/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class Settings {
this.pinNS = DEFAULT_SETTINGS.pinNS;
this.hideUser = DEFAULT_SETTINGS.hideUser;
this.contentRatings = DEFAULT_SETTINGS.contentRatings;
this.links = DEFAULT_SETTINGS.links;
this.enableLinks = DEFAULT_SETTINGS.enableLinks;
this.linkFrequency = DEFAULT_SETTINGS.linkFrequency;
return;
}

Expand Down Expand Up @@ -130,12 +133,14 @@ class Settings {
if(readSettings.enableSonarr==undefined) readSettings.enableSonarr = 'true';
if(readSettings.enableReadarr==undefined) readSettings.enableReadarr = 'true';
if(readSettings.enableRadarr==undefined) readSettings.enableRadarr = 'true';
if(readSettings.enableLinks==undefined) readSettings.enableLinks = "false";
if(readSettings.filterRemote==undefined) readSettings.filterRemote = 'true';
if(readSettings.filterLocal==undefined) readSettings.filterLocal = 'true';
if(readSettings.enableCustomPictures==undefined) readSettings.enableCustomPictures = 'false';
if(readSettings.customPictureTheme==undefined) readSettings.customPictureTheme = 'default';
if(readSettings.enableSleep==undefined) readSettings.enableSleep = 'false';
if(readSettings.enableTrivia==undefined) readSettings.enableTrivia = 'false';
if(readSettings.enableLinks==undefined) readSettings.enableLinks = 'false';
if(readSettings.recentlyAddedDays==undefined) readSettings.recentlyAddedDays = 0;
} catch (ex) {
// do nothing if error as it reads ok anyhow
Expand Down Expand Up @@ -167,6 +172,7 @@ class Settings {
this.enableRadarr = 'false';
this.enableReadarr = 'false';
this.enableTrivia = 'false';
this.enableLinks = 'false';

const data = JSON.stringify(this, null, 4);

Expand Down Expand Up @@ -355,7 +361,12 @@ class Settings {
else this.triviaFrequency = cs.triviaFrequency;
if (jsonObject.contentRatings) this.contentRatings = jsonObject.contentRatings;
else this.contentRatings = cs.contentRatings;

if (jsonObject.links) this.links = jsonObject.links;
else this.links = cs.links;
if (jsonObject.enableLinks) this.enableLinks = jsonObject.enableLinks;
else this.enableLinks = cs.enableLinks;
if (jsonObject.linkFrequency) this.linkFrequency = jsonObject.linkFrequency;
else this.linkFrequency = cs.linkFrequency;
// convert JSON object to string (pretty format)
const data = JSON.stringify(this, null, 4);

Expand Down
64 changes: 64 additions & 0 deletions classes/custom/links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const mediaCard = require("../cards/MediaCard");
const cType = require("../cards/CardType");
const util = require('util');
const axios = require("axios");
const { CardTypeEnum } = require("../cards/CardType");

/**
* @desc Used to get a list of custom pictures
*/
class Links {
constructor() { }

/**
* @desc Custom link slide array
*/
async GetAllLinks(linksArray) {
let allLinkCards = [];
// get link cards
for (const linkURL of linksArray) {
const linkSet = await this.GetLinkCard(linkURL);
if(linkSet.length !== 0) {
allLinkCards = allLinkCards.concat(linkSet);
}
}

let now = new Date();
if (allLinkCards.length == 0) {
console.log(
now.toLocaleString() + " No links found");
} else {
console.log(
now.toLocaleString() + " Links added");
}
return allLinkCards;
}


/**
* @desc Custom link card
*/
async GetLinkCard(url) {
let linkCards = [];
// reutrn an empty array if no results
if (url !== null) {
// move through results and populate media cards
const medCard = new mediaCard();
medCard.cardType = cType.CardTypeEnum.WebURL;
medCard.mediaType = "WebURL";
medCard.linkUrl = url;
medCard.posterAR = 0;
medCard.theme = "";
medCard.posterURL = "";
medCard.posterArtURL = "";
//console.log(medCard);
linkCards.push(medCard);
}

let now = new Date();
//console.log(linkCards);
return linkCards;
}
}

module.exports = Links;
12 changes: 11 additions & 1 deletion classes/custom/trivia.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Trivia {
* @desc Gets results from triviadb api call
*/
async GetRawData(numberOfQuestions, category, hasThemes, token){

let response;
// call sonarr API and return results
try {
Expand All @@ -54,6 +55,13 @@ class Trivia {
if(token !== undefined && token.length !== 0 && token !== 'false'){
apiToken = "&token=" + token
}
console.log("https://opentdb.com/api.php?amount=" +
numberOfQuestions +
"&category=" +
category +
apiToken)


response = await axios
.get(
"https://opentdb.com/api.php?amount=" +
Expand Down Expand Up @@ -145,7 +153,10 @@ class Trivia {
let trivCards = [];

// get questions for specific category

const raw = await this.GetRawData(numberOfQuestions,questionCategory, hasThemes, token);


// reutrn an empty array if no results
if (raw !== null) {
// move through results and populate media cards
Expand Down Expand Up @@ -199,7 +210,6 @@ class Trivia {
// console.log(
// now.toLocaleString() + " Trivia questions added");
}

return trivCards;
}
}
Expand Down
1 change: 0 additions & 1 deletion classes/mediaservers/plex.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,6 @@ class Plex {
// calculate for recently added (if set)
var includeTitle = false;
medCard.cardType = md.ctype;

// add media card to array
odCards.push(medCard);

Expand Down
4 changes: 3 additions & 1 deletion consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ const DEFAULT_SETTINGS = {
triviaCategories: "",
enableTrivia: "false",
triviaNumber: "",
contentRatings: ""
contentRatings: "",
links: "",
enableLinks: "false"
};

module.exports = DEFAULT_SETTINGS;
Loading

0 comments on commit 42cee8c

Please sign in to comment.