mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
parent
1bb31ba7ad
commit
4ee6e57111
@ -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);
|
||||
}
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user