From a164da9f253d9322d71d9714cdfb6a7f8b9c90c0 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Fri, 31 Jul 2015 11:57:16 +0100 Subject: [PATCH] debugging braider --- node_modules/rss-braider/lib/RssBraider.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/node_modules/rss-braider/lib/RssBraider.js b/node_modules/rss-braider/lib/RssBraider.js index 97df1f3..f09dd58 100644 --- a/node_modules/rss-braider/lib/RssBraider.js +++ b/node_modules/rss-braider/lib/RssBraider.js @@ -79,11 +79,13 @@ RssBraider.prototype.processFeed = function(feed_name, format, callback) // Process each feed source through Feedparser to get articles. // Then process each item/article through rss-braider and any plugins async.each(feed.sources, function(source, callback) { + console.log('+ async.each'); var count = source.count || feed.default_count || 10, // Number of articles per source url = source.feed_url || null, file_path = source.file_path || null, source_articles = []; + console.log('Pre FeedParser'); var feedparser = new FeedParser(); if (url) { var req = request(url); @@ -97,10 +99,12 @@ RssBraider.prototype.processFeed = function(feed_name, format, callback) if (res.statusCode !== 200) { return this.emit('error', 'Bad status code: ' + res.statusCode); } + console.log('** DO FEED Parser A'); stream.pipe(feedparser); }); } else if (file_path) { // open file + console.log('** DO FEED Parser B'); var filestream = fs.createReadStream(file_path); filestream.pipe(feedparser); } else { @@ -114,6 +118,7 @@ RssBraider.prototype.processFeed = function(feed_name, format, callback) // Collect the articles from this source feedparser.on('readable', function() { + console.log('+ readable: ' + source.feed_url); var stream = this, item; @@ -129,9 +134,11 @@ RssBraider.prototype.processFeed = function(feed_name, format, callback) source_articles.push(article); } } + console.log('- readable'); }); feedparser.on("end", function(){ + console.log('+ end'); // de-dupe , date sort, and trim this feed's articles and push them into array // console.log('** Go for dedupe'); @@ -143,7 +150,9 @@ RssBraider.prototype.processFeed = function(feed_name, format, callback) source_articles = source_articles.slice(0, count); feed_articles = feed_articles.concat(source_articles); callback(); + console.log('- end'); }); + console.log('- async.each'); }, function(err){ if (err) {