Rinser/paleo-test.js

106 lines
2.8 KiB
JavaScript
Raw Permalink Normal View History

2015-07-21 09:50:51 +00:00
var RssBraider = require('rss-braider'),
fs = require('fs'),
ejs = require('ejs'),
read = require('fs').readFileSync,
join = require('path').join,
str = read(join(__dirname, '/templates/rss.ejs'), 'utf8'),
2015-07-21 16:14:49 +00:00
sqlite3 = require('sqlite3').verbose(),
2015-07-21 09:50:51 +00:00
feeds = {};
2015-07-21 16:14:49 +00:00
var db = new sqlite3.Database(__dirname + '/images.db');
2015-07-21 09:50:51 +00:00
// 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",
'site_url':'http://pipes.silvrtree.co.uk/paleo.xml'
},
2015-07-23 10:37:04 +00:00
"plugins" : ['capitalize_title','filter_last_week'],
2015-07-21 09:50:51 +00:00
"sources" : [
{
/* "name" : "JobServe",*/
2015-07-21 16:14:49 +00:00
"count": 100,
"feed_url": "http://feeds.feedburner.com/PaleoPlan"
2015-07-21 09:50:51 +00:00
}
]
};
var braider_options = {
feeds : feeds,
indent : " ",
date_sort_order : "desc", // Newest first
2015-07-23 10:37:04 +00:00
log_level : "debug",
dedupe_fields : ['link','guid'],
plugins_directories : [__dirname + "/plugins/"],
2015-07-21 09:50:51 +00:00
};
var rss_braider = RssBraider.createClient(braider_options);
// Override logging level (debug, info, warn, err, off)
2015-07-23 10:37:04 +00:00
rss_braider.logger.level('debug');
2015-07-21 09:50:51 +00:00
// 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);
}
var j = JSON.parse(data);
2015-07-21 16:14:49 +00:00
2015-07-23 10:37:04 +00:00
/* j.items.forEach(function (obj, index) {
2015-07-21 16:14:49 +00:00
// console.log(obj); // logs "3", "5", "7"
// console.log(index); // logs "0", "1", "2"
var desc = obj.description;
var imgRegEx = /<img[^>]+src="([^">]+)"/;
var myArray = imgRegEx.exec(desc) || [];
if (myArray.length > 0)
{
console.log('Length: ' + myArray.length);
console.log(myArray[0]);
console.log(myArray[1]);
console.log('- - -');
}
2015-07-21 09:50:51 +00:00
});
2015-07-23 10:37:04 +00:00
*/
2015-07-21 16:14:49 +00:00
// var ejsOutput = ejs.compile(str)(j);
//console.log(j);
// console.log(ejsOutput);
});
/*
// grabbing images
<img[^>]+src="([^">]+)"
var fs = require('fs');
var request = require('request');
// Or with cookies
// var request = require('request').defaults({jar: true});
request.get({url: 'https://someurl/somefile.torrent', encoding: 'binary'}, function (err, response, body) {
fs.writeFile("/tmp/test.torrent", body, 'binary', function(err) {
if(err)
console.log(err);
else
console.log("The file was saved!");
});
});
*/