101 lines
3.0 KiB
JavaScript
101 lines
3.0 KiB
JavaScript
var RssBraider = require('rss-braider'), fs = require('fs'), CronJob = require('cron').CronJob,
|
|
feeds = {};
|
|
|
|
// Pull feeds from config files: ,
|
|
// feeds.simple_test_feed = require("./config/feed").feed;
|
|
// Or define in-line
|
|
feeds.simple_test_feed = {
|
|
"feed_name" : "feed",
|
|
"default_count" : 1,
|
|
"no_cdata_fields" : [], // Don't wrap these fields in CDATA tags
|
|
"meta" : {
|
|
"title": "Paleo",
|
|
"description": "Combined Paleo Feed"
|
|
},
|
|
"sources" : [
|
|
{
|
|
/* "name" : "JobServe",*/
|
|
"count" : 100,
|
|
"feed_url" : "http://feeds.feedburner.com/PaleoPlan"
|
|
},
|
|
{
|
|
/* "name" : "JobServe",*/
|
|
"count" : 100,
|
|
"feed_url" : "http://nomnompaleo.com/rss"
|
|
},
|
|
{
|
|
/* "name" : "JobServe",*/
|
|
"count" : 100,
|
|
"feed_url" : "http://thepaleodiet.com/feed/"
|
|
},
|
|
{
|
|
/* "name" : "JobServe",*/
|
|
"count" : 100,
|
|
"feed_url" : "http://paleoleap.com/feed/"
|
|
},
|
|
{
|
|
/* "name" : "JobServe",*/
|
|
"count" : 100,
|
|
"feed_url" : "http://ultimatepaleoguide.com/feed/"
|
|
},
|
|
{
|
|
/* "name" : "JobServe",*/
|
|
"count" : 100,
|
|
"feed_url" : "http://elanaspantry.com/feed/"
|
|
}
|
|
,
|
|
{
|
|
/* "name" : "JobServe",*/
|
|
"count" : 100,
|
|
"feed_url" : "http://feeds.feedburner.com/Paleomg-PaleoRecipes"
|
|
},
|
|
{
|
|
/* "name" : "JobServe",*/
|
|
"count" : 100,
|
|
"feed_url" : "http://civilizedcavemancooking.com/feed/"
|
|
}
|
|
]
|
|
};
|
|
var braider_options = {
|
|
feeds : feeds,
|
|
indent : " ",
|
|
date_sort_order : "desc", // Newest first
|
|
log_level : "warn"
|
|
};
|
|
var rss_braider = RssBraider.createClient(braider_options);
|
|
|
|
// Override logging level (debug, info, warn, err, off)
|
|
rss_braider.logger.level('off');
|
|
|
|
// Output braided feed as rss. use 'json' for JSON output.
|
|
rss_braider.processFeed('simple_test_feed', 'rss', function(err, data){
|
|
// rss_braider.processFeed('simple_test_feed', 'json', function(err, data){
|
|
if (err) {
|
|
return console.log(err);
|
|
}
|
|
// console.log(data);
|
|
fs.writeFile("./paleo.xml", data, function(err) {
|
|
if(err) {
|
|
return console.log(err);
|
|
}
|
|
|
|
console.log("The file was saved!");
|
|
});
|
|
});
|
|
|
|
|
|
var job = new CronJob({
|
|
//cronTime: '0 0/60 * 1/1 * ? *',
|
|
|
|
cronTime: '0 0/5 * 1/1 * ? *',
|
|
onTick: function() {
|
|
// Runs every hour
|
|
|
|
console.log('Tick');
|
|
|
|
|
|
},
|
|
start: false,
|
|
timeZone: "America/Los_Angeles"
|
|
});
|
|
job.start(); |