let feedparser accept simple xml headers

to close #867
This commit is contained in:
Dave Conway-Jones 2021-12-23 10:59:21 +00:00
parent 1bb31ba7ad
commit 4ee6e57111
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 6 additions and 6 deletions

View File

@ -10,19 +10,19 @@ module.exports = function(RED) {
this.url = n.url;
if (n.interval > 35790) { this.warn(RED._("feedparse.errors.invalidinterval")) }
this.interval = (parseInt(n.interval)||15) * 60000;
var node = this;
this.interval_id = null;
this.seen = {};
var node = this;
var parsedUrl = url.parse(this.url);
if (!(parsedUrl.host || (parsedUrl.hostname && parsedUrl.port)) && !parsedUrl.isUnix) {
this.error(RED._("feedparse.errors.invalidurl"));
node.error(RED._("feedparse.errors.invalidurl"));
}
else {
var getFeed = function() {
var req = request(node.url, {timeout:10000, pool:false});
//req.setMaxListeners(50);
req.setHeader('user-agent', 'Mozilla/5.0 (Node-RED)');
req.setHeader('accept', 'application/rss+xml,text/html,application/xhtml+xml');
req.setHeader('accept', 'application/rss+xml,text/html,application/xhtml+xml,application/xml');
var feedparser = new FeedParser();
@ -53,11 +53,11 @@ module.exports = function(RED) {
feedparser.on('meta', function (meta) {});
feedparser.on('end', function () {});
};
this.interval_id = setInterval(function() { getFeed(); }, node.interval);
node.interval_id = setInterval(function() { getFeed(); }, node.interval);
getFeed();
}
this.on("close", function() {
node.on("close", function() {
if (this.interval_id != null) {
clearInterval(this.interval_id);
}

View File

@ -1,6 +1,6 @@
{
"name": "node-red-node-feedparser",
"version": "0.2.1",
"version": "0.2.2",
"description": "A Node-RED node to get RSS Atom feeds.",
"dependencies": {
"feedparser": "^2.2.10",