post validation, rework last downloaded, upversion

This commit is contained in:
Karl0ss 2022-10-27 13:58:36 +01:00
parent df44638771
commit bb2e58e624
8 changed files with 42 additions and 20 deletions

View File

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

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "jdrssdownloader",
"version": "1.1.0",
"version": "1.1.1",
"description": "",
"main": "JDRssDownloader.js",
"bin": "JDRssDownloader.js",
@ -15,6 +15,7 @@
"cors": "^2.8.5",
"express": "^4.18.2",
"express-basic-auth": "^1.2.1",
"express-validator": "^6.14.2",
"jdownloader-client": "^1.0.0",
"line-reader": "^0.4.0",
"lodash": "^4.17.21",

View File

@ -97,9 +97,15 @@ a {
.Message {
background: white;
padding: 30px;
border-radius: 5px;
padding: 20px;
border-bottom: var(--ui-shadow-border);
box-shadow: var(--ui-shadow);
overflow-x: hidden;
overflow-y: auto;
/* text-align: center; */
margin-top:10px;
margin-bottom:10px;
}
.Message > .Title {

View File

@ -1,5 +1,5 @@
const fs = require("fs");
const { nextLinkCheck, nextRssRefresh } = require('.././utils')
const { nextLinkCheck, nextRssRefresh, get_last_downloaded } = require('.././utils')
module.exports = function (app) {
@ -7,6 +7,6 @@ module.exports = function (app) {
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, lastDownloaded: global.lastDownloadedLink });
res.render("index", { title: "Home", showListLength: showListLength, version: global.version, rssTime: rssTime, linkCheck: linkCheck, lastDownloaded: get_last_downloaded() });
});
}

View File

@ -1,5 +1,7 @@
const fs = require("fs");
const { addNewShow, removeShow, editShow } = require('.././apiFunctions')
const { check, validationResult } = require('express-validator');
module.exports = function (app) {
app.get("/shows", (req, res) => {
@ -21,10 +23,19 @@ module.exports = function (app) {
res.render("editShow", { title: "Edit Show", showList: showList });
});
app.post('/addNewShow', (req, res) => {
addNewShow(req.body)
res.redirect("/shows");
});
app.post('/addNewShow', [
check('showName')
.isLength({ min: 1 })
], (req, res) => {
if (validationResult(req).isEmpty()) {
addNewShow(req.body)
res.redirect("/shows");
} else {
log.error('You cannot add a show without a name.')
res.redirect("/shows");
}
}
);
app.post('/removeShow', (req, res) => {
removeShow(req.body)

View File

@ -16,7 +16,13 @@ function nextLinkCheck() {
return returnUpdatedDate(global.linkCheckTime, config.JDPostLinksMins)
}
module.exports = {
nextRssRefresh, nextLinkCheck
function get_last_downloaded(){
history = JSON.parse(fs.readFileSync('./cache/downloadHistory.json'))
last = history.slice(-1)[0]
return last
}
module.exports = {
nextRssRefresh, nextLinkCheck, get_last_downloaded
}

View File

@ -5,14 +5,14 @@ block layout-content
h1.Banner JDRssDownloader #{version}
body
div.Message
h3 Number of Tracked Shows
h1 #{showListLength}
h3 Last Downloaded
h1 #{lastDownloaded}
h3 Next RSS Refresh
h1 #{rssTime}
h3 Next Link Check
h1 #{linkCheck}
h2 Number of Tracked Shows
h3 #{showListLength}
h2 Last Downloaded
h3 #{lastDownloaded}
h2 Next RSS Refresh
h3 #{rssTime}
h2 Next Link Check
h3 #{linkCheck}
div.NavButtons
a(href="/shows")
div.NavButton Show List