mirror of
https://github.com/karl0ss/JDRssDownloader.git
synced 2025-04-27 20:03:40 +01:00
Merge pull request #5 from karl0ss/DontSendProcessed
Dont send processed
This commit is contained in:
commit
393029ed37
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@ feedCache.json
|
|||||||
dist/jdrssdownloader-linux
|
dist/jdrssdownloader-linux
|
||||||
dist/jdrssdownloader-win.exe
|
dist/jdrssdownloader-win.exe
|
||||||
dist/jdrssdownloader-macos
|
dist/jdrssdownloader-macos
|
||||||
|
downloadHistory.json
|
||||||
|
@ -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.')
|
||||||
|
@ -1,19 +1,24 @@
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const { feedUpdater } = require('./FeedUpdater')
|
const { feedUpdater } = require('./FeedUpdater')
|
||||||
const { filterFeed } = require('./FeedFilter')
|
const { filterFeed } = require('./FeedFilter')
|
||||||
|
const version = require('./package.json').version;
|
||||||
|
|
||||||
global.log = require('simple-node-logger').createSimpleLogger({
|
global.log = require('simple-node-logger').createSimpleLogger({
|
||||||
logFilePath: 'jdrssdownloader.log',
|
logFilePath: 'jdrssdownloader.log',
|
||||||
timestampFormat: 'YYYY-MM-DD HH:mm:ss.SSS'
|
timestampFormat: 'YYYY-MM-DD HH:mm:ss.SSS'
|
||||||
});
|
});
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
let RSSFeedRefreshMins = JSON.parse(fs.readFileSync('config.json')).RSSFeedRefreshMins
|
log.info('Running JDRssDownloader version ' + version)
|
||||||
let JDPostLinksMins = JSON.parse(fs.readFileSync('config.json')).JDPostLinksMins
|
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('Refreshing RSS Items every ' + RSSFeedRefreshMins + ' Minutes')
|
||||||
log.info('Checking for links and sending to JDdownloader every ' + JDPostLinksMins + ' Minutes')
|
log.info('Checking for links and sending to JDdownloader every ' + JDPostLinksMins + ' Minutes')
|
||||||
|
|
||||||
|
|
||||||
setInterval(await feedUpdater, RSSFeedRefreshMins * 60000);
|
setInterval(await feedUpdater, RSSFeedRefreshMins * 60000);
|
||||||
setInterval(await filterFeed, JDPostLinksMins * 60000);
|
setInterval(await filterFeed, JDPostLinksMins * 60000);
|
||||||
}
|
}
|
||||||
|
19
checkDownloadHistory.js
Normal file
19
checkDownloadHistory.js
Normal 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 }
|
@ -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",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user