Skip to content

Instantly share code, notes, and snippets.

@hanachin
Created October 24, 2012 14:58
Show Gist options
  • Save hanachin/3946566 to your computer and use it in GitHub Desktop.
Save hanachin/3946566 to your computer and use it in GitHub Desktop.
download gif animations from kksg.net
require 'fileutils'
require 'open-uri'
require 'json'
DIRNAME = File.join(File.dirname(File.expand_path(__FILE__)), 'gifs')
Dir.mkdir(DIRNAME) unless File.exists?(DIRNAME)
gifs = JSON.parse(open('http://kksg.net/api/gifs.json').read)
gifs.map{|gif| gif["md5"]}.each {|md5|
url = "http://kksg.net/data/gif/#{md5}"
filename = File.join(DIRNAME, "#{md5}.gif")
if File.exists?(filename)
puts "already downloaded #{url}"
else
puts "Download #{url}"
gif = open(url)
FileUtils.mv(gif.path, filename)
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment