Created
May 7, 2016 15:11
-
-
Save charlieegan3/7966c55985cdb8d22011d8e3c97a4252 to your computer and use it in GitHub Desktop.
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
require 'json' | |
require 'open-uri' | |
require 'pry' | |
urls = [] | |
Dir.glob("general/*.json") do |f| | |
list = JSON.parse(File.open(f).read) | |
urls += list.select do |e| | |
e["file"] && e["file"]["filetype"].match(/jpg/) | |
end.map { |e| e["file"]["url_private_download"] } | |
end | |
urls.each_with_index do |e, i| | |
fork do | |
File.open("image_#{i}.jpg", 'w').write(open(e).read) | |
end | |
Process.waitall if i % 15 == 0 | |
end | |
Process.waitall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment