JDRssDownloader/JDRssDownloader.js

39 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-06-09 19:08:32 +01:00
const fs = require("fs");
2022-06-09 10:29:05 +01:00
const { feedUpdater } = require('./FeedUpdater')
const { filterFeed } = require('./FeedFilter')
2022-09-08 09:35:59 +01:00
const { telegrambot } = require('./telegramCommunication')
2022-06-18 13:19:45 +01:00
const version = require('./package.json').version;
2022-09-08 09:35:59 +01:00
global.TelegramBotConfig = JSON.parse(fs.readFileSync('config.json')).TelegramBot
2022-06-11 18:54:21 +01:00
global.log = require('simple-node-logger').createSimpleLogger({
logFilePath: 'jdrssdownloader.log',
timestampFormat: 'YYYY-MM-DD HH:mm:ss.SSS'
});
2022-06-09 10:29:05 +01:00
2022-06-15 18:26:59 +01:00
async function main() {
2022-06-18 13:19:45 +01:00
log.info('Running JDRssDownloader version ' + version)
2022-09-08 09:35:59 +01:00
if (TelegramBotConfig) {
telegrambot('Running JDRssDownloader version ' + version)
}
2022-06-18 13:58:29 +01:00
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.')
}
2022-06-15 18:26:59 +01:00
log.info('Refreshing RSS Items every ' + RSSFeedRefreshMins + ' Minutes')
2022-09-08 09:35:59 +01:00
if (TelegramBotConfig) {
telegrambot('Refreshing RSS Items every ' + RSSFeedRefreshMins + ' Minutes')
}
2022-06-15 18:26:59 +01:00
log.info('Checking for links and sending to JDdownloader every ' + JDPostLinksMins + ' Minutes')
2022-09-08 09:35:59 +01:00
if (TelegramBotConfig) {
telegrambot('Checking for links and sending to JDdownloader every ' + JDPostLinksMins + ' Minutes')
}
2022-06-09 19:08:32 +01:00
2022-06-15 18:26:59 +01:00
setInterval(await feedUpdater, RSSFeedRefreshMins * 60000);
setInterval(await filterFeed, JDPostLinksMins * 60000);
}
main()