latest working with builds

This commit is contained in:
karl.hudgell 2022-06-11 18:46:24 +01:00
parent 1365236bdc
commit 32aa5c7c1b
4 changed files with 16 additions and 9 deletions

4
.gitignore vendored
View File

@ -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

View File

@ -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 = {

View File

@ -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));
}

View File

@ -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"
}
}