debugging braider
This commit is contained in:
parent
0c720448ab
commit
a164da9f25
9
node_modules/rss-braider/lib/RssBraider.js
generated
vendored
9
node_modules/rss-braider/lib/RssBraider.js
generated
vendored
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user