Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charlieegan3/7966c55985cdb8d22011d8e3c97a4252 to your computer and use it in GitHub Desktop.
Save charlieegan3/7966c55985cdb8d22011d8e3c97a4252 to your computer and use it in GitHub Desktop.
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