From 0bbd83f3752c41f7415e914564cdc09d309e47f6 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Wed, 15 Jun 2022 18:26:59 +0100 Subject: [PATCH] working link deletion --- FeedFilter.js | 27 ++++++++++++++------------- JDRssDownloader.js | 16 ++++++++++------ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/FeedFilter.js b/FeedFilter.js index 3ca045c..151da3e 100644 --- a/FeedFilter.js +++ b/FeedFilter.js @@ -7,10 +7,11 @@ async function filterFeed() { let myshowlist = JSON.parse(fs.readFileSync('config.json')).Shows let hevcSwitch = JSON.parse(fs.readFileSync('config.json')).OnlyHEVC let feed = JSON.parse(fs.readFileSync('./feedCache.json')); + let retry_show_cache = [] if (hevcSwitch) { - myshowlist.forEach(async show => { + for (let show of myshowlist) { try { // Find show on feed let list_filtered_for_show = feed.filter(item => item.title.includes(show.Name)) @@ -39,9 +40,11 @@ async function filterFeed() { linkAdder(download_list) } else { // No HEVC links found - log.info(download_list.length + ' HEVC links for ' + show.Name + ' have been found') + log.info(download_list.length + ' HEVC links for ' + show.Name + ' have been found, will recheck next time.') + for (let feed_item of list_filtered_for_show) { + retry_show_cache.push(feed_item) + } } - } else { // Show not found on the current feed cache log.info(show.Name + ' not on feed') @@ -49,10 +52,9 @@ async function filterFeed() { } catch (error) { log.error('Something went wrong ' + error) } - - }) + } } else { - myshowlist.forEach(async show => { + for (let show of myshowlist) { try { // Find show on feed let list_filtered_for_show = feed.filter(item => item.title.includes(show.Name)) @@ -73,9 +75,11 @@ async function filterFeed() { linkAdder(download_list) } else { // No links found - log.info(download_list.length + ' links for ' + show.Name + ' have been found') + log.info(download_list.length + ' HEVC links for ' + show.Name + ' have been found, will recheck next time.') + for (let feed_item of list_filtered_for_show) { + retry_show_cache.push(feed_item) + } } - } else { // Show not found on the current feed cache log.info(show.Name + ' not on feed') @@ -83,13 +87,10 @@ async function filterFeed() { } catch (error) { log.error('Something went wrong ' + error) } - - }) + } } - - // log.info('Wiping feed cache') - fs.writeFileSync('./feedCache.json', JSON.stringify('[]')); + fs.writeFileSync('./feedCache.json', JSON.stringify(retry_show_cache)); } module.exports = { diff --git a/JDRssDownloader.js b/JDRssDownloader.js index 7aec98f..d3102d8 100644 --- a/JDRssDownloader.js +++ b/JDRssDownloader.js @@ -6,12 +6,16 @@ global.log = require('simple-node-logger').createSimpleLogger({ timestampFormat: 'YYYY-MM-DD HH:mm:ss.SSS' }); -let RSSFeedRefreshMins = JSON.parse(fs.readFileSync('config.json')).RSSFeedRefreshMins -let JDPostLinksMins = JSON.parse(fs.readFileSync('config.json')).JDPostLinksMins +async function main() { + let RSSFeedRefreshMins = JSON.parse(fs.readFileSync('config.json')).RSSFeedRefreshMins + let JDPostLinksMins = JSON.parse(fs.readFileSync('config.json')).JDPostLinksMins -log.info('Refreshing RSS Items every ' + RSSFeedRefreshMins + ' Minutes') -log.info('Checking for links and sending to JDdownloader every ' + JDPostLinksMins + ' Minutes') + log.info('Refreshing RSS Items every ' + RSSFeedRefreshMins + ' Minutes') + log.info('Checking for links and sending to JDdownloader every ' + JDPostLinksMins + ' Minutes') -setInterval(feedUpdater, RSSFeedRefreshMins * 60000); -setInterval(filterFeed, JDPostLinksMins * 60000); + setInterval(await feedUpdater, RSSFeedRefreshMins * 60000); + setInterval(await filterFeed, JDPostLinksMins * 60000); +} + +main() \ No newline at end of file