Created
December 8, 2014 17:41
-
-
Save 100ideas/4abc9e9e5cb99236976c to your computer and use it in GitHub Desktop.
javascript to download images listed in posts.json from kristopolous/tumblr-scraper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////////////////////// | |
// console javascript to download images listed in | |
// json file generated by tumblr-scraper | |
// https://github.com/kristopolous/tumblr-scraper | |
// | |
// uses Artoo! I'm lazy, probably massive overkill | |
// http://medialab.github.io/artoo/save/ | |
// | |
// requires chrome | |
// images stored in usual download folder | |
// | |
// paste in the giant json object literal or adjust the code | |
// to parse the posts.json file | |
imgs = { | |
"[0123456789]":[["http://[0-9].media.tumblr.com/[hash]_100.gif"],["http://[0-9]media.tumblr.com/[hash]_250.gif"]], | |
"[0123456789]":[["http://[0-9].media.tumblr.com/[hash]_100.gif"],["http://[0-9]media.tumblr.com/[hash]_400.gif"]], | |
"[0123456789]":[["http://[0-9].media.tumblr.com/[hash]_100.gif"],["http://[0-9]media.tumblr.com/[hash]_250.gif"]], | |
"[0123456789]":[["http://[0-9].media.tumblr.com/[hash]_100.gif"],["http://[0-9]media.tumblr.com/[hash]_500.gif"]], | |
"[0123456789]":[["http://[0-9].media.tumblr.com/[hash]_100.gif"],["http://[0-9]media.tumblr.com/[hash]_400.gif"]], | |
"[0123456789]":[["http://[0-9].media.tumblr.com/[hash]_100.jpg"],["http://[0-9]media.tumblr.com/[hash]_1280.jpg"]], | |
"[0123456789]":[["http://[0-9].media.tumblr.com/[hash]_100.jpg"],["http://[0-9]media.tumblr.com/[hash]_500.jpg"]], | |
"[0123456789]":[["http://[0-9].media.tumblr.com/[hash]_100.jpg"],["http://[0-9]media.tumblr.com/[hash]_1280.jpg"]], | |
"[0123456789]":[["http://[0-9].media.tumblr.com/[hash]_100.jpg"],["http://[0-9]media.tumblr.com/[hash]_500.jpg"]], | |
"[0123456789]":[["http://[0-9].media.tumblr.com/[hash]_100.jpg"],["http://[0-9]media.tumblr.com/[hash]_1280.jpg"]], | |
"[0123456789]":[["http://[0-9].media.tumblr.com/[hash]_100.jpg"],["http://[0-9]media.tumblr.com/[hash]_1280.jpg"]] | |
}; | |
function pausecomp(millis) { | |
var date = new Date(); | |
var curDate = null; | |
do { curDate = new Date(); } | |
while(curDate-date < millis); | |
} | |
var grabImages = function(json){ | |
var i = 1; | |
for (key in json){ | |
json[key].forEach(function(value, index){ | |
artoo.saveResource(value); | |
console.log(i + ": downloaded " + value); | |
if (i % 10 == 0){ | |
var wait = Math.random()*10000; // take it easy on the pipes | |
console.log('waiting a little bit... (' + wait + ')' ); | |
pausecomp(wait); | |
} | |
}); | |
i++; | |
} | |
}; | |
grabImages(imgs); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sounds good ... you ok with MIT license? (Just realized I don't even have mine marked as that)