mirror of
https://github.com/karl0ss/JDRssDownloader.git
synced 2025-04-27 20:03:40 +01:00
commit
a3987c67bb
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ releasebb.json
|
||||
config.json
|
||||
package-lock.json
|
||||
jdrssdownloader.log
|
||||
.vscode/launch.json
|
||||
|
4
feed.js
4
feed.js
@ -14,9 +14,9 @@ function filterFeed(fileName) {
|
||||
let urls_with_HEVC_in_url = extracted_urls_for_show.filter(item => item.includes('HEVC'))
|
||||
let urls_with_quality_in_url = urls_with_HEVC_in_url.filter(item => item.includes(show.Quality))
|
||||
let urls_without_torrent_in_url = urls_with_quality_in_url.filter(item => !item.includes('torrent'))
|
||||
log.info(show + ' - ' + urls_without_torrent_in_url)
|
||||
log.info(show.Name + ' - ' + urls_without_torrent_in_url)
|
||||
linkAdder(urls_without_torrent_in_url)
|
||||
// console.log(list_filtered_for_show)
|
||||
// console.log(urls_without_torrent_in_url)
|
||||
} catch (error) {
|
||||
log.info(show.Name + ' not on feed')
|
||||
}
|
||||
|
69
main.js
69
main.js
@ -2,63 +2,32 @@
|
||||
const fs = require("fs");
|
||||
const Parser = require("rss-parser");
|
||||
const { filterFeed } = require("./feed");
|
||||
const lodash = require('lodash');
|
||||
|
||||
|
||||
(async function main() {
|
||||
(async function main() {
|
||||
|
||||
|
||||
// Make a new RSS Parser
|
||||
const parser = new Parser();
|
||||
// Make a new RSS Parser
|
||||
const parser = new Parser();
|
||||
|
||||
// Get all the items in the RSS feed
|
||||
const feed = await parser.parseURL(JSON.parse(fs.readFileSync('config.json')).RSSFeed);
|
||||
// Get all the items in the RSS feed
|
||||
const feed = await parser.parseURL(JSON.parse(fs.readFileSync('config.json')).RSSFeed);
|
||||
|
||||
let items = [];
|
||||
let items = [];
|
||||
|
||||
// Clean up the string and replace reserved characters
|
||||
const fileName = `${feed.title.replace(/\s+/g, "-").replace(/[/\\?%*:|"<>]/g, '').toLowerCase()}.json`;
|
||||
// Clean up the string and replace reserved characters
|
||||
const fileName = `${feed.title.replace(/\s+/g, "-").replace(/[/\\?%*:|"<>]/g, '').toLowerCase()}.json`;
|
||||
|
||||
if (fs.existsSync(fileName)) {
|
||||
items = require(`./${fileName}`);
|
||||
}
|
||||
|
||||
|
||||
// Add the items to the items array
|
||||
await Promise.all(feed.items.map(async (currentItem) => {
|
||||
|
||||
// Add a new item if it doesn't already exist
|
||||
if (items.filter((item) => isEquivalent(item, currentItem)).length <= 0) {
|
||||
items.push(currentItem);
|
||||
if (fs.existsSync(fileName)) {
|
||||
items = require(`./${fileName}`);
|
||||
}
|
||||
let updatedArray = lodash.unionBy(feed.items, items, 'title');
|
||||
|
||||
// Save the file
|
||||
console.log(updatedArray.length)
|
||||
fs.writeFileSync(fileName, JSON.stringify(updatedArray));
|
||||
|
||||
}));
|
||||
|
||||
// Save the file
|
||||
fs.writeFileSync(fileName, JSON.stringify(items));
|
||||
|
||||
// run next part
|
||||
filterFeed(fileName)
|
||||
})();
|
||||
|
||||
function isEquivalent(a, b) {
|
||||
// Create arrays of property names
|
||||
let aProps = Object.getOwnPropertyNames(a);
|
||||
let bProps = Object.getOwnPropertyNames(b);
|
||||
|
||||
// if number of properties is different, objects are not equivalent
|
||||
if (aProps.length != bProps.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < aProps.length; i++) {
|
||||
let propName = aProps[i];
|
||||
|
||||
// if values of same property are not equal, objects are not equivalent
|
||||
if (a[propName] !== b[propName]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// if we made it this far, objects are considered equivalent
|
||||
return true;
|
||||
}
|
||||
// run next part
|
||||
filterFeed(fileName)
|
||||
})();
|
||||
|
@ -11,6 +11,7 @@
|
||||
"dependencies": {
|
||||
"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"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user