From fb0ad8af5e66f2cba9686ed2edb0e4bbe3e58af8 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Sat, 18 Jun 2022 13:19:45 +0100 Subject: [PATCH 1/6] print app version when starting --- JDRssDownloader.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/JDRssDownloader.js b/JDRssDownloader.js index d3102d8..3f7c6a2 100644 --- a/JDRssDownloader.js +++ b/JDRssDownloader.js @@ -1,6 +1,8 @@ const fs = require("fs"); const { feedUpdater } = require('./FeedUpdater') const { filterFeed } = require('./FeedFilter') +const version = require('./package.json').version; + global.log = require('simple-node-logger').createSimpleLogger({ logFilePath: 'jdrssdownloader.log', timestampFormat: 'YYYY-MM-DD HH:mm:ss.SSS' @@ -10,6 +12,7 @@ async function main() { let RSSFeedRefreshMins = JSON.parse(fs.readFileSync('config.json')).RSSFeedRefreshMins let JDPostLinksMins = JSON.parse(fs.readFileSync('config.json')).JDPostLinksMins + log.info('Running JDRssDownloader version ' + version) log.info('Refreshing RSS Items every ' + RSSFeedRefreshMins + ' Minutes') log.info('Checking for links and sending to JDdownloader every ' + JDPostLinksMins + ' Minutes') From 495ebfbab199c2a465bf3bb08322995712b9c511 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Sat, 18 Jun 2022 13:20:06 +0100 Subject: [PATCH 2/6] default downloadHistory.json to work with --- downloadHistory.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 downloadHistory.json diff --git a/downloadHistory.json b/downloadHistory.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/downloadHistory.json @@ -0,0 +1 @@ +[] \ No newline at end of file From 10a2873aa26baee96a4a739b37fc2afeb567407c Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Sat, 18 Jun 2022 13:43:27 +0100 Subject: [PATCH 3/6] ignore downloadHistory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bfef211..a75cf9d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ feedCache.json dist/jdrssdownloader-linux dist/jdrssdownloader-win.exe dist/jdrssdownloader-macos +downloadHistory.json From 736ec930307ef406d52daee6ae85a76cf1543e39 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Sat, 18 Jun 2022 13:43:54 +0100 Subject: [PATCH 4/6] remove downloadHistory --- downloadHistory.json | 1 - 1 file changed, 1 deletion(-) delete mode 100644 downloadHistory.json diff --git a/downloadHistory.json b/downloadHistory.json deleted file mode 100644 index 0637a08..0000000 --- a/downloadHistory.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file From 77f2029615d31cd3adb45c5bd5e04160b2cf84ed Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Sat, 18 Jun 2022 13:44:16 +0100 Subject: [PATCH 5/6] upversion and working download history --- FeedFilter.js | 10 ++++++++-- checkDownloadHistory.js | 19 +++++++++++++++++++ package.json | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 checkDownloadHistory.js diff --git a/FeedFilter.js b/FeedFilter.js index 05f876e..2675ec0 100644 --- a/FeedFilter.js +++ b/FeedFilter.js @@ -2,6 +2,7 @@ const fs = require('fs') const { linkAdder } = require('./JDLinkAdder'); const { getLinksFromURL } = require('./LinkGrabber') const { checkFileName } = require('./checkFileName') +const { checkDownloadHistory } = require('./checkDownloadHistory') async function filterFeed() { let myshowlist = JSON.parse(fs.readFileSync('config.json')).Shows @@ -47,8 +48,13 @@ async function filterFeed() { let download_list = urlObj.urlList // Send Links to JDdownloader if (download_list.length !== 0) { - log.info(download_list.length + ' links for ' + urlObj.fileName + ' have been sent to JDdownloader') - linkAdder(download_list) + if (checkDownloadHistory(urlObj)) { + 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 { // No HEVC links found log.info(download_list.length + ' links for ' + show.Name + ' have been found, will recheck next time.') diff --git a/checkDownloadHistory.js b/checkDownloadHistory.js new file mode 100644 index 0000000..e3c923b --- /dev/null +++ b/checkDownloadHistory.js @@ -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 } \ No newline at end of file diff --git a/package.json b/package.json index e280cdb..5e4bd81 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jdrssdownloader", - "version": "1.0.1", + "version": "1.0.2", "description": "", "main": "JDRssDownloader.js", "bin": "JDRssDownloader.js", From 25ed5af433d5e2667ab7a26c71b8b975e91e9056 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Sat, 18 Jun 2022 13:58:29 +0100 Subject: [PATCH 6/6] quick config.json check --- JDRssDownloader.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/JDRssDownloader.js b/JDRssDownloader.js index 3f7c6a2..1d7766b 100644 --- a/JDRssDownloader.js +++ b/JDRssDownloader.js @@ -9,14 +9,16 @@ global.log = require('simple-node-logger').createSimpleLogger({ }); async function main() { - let RSSFeedRefreshMins = JSON.parse(fs.readFileSync('config.json')).RSSFeedRefreshMins - let JDPostLinksMins = JSON.parse(fs.readFileSync('config.json')).JDPostLinksMins - log.info('Running JDRssDownloader version ' + version) + try { + RSSFeedRefreshMins = JSON.parse(fs.readFileSync('config.json')).RSSFeedRefreshMins + JDPostLinksMins = JSON.parse(fs.readFileSync('config.json')).JDPostLinksMins + } catch (error) { + log.error('config.json file is missing.') + } log.info('Refreshing RSS Items every ' + RSSFeedRefreshMins + ' Minutes') log.info('Checking for links and sending to JDdownloader every ' + JDPostLinksMins + ' Minutes') - setInterval(await feedUpdater, RSSFeedRefreshMins * 60000); setInterval(await filterFeed, JDPostLinksMins * 60000); }