Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hevc switch #4

Merged
merged 9 commits into from
Jun 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 49 additions & 29 deletions FeedFilter.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,72 @@
const fs = require('fs')
const { linkAdder } = require('./JDLinkAdder');
const { getLinksFromURL } = require('./LinkGrabber')
const { checkFileName } = require('./checkFileName')

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 = []
let urls_to_check = []


for (let show of myshowlist) {

myshowlist.forEach(async show => {
try {
// Find show on feed
let list_filtered_for_show = feed.filter(item => item.title.includes(show.Name))
if (list_filtered_for_show.length > 0) {
// If show is found get url then return all links on that page
let full_link_list_from_page = await getLinksFromURL(list_filtered_for_show[0].link)
// Only get urls with HEVC in name
let urls_with_HEVC_in_url = full_link_list_from_page.filter(item => item.includes('HEVC'))
if (urls_with_HEVC_in_url.length == 0) {
// If no urls with HEVC check for H265
urls_with_HEVC_in_url = full_link_list_from_page.filter(item => item.includes('H265'))
}
// Only keep urls that match show quality
let urls_with_quality_in_url = urls_with_HEVC_in_url.filter(item => item.includes(show.Quality))
// Remove any url trying to direct to a torrent site search
let urls_without_torrent_in_url = urls_with_quality_in_url.filter(item => !item.includes('torrent'))
// Remove any url that doesn't include MeGusta
let only_MeGusta_links = urls_without_torrent_in_url.filter(item => item.includes('MeGusta'))
// NitroFlare doesn't group with the rest of the links in JD, remove them.
let remove_nitroflare = only_MeGusta_links.filter(item => !item.includes('nitro'))
// Send Links to JDdownloader
if (remove_nitroflare.length !== 0) {
log.info(remove_nitroflare.length + ' links for ' + show.Name + ' have been sent to JDdownloader')
linkAdder(remove_nitroflare)
} else {
// No HEVC links found
log.info(remove_nitroflare.length + ' HEVC links for ' + show.Name + ' have been found')
for (let match of list_filtered_for_show) {
// If show is found get url then return all links on that page
let full_link_list_from_page = await getLinksFromURL(match.link)
if (hevcSwitch) {
// Only get urls with HEVC in name
urls_to_check = full_link_list_from_page.filter(item => item.includes('HEVC'))
if (urls_to_check.length == 0) {
// If no urls with HEVC check for H265
urls_to_check = full_link_list_from_page.filter(item => item.includes('H265'))
}
} else {
urls_to_check = full_link_list_from_page
}
// Only keep urls that match show quality
let urls_with_quality_in_url = urls_to_check.filter(item => item.includes(show.Quality))
// Remove any url trying to direct to a torrent site search
let urls_without_torrent_in_url = urls_with_quality_in_url.filter(item => !item.includes('torrent'))
// Remove any url that doesn't include MeGusta
if (hevcSwitch) {
pre_nitroFlare = urls_without_torrent_in_url.filter(item => item.includes('MeGusta'))
} else {
pre_nitroFlare = urls_without_torrent_in_url
}
// NitroFlare doesn't group with the rest of the links in JD, remove them.
let remove_nitroflare = pre_nitroFlare.filter(item => !item.includes('nitro'))
// Do some stuff
urlObj = checkFileName(remove_nitroflare)
let download_list = urlObj.urlList
// Send Links to JDdownloader
if (download_list.length !== 0) {
log.info(download_list.length + ' links for ' + urlObj.fileName + ' have been sent to JDdownloader')
linkAdder(download_list)
} else {
// No HEVC links found
log.info(download_list.length + ' 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')
}
} catch (error) {
log.error('Something went wrong ' + error)
}

})
// log.info('Wiping feed cache')
// fs.writeFileSync(global.fileName, JSON.stringify('[]'));
}
log.info('Wiping feed cache')
fs.writeFileSync('./feedCache.json', JSON.stringify(retry_show_cache));
}

module.exports = {
Expand Down
16 changes: 10 additions & 6 deletions JDRssDownloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ I have put together this simple project to allow me to do that, people may find
- 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
- Ability to turn OFF only HEVC search

# 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.

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
- RSSFeed - The url to the rss feed you want to watch (Only tested with - https://rlsbb.cc/feed/)
- RSSFeed - The url to the rss feed you want to watch (Only tested with - rlsbb)
- 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
- 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)
- OnlyHEVC - If false, this will download any files that it finds on the post that matches the quality (true/false)
- 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
Expand All @@ -30,10 +32,11 @@ An example shown below
{
"JDUserName": "User",
"JDPassword": "Pass",
"RSSFeed": "https://rlsbb.cc/feed/",
"RSSFeed": "https://mypage.com/feed/",
"RSSFeedRefreshMins": 10,
"JDPostLinksMins": 180,
"Autostart": false,
"OnlyHEVC": true,
"Shows": [
{
"Name": "Obi-Wan Kenobi",
Expand All @@ -46,29 +49,32 @@ 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.

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.

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

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.
I have some ideas to make this a bit smarter and I 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.

Thank for all the people who made any of the modules that I used to create this.
16 changes: 16 additions & 0 deletions checkFileName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function checkFileName(urls) {
let urlObj = {
"fileName": "",
"urlList": []
}
urls.forEach(url => {
let cut = url.match(/([^\/]*$)/mg);
if (cut[0] !== '') {
urlObj.fileName = cut[0].replace('.html', '')
urlObj.urlList.push(url)
}
});
return urlObj
}

module.exports = { checkFileName }
1 change: 1 addition & 0 deletions config-sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"RSSFeedRefreshMins": 10,
"JDPostLinksMins": 180,
"Autostart": false,
"OnlyHEVC": true,
"Shows": [
{
"Name": "",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jdrssdownloader",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"main": "JDRssDownloader.js",
"bin": "JDRssDownloader.js",
Expand Down