From f8452707cb72b10b01ad77d11a471b7016973ef8 Mon Sep 17 00:00:00 2001 From: Gabriel Dunne Date: Fri, 22 Mar 2013 15:00:14 -0700 Subject: [PATCH] just workin --- download_gifs.js | 22 +++++++++ download_gifs.py | 14 ++++++ index.html | 41 ---------------- lines-to-json.js | 1 - prelinger.db | Bin 0 -> 2048 bytes prelinger.json | 1 + prelinger_identifiers copy.txt | 2 + prelinger_thumbs.json | 1 + scrape-from-file.js | 1 - server_gifs.js | 86 +++++++++++++++++++++++++++++++++ test.js | 5 -- to_sqlite.js | 35 ++++++++++++++ 12 files changed, 161 insertions(+), 48 deletions(-) create mode 100644 download_gifs.js create mode 100644 download_gifs.py delete mode 100644 index.html create mode 100644 prelinger.db create mode 100644 prelinger.json create mode 100644 prelinger_identifiers copy.txt create mode 100644 prelinger_thumbs.json create mode 100644 server_gifs.js delete mode 100644 test.js create mode 100644 to_sqlite.js diff --git a/download_gifs.js b/download_gifs.js new file mode 100644 index 0000000..c73543d --- /dev/null +++ b/download_gifs.js @@ -0,0 +1,22 @@ +var exec = require('child_process').exec; +var clips = require('./prelinger.json'); clips = clips.clips; + +// var count = 0; + +// var dl_thumb = function (t) { +// console.log("downloading", t); +// exec('cd gifs/prelinger; curl -O ' + t); +// count++; +// } + + +setInterval(function(){ + console.log('hit'); +}, 2000); + + +// for (var i = 0; i < 1; i++) { +// var t = clips[i]['thumbnail'].split("?")[0]; +// dl_thumb(t); +// } + diff --git a/download_gifs.py b/download_gifs.py new file mode 100644 index 0000000..92c1049 --- /dev/null +++ b/download_gifs.py @@ -0,0 +1,14 @@ +import json +import os +from pprint import pprint +json_data = open('prelinger.json') + +data = json.load(json_data) +#pprint(data) + +for clip in data['clips']: + thumb = clip['thumbnail'].rpartition('?')[0] + print thumb + os.system('cd gifs/prelinger/; curl -O ' + thumb) + +json_data.close() diff --git a/index.html b/index.html deleted file mode 100644 index e9ab17f..0000000 --- a/index.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - diff --git a/lines-to-json.js b/lines-to-json.js index dc55985..22ba61f 100644 --- a/lines-to-json.js +++ b/lines-to-json.js @@ -7,5 +7,4 @@ function (line) { console.log('"'+line + '",'); } ); - console.log(']}'); diff --git a/prelinger.db b/prelinger.db new file mode 100644 index 0000000000000000000000000000000000000000..63cbe420489ca416d3b1b4b03d91b5cf512ace5e GIT binary patch literal 2048 zcmWFz^vNtqRY=P(%1ta$FlJz3U}R))P*7lCVBiK~CLo3ZMj(R)#sShGJ|V!(p!-Ob z7pRJn`4j^Xje^k-7!3iMgn$Vno4B|*qi0ECQch}4eo<;Jm|$`aa&-)GRS0o(@^MuF z3n^%1=B4E;gt$h8XoB)47xN?r=C91JnC~-RVLr*ck9jlm3g)>$!BH?80;3^7=MdoJ zVv_bOC@#%au;k=~F)cVbU`%sPb{Nx)lMTi+'); + // prelinger.clips.length + for( var i = 0; i < 50; i++) { + var clip = prelinger.clips[i]; + var t = clip.thumbnail.split('/'); + t = t[t.length-1].split('?')[0]; + var url = clip.url; + out.push([ + '
  • ', + '', + '', + '', + '
  • '].join("") + ); + } + out.push(''); + out.push(''); + var body = out.join(""); + + res.setHeader('Content-Type', 'text/html'); + res.setHeader('Content-Length', body.length); + res.end(body); + +}); + + + +app.configure(function(){ + app.use(express.methodOverride()); + app.use(express.bodyParser()); + app.use(express.static(__dirname + '/public')); + app.use(express.static(__dirname + '/gifs')); + app.use(express.errorHandler({ + dumpExceptions: true, + showStack: true + })); + app.use(app.router); +}); +app.listen(port); +console.log('Listening on port ' + port); + + + +/*var express = require('express'); +var app = express(); + +app.use(express.static(__dirname + '/css')); + +//app.use("/css", express.static(__dirname + '/css')); + +var prelinger = require('./prelinger.json'); + +app.get('/gifs', function(req, res){ + + var out = []; + out.push(''); + var body = out.join(""); + + res.setHeader('Content-Type', 'text/html'); + res.setHeader('Content-Length', body.length); + res.end(body); +}); + +app.listen(3000); +console.log('Listening on port 3000'); + +*/ diff --git a/test.js b/test.js deleted file mode 100644 index 3f9ee46..0000000 --- a/test.js +++ /dev/null @@ -1,5 +0,0 @@ -var page = require('webpage').create(); -page.open('http://google.com', function () { - page.render('google.png'); - phantom.exit(); -}); diff --git a/to_sqlite.js b/to_sqlite.js new file mode 100644 index 0000000..7663f01 --- /dev/null +++ b/to_sqlite.js @@ -0,0 +1,35 @@ +// output to sqlite + +var thumbs = require('./prelinger_thumbs.json'); + +console.log(thumbs[0]); + +var sqlite3 = require('sqlite3').verbose(); +var db = new sqlite3.Database('prelinger.db'); +db.serialize(function() { + + db.run("CREATE TABLE lorem (info TEXT)"); + + /* +CREATE TABLE IF NOT EXISTS entries( +id INTEGER PRIMARY KEY AUTOINCREMENT, +added DEFAULT CURRENT_TIMESTAMP, +link TEXT, +title TEXT, +desc TEXT, +url TEXT, +mimetype TEXT) + */ + + var stmt = db.prepare("INSERT INTO lorem VALUES (?)"); + for (var i = 0; i < 10; i++) { + stmt.run("Ipsum " + i); + } + stmt.finalize(); + + db.each("SELECT rowid AS id, info FROM lorem", function(err, row) { + console.log(row.id + ": " + row.info); + }); +}); + +db.close(); -- 2.34.1