upversion and working download history

This commit is contained in:
karl.hudgell 2022-06-18 13:44:16 +01:00
parent 736ec93030
commit 77f2029615
3 changed files with 28 additions and 3 deletions

View File

@ -2,6 +2,7 @@ const fs = require('fs')
const { linkAdder } = require('./JDLinkAdder'); const { linkAdder } = require('./JDLinkAdder');
const { getLinksFromURL } = require('./LinkGrabber') const { getLinksFromURL } = require('./LinkGrabber')
const { checkFileName } = require('./checkFileName') const { checkFileName } = require('./checkFileName')
const { checkDownloadHistory } = require('./checkDownloadHistory')
async function filterFeed() { async function filterFeed() {
let myshowlist = JSON.parse(fs.readFileSync('config.json')).Shows let myshowlist = JSON.parse(fs.readFileSync('config.json')).Shows
@ -47,8 +48,13 @@ async function filterFeed() {
let download_list = urlObj.urlList let download_list = urlObj.urlList
// Send Links to JDdownloader // Send Links to JDdownloader
if (download_list.length !== 0) { if (download_list.length !== 0) {
log.info(download_list.length + ' links for ' + urlObj.fileName + ' have been sent to JDdownloader') if (checkDownloadHistory(urlObj)) {
linkAdder(download_list) log.info(urlObj.fileName + ' already downloaded, skipped.')
break
} else {
log.info(download_list.length + ' links for ' + urlObj.fileName + ' have been sent to JDdownloader.')
linkAdder(download_list)
}
} else { } else {
// No HEVC links found // No HEVC links found
log.info(download_list.length + ' links for ' + show.Name + ' have been found, will recheck next time.') log.info(download_list.length + ' links for ' + show.Name + ' have been found, will recheck next time.')

19
checkDownloadHistory.js Normal file
View File

@ -0,0 +1,19 @@
const fs = require('fs')
function checkDownloadHistory(urlObj) {
try {
history = JSON.parse(fs.readFileSync('./downloadHistory.json'));
} catch (error) {
fs.writeFileSync('./downloadHistory.json', JSON.stringify([]));
}
history = JSON.parse(fs.readFileSync('./downloadHistory.json'));
if (history.includes(urlObj.fileName)) {
return true
} else {
history.push(urlObj.fileName)
fs.writeFileSync('./downloadHistory.json', JSON.stringify(history));
return false
}
}
module.exports = { checkDownloadHistory }

View File

@ -1,6 +1,6 @@
{ {
"name": "jdrssdownloader", "name": "jdrssdownloader",
"version": "1.0.1", "version": "1.0.2",
"description": "", "description": "",
"main": "JDRssDownloader.js", "main": "JDRssDownloader.js",
"bin": "JDRssDownloader.js", "bin": "JDRssDownloader.js",