working link deletion

This commit is contained in:
karl.hudgell 2022-06-15 18:26:59 +01:00
parent 26658fdf8a
commit 0bbd83f375
2 changed files with 24 additions and 19 deletions

View File

@ -7,10 +7,11 @@ async function filterFeed() {
let myshowlist = JSON.parse(fs.readFileSync('config.json')).Shows let myshowlist = JSON.parse(fs.readFileSync('config.json')).Shows
let hevcSwitch = JSON.parse(fs.readFileSync('config.json')).OnlyHEVC let hevcSwitch = JSON.parse(fs.readFileSync('config.json')).OnlyHEVC
let feed = JSON.parse(fs.readFileSync('./feedCache.json')); let feed = JSON.parse(fs.readFileSync('./feedCache.json'));
let retry_show_cache = []
if (hevcSwitch) { if (hevcSwitch) {
myshowlist.forEach(async show => { for (let show of myshowlist) {
try { try {
// Find show on feed // Find show on feed
let list_filtered_for_show = feed.filter(item => item.title.includes(show.Name)) let list_filtered_for_show = feed.filter(item => item.title.includes(show.Name))
@ -39,9 +40,11 @@ async function filterFeed() {
linkAdder(download_list) linkAdder(download_list)
} else { } else {
// No HEVC links found // 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 { } else {
// Show not found on the current feed cache // Show not found on the current feed cache
log.info(show.Name + ' not on feed') log.info(show.Name + ' not on feed')
@ -49,10 +52,9 @@ async function filterFeed() {
} catch (error) { } catch (error) {
log.error('Something went wrong ' + error) log.error('Something went wrong ' + error)
} }
}
})
} else { } else {
myshowlist.forEach(async show => { for (let show of myshowlist) {
try { try {
// Find show on feed // Find show on feed
let list_filtered_for_show = feed.filter(item => item.title.includes(show.Name)) let list_filtered_for_show = feed.filter(item => item.title.includes(show.Name))
@ -73,9 +75,11 @@ async function filterFeed() {
linkAdder(download_list) linkAdder(download_list)
} else { } else {
// No links found // 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 { } else {
// Show not found on the current feed cache // Show not found on the current feed cache
log.info(show.Name + ' not on feed') log.info(show.Name + ' not on feed')
@ -83,13 +87,10 @@ async function filterFeed() {
} catch (error) { } catch (error) {
log.error('Something went wrong ' + error) log.error('Something went wrong ' + error)
} }
})
} }
}
//
log.info('Wiping feed cache') log.info('Wiping feed cache')
fs.writeFileSync('./feedCache.json', JSON.stringify('[]')); fs.writeFileSync('./feedCache.json', JSON.stringify(retry_show_cache));
} }
module.exports = { module.exports = {

View File

@ -6,6 +6,7 @@ global.log = require('simple-node-logger').createSimpleLogger({
timestampFormat: 'YYYY-MM-DD HH:mm:ss.SSS' timestampFormat: 'YYYY-MM-DD HH:mm:ss.SSS'
}); });
async function main() {
let RSSFeedRefreshMins = JSON.parse(fs.readFileSync('config.json')).RSSFeedRefreshMins let RSSFeedRefreshMins = JSON.parse(fs.readFileSync('config.json')).RSSFeedRefreshMins
let JDPostLinksMins = JSON.parse(fs.readFileSync('config.json')).JDPostLinksMins let JDPostLinksMins = JSON.parse(fs.readFileSync('config.json')).JDPostLinksMins
@ -13,5 +14,8 @@ 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(feedUpdater, RSSFeedRefreshMins * 60000); setInterval(await feedUpdater, RSSFeedRefreshMins * 60000);
setInterval(filterFeed, JDPostLinksMins * 60000); setInterval(await filterFeed, JDPostLinksMins * 60000);
}
main()