Skip to content

Instantly share code, notes, and snippets.

@gomasy
Last active August 29, 2015 14:06
Show Gist options
  • Save gomasy/0cca428d56607930dc08 to your computer and use it in GitHub Desktop.
Save gomasy/0cca428d56607930dc08 to your computer and use it in GitHub Desktop.
Twitpic から写真を巻き上げるやつ
#!/usr/bin/ruby
require "http"
require "json"
@url = "http://api.twitpic.com/2/users/show.json"
@page = 1
if ARGV[0] != nil
if ARGV[1] == nil
loop do
user = JSON.parse(HTTP.get("#{@url}?username=#{ARGV[0]}&page=#{@page}"))
if !user.key?("errors")
user["images"].each do |photo|
`curl -O https://d3j5vwomefv46c.cloudfront.net/photos/large/#{photo["id"]}.#{photo["type"]}`
end
@page += 1
else
break
end
end
else
user = JSON.parse(HTTP.get("#{@url}?username=#{ARGV[0]}&page=#{ARGV[1]}"))
user["images"].each do |photo|
`curl -O https://d3j5vwomefv46c.cloudfront.net/photos/large/#{photo["id"]}.#{photo["type"]}`
end
end
else
puts "usage: ./twitpic.rb username page(optional)"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment