From 3c4f825991e0c71d80ac6fb0cb6bba0cbeb429ce Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Thu, 9 Jun 2022 10:29:05 +0100 Subject: [PATCH 1/7] timed runner --- FeedFilter.js | 3 ++- main.js => FeedUpdater.js | 14 +++++++++----- runner.js | 5 +++++ 3 files changed, 16 insertions(+), 6 deletions(-) rename main.js => FeedUpdater.js (86%) create mode 100644 runner.js diff --git a/FeedFilter.js b/FeedFilter.js index f9d7140..d379720 100644 --- a/FeedFilter.js +++ b/FeedFilter.js @@ -3,7 +3,8 @@ const { linkAdder } = require('./JDLinkAdder'); const { getLinksFromURL } = require('./LinkGrabber') const log = require('simple-node-logger').createSimpleLogger('jdrssdownloader.log'); -async function filterFeed(fileName) { +async function filterFeed() { + fileName = './releasebb.json' let myshowlist = JSON.parse(fs.readFileSync('config.json')).Shows let feed = JSON.parse(fs.readFileSync(fileName)); diff --git a/main.js b/FeedUpdater.js similarity index 86% rename from main.js rename to FeedUpdater.js index 9a283be..78eb0eb 100644 --- a/main.js +++ b/FeedUpdater.js @@ -5,9 +5,7 @@ const { filterFeed } = require("./FeedFilter"); const lodash = require('lodash'); const log = require('simple-node-logger').createSimpleLogger('jdrssdownloader.log'); -(async function main() { - - +async function feedUpdater() { // Make a new RSS Parser const parser = new Parser(); @@ -30,5 +28,11 @@ const log = require('simple-node-logger').createSimpleLogger('jdrssdownloader.lo fs.writeFileSync(fileName, JSON.stringify(updatedArray)); // run next part - filterFeed(fileName) -})(); + // return fileName + // filterFeed(fileName) +} +// (); + +module.exports = { + feedUpdater +} \ No newline at end of file diff --git a/runner.js b/runner.js new file mode 100644 index 0000000..e30e875 --- /dev/null +++ b/runner.js @@ -0,0 +1,5 @@ +const { feedUpdater } = require('./FeedUpdater') +const { filterFeed } = require('./FeedFilter') + +setInterval(feedUpdater, 600000); +setInterval(filterFeed, 18000000); \ No newline at end of file From 4f50f46fc7665752ad48b8d4b0b4aff3416d1643 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Thu, 9 Jun 2022 19:08:32 +0100 Subject: [PATCH 2/7] updated runner code and logging --- runner.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/runner.js b/runner.js index e30e875..b4b8a90 100644 --- a/runner.js +++ b/runner.js @@ -1,5 +1,13 @@ +const fs = require("fs"); const { feedUpdater } = require('./FeedUpdater') const { filterFeed } = require('./FeedFilter') +const log = require('simple-node-logger').createSimpleLogger('jdrssdownloader.log'); -setInterval(feedUpdater, 600000); -setInterval(filterFeed, 18000000); \ No newline at end of file +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') + +setInterval(feedUpdater, RSSFeedRefreshMins * 60000); +setInterval(filterFeed, JDPostLinksMins * 60000); From a6df6aae5f83a363c209288edf0129e8a83334f1 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Thu, 9 Jun 2022 19:45:58 +0100 Subject: [PATCH 3/7] update readme and rename to JDRssDownloader --- runner.js => JDRssDownloader.js | 0 README.md | 15 +++++++++------ config-sample.json | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) rename runner.js => JDRssDownloader.js (100%) diff --git a/runner.js b/JDRssDownloader.js similarity index 100% rename from runner.js rename to JDRssDownloader.js diff --git a/README.md b/README.md index 81db5c9..e88ab35 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # JDRssDownloader -JDownloder 2 is a great tool, but since V1 has been missing a way to automatically download from RSS feeds, and filter downloads to only download HEVC files. +JDownloader 2 is a great tool, but since V1 has been missing a way to automatically download from RSS feeds, and filter downloads to only download HEVC files. I have put together this simple project to allow me to do that, people may find useful. @@ -10,11 +10,12 @@ You will need NodeJS installed, then you can checkout this repo. There is a ``config-sample.json`` file that needs to be renamed to ``config.json``, after this you can update it with your required settings. - JDUserName - Your MyJDownloader Username -- JDPassword - Your MyJdownloader Password +- JDPassword - Your MyJDownloader Password - RSSFeed - The url to the rss feed you want to watch (Only tested with - https://rlsbb.cc/feed/) - +- RSSFeedRefreshMins - How often to poll your rss feed down to local file cache +- JDPostLinksMins": How often to check your file cache for your shows and send found links to JDownloader - Autostart - Tells JDownloader to add and start the downloads straight away (true/false) -- Shows - This needs to be a comma seperated list of json objects of the show and quality you want to check for. +- Shows - This needs to be a comma separated list of json objects of the show and quality you want to check for. An example shown below @@ -23,6 +24,8 @@ An example shown below "JDUserName": "User", "JDPassword": "Pass", "RSSFeed": "https://rlsbb.cc/feed/", + "RSSFeedRefreshMins": 10, + "JDPostLinksMins": 180, "Autostart": false, "Shows": [ { @@ -40,9 +43,9 @@ An example shown below ## Execution For basic usage you can just navigate into the folder and run - - ``npm i`` to install the requirements. -- ``node main.js`` This will execute the process and add the links if they are found. +- ``node JDRssDownloader.js`` This will execute the process and add the links if they are found. -For advanced usage, you can set it to run every hour or something using a cron job, thats what I have setup. +My suggestion would be to use pm2 so it can run "in the background" ## Issues diff --git a/config-sample.json b/config-sample.json index 54825f6..574f704 100644 --- a/config-sample.json +++ b/config-sample.json @@ -2,6 +2,8 @@ "JDUserName": "", "JDPassword": "", "RSSFeed": "", + "RSSFeedRefreshMins": 10, + "JDPostLinksMins": 180, "Autostart": false, "Shows": [ { From 1365236bdcbeeb67410e2b602093ff94791ec14e Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Thu, 9 Jun 2022 20:23:36 +0100 Subject: [PATCH 4/7] working dynamic fileName again --- FeedFilter.js | 3 +-- FeedUpdater.js | 13 ++++--------- JDRssDownloader.js | 1 + README.md | 9 +++++++++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/FeedFilter.js b/FeedFilter.js index d379720..33b4537 100644 --- a/FeedFilter.js +++ b/FeedFilter.js @@ -4,9 +4,8 @@ const { getLinksFromURL } = require('./LinkGrabber') const log = require('simple-node-logger').createSimpleLogger('jdrssdownloader.log'); async function filterFeed() { - fileName = './releasebb.json' let myshowlist = JSON.parse(fs.readFileSync('config.json')).Shows - let feed = JSON.parse(fs.readFileSync(fileName)); + let feed = JSON.parse(fs.readFileSync(global.fileName)); myshowlist.forEach(async show => { try { diff --git a/FeedUpdater.js b/FeedUpdater.js index 78eb0eb..6bee7a8 100644 --- a/FeedUpdater.js +++ b/FeedUpdater.js @@ -1,7 +1,5 @@ -// Import dependencies const fs = require("fs"); const Parser = require("rss-parser"); -const { filterFeed } = require("./FeedFilter"); const lodash = require('lodash'); const log = require('simple-node-logger').createSimpleLogger('jdrssdownloader.log'); @@ -15,10 +13,10 @@ async function feedUpdater() { let items = []; // Clean up the string and replace reserved characters - const fileName = `${feed.title.replace(/\s+/g, "-").replace(/[/\\?%*:|"<>]/g, '').toLowerCase()}.json`; + global.fileName = `${feed.title.replace(/\s+/g, "-").replace(/[/\\?%*:|"<>]/g, '').toLowerCase()}.json`; - if (fs.existsSync(fileName)) { - items = require(`./${fileName}`); + if (fs.existsSync(global.fileName)) { + items = require(`./${global.fileName}`); } // Compare existing cache and new items and merge differences let updatedArray = lodash.unionBy(feed.items, items, 'title'); @@ -27,11 +25,8 @@ async function feedUpdater() { log.info(updatedArray.length + ' items in file cache') fs.writeFileSync(fileName, JSON.stringify(updatedArray)); - // run next part - // return fileName - // filterFeed(fileName) + } -// (); module.exports = { feedUpdater diff --git a/JDRssDownloader.js b/JDRssDownloader.js index b4b8a90..4d702a8 100644 --- a/JDRssDownloader.js +++ b/JDRssDownloader.js @@ -9,5 +9,6 @@ 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') + setInterval(feedUpdater, RSSFeedRefreshMins * 60000); setInterval(filterFeed, JDPostLinksMins * 60000); diff --git a/README.md b/README.md index e88ab35..a4627ff 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,15 @@ JDownloader 2 is a great tool, but since V1 has been missing a way to automatica I have put together this simple project to allow me to do that, people may find useful. +- Automatically check RSS feed and send to JDownloader +- Uses MyJDownloader API to allow running on separate system +- Local file cache of RSS feed +- Specify time to check RSS feed +- Specify time to check file cache to send links to JDownloader +- Ability to add multiple shows to check for +- Ability to check for different qualities per show you are looking for + + You will need NodeJS installed, then you can checkout this repo. ## Configuration From 32aa5c7c1b7efcba53e30680c53a89203fae6fbe Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Sat, 11 Jun 2022 18:46:24 +0100 Subject: [PATCH 5/7] latest working with builds --- .gitignore | 4 ++++ FeedFilter.js | 5 ++++- FeedUpdater.js | 9 +++------ package.json | 7 +++++-- 4 files changed, 16 insertions(+), 9 deletions(-) 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" } } From fadf79a75926ae3ec0e3e26f74fe847edef9c380 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Sat, 11 Jun 2022 18:54:21 +0100 Subject: [PATCH 6/7] global log --- FeedFilter.js | 1 - FeedUpdater.js | 1 - JDLinkAdder.js | 1 - JDRssDownloader.js | 5 ++++- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/FeedFilter.js b/FeedFilter.js index 740c2ea..6a4b1c5 100644 --- a/FeedFilter.js +++ b/FeedFilter.js @@ -1,7 +1,6 @@ const fs = require('fs') const { linkAdder } = require('./JDLinkAdder'); const { getLinksFromURL } = require('./LinkGrabber') -const log = require('simple-node-logger').createSimpleLogger('jdrssdownloader.log'); async function filterFeed() { let myshowlist = JSON.parse(fs.readFileSync('config.json')).Shows diff --git a/FeedUpdater.js b/FeedUpdater.js index 17121b1..086124b 100644 --- a/FeedUpdater.js +++ b/FeedUpdater.js @@ -1,7 +1,6 @@ const fs = require("fs"); const Parser = require("rss-parser"); const lodash = require('lodash'); -const log = require('simple-node-logger').createSimpleLogger('jdrssdownloader.log'); async function feedUpdater() { // Make a new RSS Parser diff --git a/JDLinkAdder.js b/JDLinkAdder.js index 0ba9d91..5421987 100644 --- a/JDLinkAdder.js +++ b/JDLinkAdder.js @@ -3,7 +3,6 @@ const fs = require("fs"); async function linkAdder(links) { - const client = new JDownloaderClient(JSON.parse(fs.readFileSync('config.json')).JDUserName, JSON.parse(fs.readFileSync('config.json')).JDPassword) await client.connect() const devices = await client.listDevices() diff --git a/JDRssDownloader.js b/JDRssDownloader.js index 4d702a8..7aec98f 100644 --- a/JDRssDownloader.js +++ b/JDRssDownloader.js @@ -1,7 +1,10 @@ const fs = require("fs"); const { feedUpdater } = require('./FeedUpdater') const { filterFeed } = require('./FeedFilter') -const log = require('simple-node-logger').createSimpleLogger('jdrssdownloader.log'); +global.log = require('simple-node-logger').createSimpleLogger({ + logFilePath: 'jdrssdownloader.log', + 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 From 82dcdf519025d28559d75fd2d53feb48ddb12b10 Mon Sep 17 00:00:00 2001 From: "karl.hudgell" Date: Sat, 11 Jun 2022 19:03:54 +0100 Subject: [PATCH 7/7] readme update --- README.md | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a4627ff..bc0b120 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,19 @@ # JDRssDownloader -JDownloader 2 is a great tool, but since V1 has been missing a way to automatically download from RSS feeds, and filter downloads to only download HEVC files. +JDownloader 2 is a great tool, but since V1 has been missing a way to automatically download from RSS feeds, and filter downloads to only download what you want, in my case 720p HEVC files, MeGusta rips by preference. I have put together this simple project to allow me to do that, people may find useful. -- Automatically check RSS feed and send to JDownloader +- Automatically check an RSS feed and send to JDownloader - Uses MyJDownloader API to allow running on separate system - Local file cache of RSS feed - Specify time to check RSS feed - Specify time to check file cache to send links to JDownloader - Ability to add multiple shows to check for - Ability to check for different qualities per show you are looking for - + -You will need NodeJS installed, then you can checkout this repo. - -## Configuration +# Configuration There is a ``config-sample.json`` file that needs to be renamed to ``config.json``, after this you can update it with your required settings. - JDUserName - Your MyJDownloader Username @@ -48,14 +46,29 @@ An example shown below ] } ``` +# Running + +## Release Version +Either download the version on the releases, as well as the `config-sample.json` and run execute, this is the simplest way, but may not be the latest code, and will not run in the background + +## Source Version +You will need NodeJS installed, then you can checkout this repo. -## Execution For basic usage you can just navigate into the folder and run - - ``npm i`` to install the requirements. - ``node JDRssDownloader.js`` This will execute the process and add the links if they are found. My suggestion would be to use pm2 so it can run "in the background" -## Issues +# Issues -Not alot of testing has gone into this, and I threw it together today in about 2 hours, so there are bound to be issues, please open them and let me know if you find any. +Not alot of testing has gone into this, and I threw it together in a few hours, and only for my use case, so there are bound to be issues, please open them and let me know if you find any. + + +# Future +I have some ideas to make this a bit smarter, at the moment it doesn't clean the cache at all, and will keep sending the same links to JDownloader once they are in the cache, I am working on cleaning them out, but for now the best thing to do it to set JDownloader to automatically mark already downloaded links as finished, then it doesn't bother redownloading all the time. + +Also want to add the ability to look at multiple RSS feeds, this seems quite easy, and I will do in the next couple of weeks. + +# Thanks +Thank for all the people who made any of the modules that I used to create this. \ No newline at end of file