Rinser/fixer.js

39 lines
755 B
JavaScript
Raw Permalink Normal View History

2017-09-11 10:34:45 +00:00
const querystring = require('querystring');
2017-09-11 11:29:20 +00:00
const url = require('url');
2017-09-11 10:34:45 +00:00
let list = [
2017-10-01 17:25:17 +00:00
2017-12-05 11:54:53 +00:00
{
2017-10-01 17:25:17 +00:00
"count": 100,
2018-03-04 16:39:52 +00:00
"feed_url": "https://www.changedetection.com/accountfeed.xml?feedid=438821327538204"
2017-10-01 17:25:17 +00:00
}
2017-12-05 11:54:53 +00:00
2017-10-01 17:25:17 +00:00
];
2017-09-11 10:34:45 +00:00
let newArray = list.map((item) => {
2017-09-11 11:29:20 +00:00
let u = url.parse(item.feed_url);
let newUrl = item.feed_url;
2017-09-11 11:31:41 +00:00
if (u.host !== '') {
2017-09-11 11:29:20 +00:00
newUrl = `http://52.211.105.9:6566/${querystring.escape(item.feed_url)}`;
}
2017-09-11 13:55:11 +00:00
return newUrl
2017-09-11 10:34:45 +00:00
});
2017-09-11 13:55:11 +00:00
console.log('New array', newArray.length);
let unique = [];
for (let item of newArray) {
if (unique.indexOf(item) === -1) {
unique.push(item);
}
}
console.log('unique', unique.length);
2017-09-11 10:34:45 +00:00
2017-09-11 13:55:11 +00:00
unique = unique.map((item) => {
return {'count':100, 'feed_url':item};
})
console.log(JSON.stringify(unique));