mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
parent
5d4a255876
commit
6b6f90a006
@ -18,6 +18,7 @@ module.exports = function(RED) {
|
||||
"use strict";
|
||||
var FeedParser = require("feedparser");
|
||||
var request = require("request");
|
||||
var url = require('url');
|
||||
|
||||
function FeedParseNode(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
@ -26,7 +27,10 @@ module.exports = function(RED) {
|
||||
var node = this;
|
||||
this.interval_id = null;
|
||||
this.seen = {};
|
||||
if (this.url !== "") {
|
||||
var parsedUrl = url.parse(this.url);
|
||||
if (!(parsedUrl.host || (parsedUrl.hostname && parsedUrl.port)) && !parsedUrl.isUnix) {
|
||||
this.error(RED._("feedparse.errors.invalidurl"));
|
||||
} else {
|
||||
var getFeed = function() {
|
||||
var req = request(node.url, {timeout: 10000, pool: false});
|
||||
//req.setMaxListeners(50);
|
||||
@ -64,8 +68,6 @@ module.exports = function(RED) {
|
||||
};
|
||||
this.interval_id = setInterval(function() { getFeed(); }, node.interval);
|
||||
getFeed();
|
||||
} else {
|
||||
this.error(RED._("feedparse.errors.invalidurl"));
|
||||
}
|
||||
|
||||
this.on("close", function() {
|
||||
|
@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "node-red-node-feedparser",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"description": "A Node-RED node to get RSS Atom feeds.",
|
||||
"dependencies": {
|
||||
"feedparser": "1.1.3",
|
||||
"request": "2.61.0"
|
||||
"request": "2.65.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
Loading…
Reference in New Issue
Block a user