106 lines
2.8 KiB
JavaScript
106 lines
2.8 KiB
JavaScript
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'),
|
|
sqlite3 = require('sqlite3').verbose(),
|
|
feeds = {};
|
|
|
|
var db = new sqlite3.Database(__dirname + '/images.db');
|
|
|
|
// 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'
|
|
},
|
|
|
|
"plugins" : ['capitalize_title','filter_last_week'],
|
|
"sources" : [
|
|
{
|
|
/* "name" : "JobServe",*/
|
|
"count": 100,
|
|
"feed_url": "http://feeds.feedburner.com/PaleoPlan"
|
|
}
|
|
]
|
|
};
|
|
var braider_options = {
|
|
feeds : feeds,
|
|
indent : " ",
|
|
date_sort_order : "desc", // Newest first
|
|
log_level : "debug",
|
|
dedupe_fields : ['link','guid'],
|
|
plugins_directories : [__dirname + "/plugins/"],
|
|
|
|
};
|
|
var rss_braider = RssBraider.createClient(braider_options);
|
|
|
|
// Override logging level (debug, info, warn, err, off)
|
|
rss_braider.logger.level('debug');
|
|
|
|
// 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);
|
|
|
|
|
|
/* j.items.forEach(function (obj, index) {
|
|
// 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('- - -');
|
|
}
|
|
});
|
|
*/
|
|
// 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!");
|
|
});
|
|
});
|
|
|
|
*/
|