diff --git a/.gitignore b/.gitignore index 5ead65e..bfef211 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ config.json package-lock.json jdrssdownloader.log .vscode/launch.json +feedCache.json +dist/jdrssdownloader-linux +dist/jdrssdownloader-win.exe +dist/jdrssdownloader-macos diff --git a/FeedFilter.js b/FeedFilter.js index 33b4537..740c2ea 100644 --- a/FeedFilter.js +++ b/FeedFilter.js @@ -5,7 +5,7 @@ const log = require('simple-node-logger').createSimpleLogger('jdrssdownloader.lo async function filterFeed() { let myshowlist = JSON.parse(fs.readFileSync('config.json')).Shows - let feed = JSON.parse(fs.readFileSync(global.fileName)); + let feed = JSON.parse(fs.readFileSync('./feedCache.json')); myshowlist.forEach(async show => { try { @@ -44,7 +44,10 @@ async function filterFeed() { } catch (error) { log.error('Something went wrong ' + error) } + }) + // log.info('Wiping feed cache') + // fs.writeFileSync(global.fileName, JSON.stringify('[]')); } module.exports = { diff --git a/FeedUpdater.js b/FeedUpdater.js index 6bee7a8..17121b1 100644 --- a/FeedUpdater.js +++ b/FeedUpdater.js @@ -12,18 +12,15 @@ async function feedUpdater() { let items = []; - // Clean up the string and replace reserved characters - global.fileName = `${feed.title.replace(/\s+/g, "-").replace(/[/\\?%*:|"<>]/g, '').toLowerCase()}.json`; - - if (fs.existsSync(global.fileName)) { - items = require(`./${global.fileName}`); + if (fs.existsSync('./feedCache.json')) { + items = JSON.parse(fs.readFileSync('./feedCache.json')) } // Compare existing cache and new items and merge differences let updatedArray = lodash.unionBy(feed.items, items, 'title'); // Save the file log.info(updatedArray.length + ' items in file cache') - fs.writeFileSync(fileName, JSON.stringify(updatedArray)); + fs.writeFileSync('./feedCache.json', JSON.stringify(updatedArray)); } diff --git a/package.json b/package.json index 3c37de5..eb8b31e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "name": "jdrssdownloader", "version": "1.0.0", "description": "", - "main": "main.js", + "main": "JDRssDownloader.js", + "bin": "JDRssDownloader.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -11,10 +12,12 @@ "dependencies": { "axios": "^0.27.2", "cheerio": "^1.0.0-rc.11", - "extract-urls": "^1.3.2", "jdownloader-client": "^1.0.0", "lodash": "^4.17.21", "rss-parser": "^3.12.0", "simple-node-logger": "^21.8.12" + }, + "pkg": { + "outputPath": "dist" } }