move shows to own file

This commit is contained in:
Karl0ss 2022-10-26 10:15:08 +01:00
parent cefd13c8da
commit 12d8c65c39
6 changed files with 18 additions and 16 deletions

View File

@ -5,8 +5,8 @@ const { checkFileName } = require('./checkFileName')
const { checkDownloadHistory } = require('./checkDownloadHistory')
async function filterFeed() {
let myshowlist = JSON.parse(fs.readFileSync('config.json')).Shows
let hevcSwitch = JSON.parse(fs.readFileSync('config.json')).OnlyHEVC
let myshowlist = JSON.parse(fs.readFileSync('shows.json'))
let feed = JSON.parse(fs.readFileSync('./feedCache.json'));
let retryShowCache = []
let urlsToCheck = []

View File

@ -1,10 +1,10 @@
const fs = require('fs');
const { config } = require('process');
async function addNewShow(showData) {
let config = JSON.parse(fs.readFileSync('config.json'))
let shows = JSON.parse(fs.readFileSync('shows.json'))
let exist = false
for (let show of config.Shows) {
for (let show of shows) {
if (show.Name == showData.showName) {
exist = true
}
@ -12,12 +12,12 @@ async function addNewShow(showData) {
if (exist) {
log.error(showData.showName + ' Already exists in list and not added')
} else {
config.Shows.push({
shows.push({
"Name": showData.showName,
"Quality": showData.quality
})
try {
fs.writeFileSync('config.json', JSON.stringify(config));
fs.writeFileSync('shows.json', JSON.stringify(shows));
log.info(showData.showName + ' Added to the list, checking for ' + showData.quality + 'p')
} catch (err) {
console.error(err);
@ -26,15 +26,15 @@ async function addNewShow(showData) {
}
async function removeShow(showData) {
let config = JSON.parse(fs.readFileSync('config.json'))
let shows = JSON.parse(fs.readFileSync('shows.json'))
myArray = config.Shows.filter(function (obj) {
myArray = shows.filter(function (obj) {
return obj.Name !== showData.showName;
});
config.Shows = myArray
shows = myArray
try {
fs.writeFileSync('config.json', JSON.stringify(config));
fs.writeFileSync('shows.json', JSON.stringify(shows));
log.info(showData.showName + ' Removed from tracking list.')
} catch (err) {
console.error(err);

View File

@ -4,8 +4,9 @@ const { nextLinkCheck, nextRssRefresh } = require('.././utils')
module.exports = function (app) {
app.get("/", (req, res) => {
showListLength = JSON.parse(fs.readFileSync('config.json')).Shows.length
a =
res.render("index", { title: "Home", showListLength: showListLength, version: global.version, rssTime: nextRssRefresh(), linkCheck: nextLinkCheck() });
showListLength = JSON.parse(fs.readFileSync('shows.json')).length
rssTime = nextRssRefresh()
linkCheck = nextLinkCheck()
res.render("index", { title: "Home", showListLength: showListLength, version: global.version, rssTime: rssTime, linkCheck: linkCheck });
});
}

View File

@ -3,7 +3,7 @@ const { addNewShow, removeShow } = require('.././apiFunctions')
module.exports = function (app) {
app.get("/shows", (req, res) => {
showList = JSON.parse(fs.readFileSync('config.json')).Shows
showList = JSON.parse(fs.readFileSync('shows.json'))
res.render("shows", { title: "Show List", showList: showList });
});
@ -12,7 +12,7 @@ module.exports = function (app) {
});
app.get("/shows/remove", (req, res) => {
showList = JSON.parse(fs.readFileSync('config.json')).Shows
showList = JSON.parse(fs.readFileSync('shows.json'))
res.render("removeshow", { title: "Remove Show", showList: showList });
});

1
shows.json Normal file
View File

@ -0,0 +1 @@
[]

View File

@ -4,7 +4,7 @@ html
head
meta(charset="utf-8")
link(rel="shortcut icon", href="/favicon.ico")
meta(name="viewport", content="width=device-width, initial-scale=1, shrink-to-fit=no")
meta(name="viewport", content="width=device-width, initial-scale=1, shrink-to-fit=yes")
meta(name="theme-color", content="#000000")
title #{title} | JDRssDownloader
link(rel="stylesheet" href="/style.css")