From 1b1364e71f60fc18742e153c7107348ccbd46455 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Jul 2015 17:14:49 +0100 Subject: [PATCH] db and image stuff --- .gitignore | 1 + images.db | 0 package.json | 3 +- paleo-test.js | 100 ++++++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 91 insertions(+), 13 deletions(-) create mode 100644 .gitignore create mode 100644 images.db diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2ccbe46 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/node_modules/ diff --git a/images.db b/images.db new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json index f06e2a3..d920ec6 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ }, "devDependencies": { "lodash": "^3.10.0", - "rss-braider": "^1.0.0" + "rss-braider": "^1.0.0", + "sqlite3": "^3.0.9" } } diff --git a/paleo-test.js b/paleo-test.js index b90d019..31a3e88 100644 --- a/paleo-test.js +++ b/paleo-test.js @@ -4,8 +4,11 @@ var RssBraider = require('rss-braider'), 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 @@ -21,8 +24,44 @@ feeds.simple_test_feed = { "sources" : [ { /* "name" : "JobServe",*/ - "count" : 1, - "feed_url" : "http://feeds.feedburner.com/PaleoPlan" + "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/" } ] }; @@ -46,16 +85,53 @@ rss_braider.logger.level('off'); } var j = JSON.parse(data); - var ejsOutput = ejs.compile(str)(j); - console.log(j); - console.log(ejsOutput); - fs.writeFile(__dirname + "/html/paleo.html", ejsOutput, function(err) { - //fs.writeFile(__dirname + "/html/paleo.json", data, function(err) { - if(err) { - return console.log(err); - } - console.log("The file was saved!"); - }); + 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 = /]+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 +]+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!"); + }); +}); + +*/