edit show quality + last downloaded file

This commit is contained in:
Karl0ss 2022-10-27 10:43:33 +01:00
parent 0cc32b18c9
commit df44638771
7 changed files with 60 additions and 4 deletions

View File

@ -55,6 +55,7 @@ async function filterFeed() {
log.tele(downloadList.length + ' links for ' + urlObj.fileName + ' have been sent to JDdownloader.') log.tele(downloadList.length + ' links for ' + urlObj.fileName + ' have been sent to JDdownloader.')
linkAdder(downloadList) linkAdder(downloadList)
global.linkCheckTime = new Date(); global.linkCheckTime = new Date();
global.lastDownloadedLink = urlObj.fileName
} }
} else { } else {
// No HEVC links found // No HEVC links found

View File

@ -25,6 +25,7 @@ app.use(basicAuth({
global.rssRefreshTime = new Date(); global.rssRefreshTime = new Date();
global.linkCheckTime = new Date(); global.linkCheckTime = new Date();
global.version = require('./package.json').version; global.version = require('./package.json').version;
global.lastDownloadedLink = 'None'
global.log = require('simple-node-logger').createSimpleLogger({ global.log = require('simple-node-logger').createSimpleLogger({
logFilePath: 'jdrssdownloader.log', logFilePath: 'jdrssdownloader.log',

View File

@ -41,7 +41,27 @@ async function removeShow(showData) {
} }
} }
module.exports = {
addNewShow, removeShow async function editShow(showData) {
let shows = JSON.parse(fs.readFileSync('shows.json'))
for (let index = 0; index < shows.length; index++) {
const element = shows[index];
if (element.Name == showData.showName) {
shows[index] = {
"Name": showData.showName,
"Quality": showData.quality
}
}
}
try {
fs.writeFileSync('shows.json', JSON.stringify(shows));
log.info(showData.showName + ' Quality modified to ' + showData.quality + 'p')
} catch (err) {
console.error(err);
}
}
module.exports = {
addNewShow, removeShow, editShow
} }

View File

@ -7,6 +7,6 @@ module.exports = function (app) {
showListLength = JSON.parse(fs.readFileSync('shows.json')).length showListLength = JSON.parse(fs.readFileSync('shows.json')).length
rssTime = nextRssRefresh() rssTime = nextRssRefresh()
linkCheck = nextLinkCheck() linkCheck = nextLinkCheck()
res.render("index", { title: "Home", showListLength: showListLength, version: global.version, rssTime: rssTime, linkCheck: linkCheck }); res.render("index", { title: "Home", showListLength: showListLength, version: global.version, rssTime: rssTime, linkCheck: linkCheck, lastDownloaded: global.lastDownloadedLink });
}); });
} }

View File

@ -1,5 +1,5 @@
const fs = require("fs"); const fs = require("fs");
const { addNewShow, removeShow } = require('.././apiFunctions') const { addNewShow, removeShow, editShow } = require('.././apiFunctions')
module.exports = function (app) { module.exports = function (app) {
app.get("/shows", (req, res) => { app.get("/shows", (req, res) => {
@ -16,6 +16,11 @@ module.exports = function (app) {
res.render("removeshow", { title: "Remove Show", showList: showList }); res.render("removeshow", { title: "Remove Show", showList: showList });
}); });
app.get("/shows/edit", (req, res) => {
showList = JSON.parse(fs.readFileSync('shows.json'))
res.render("editShow", { title: "Edit Show", showList: showList });
});
app.post('/addNewShow', (req, res) => { app.post('/addNewShow', (req, res) => {
addNewShow(req.body) addNewShow(req.body)
res.redirect("/shows"); res.redirect("/shows");
@ -25,4 +30,9 @@ module.exports = function (app) {
removeShow(req.body) removeShow(req.body)
res.redirect("/shows"); res.redirect("/shows");
}); });
app.post('/editShow', (req, res) => {
editShow(req.body)
res.redirect("/shows");
});
} }

20
views/editShow.pug Normal file
View File

@ -0,0 +1,20 @@
extends layout
block layout-content
div.View
h1.Banner Edit Show
div.Message
form(action="/editShow" method="POST")
p Show Name:
select(name="showName")
each show in showList
option(value=show.Name) #{show.Name}
p Quality:
select(name="quality")
option(value='720') #{'720p'}
option(value='1080') #{'1080p'}
option(value='2160') #{'2160p'}
input(type="submit", value="Edit Show")
div.NavButtons
a(href="/")
div.NavButton Home

View File

@ -7,6 +7,8 @@ block layout-content
div.Message div.Message
h3 Number of Tracked Shows h3 Number of Tracked Shows
h1 #{showListLength} h1 #{showListLength}
h3 Last Downloaded
h1 #{lastDownloaded}
h3 Next RSS Refresh h3 Next RSS Refresh
h1 #{rssTime} h1 #{rssTime}
h3 Next Link Check h3 Next Link Check
@ -16,6 +18,8 @@ block layout-content
div.NavButton Show List div.NavButton Show List
a(href="/shows/add") a(href="/shows/add")
div.NavButton Add New Show div.NavButton Add New Show
a(href="/shows/edit")
div.NavButton Edit Show
a(href="/shows/remove") a(href="/shows/remove")
div.NavButton Remove Show div.NavButton Remove Show
a(href="/logFile") a(href="/logFile")