Last active
August 29, 2015 14:06
-
-
Save gomasy/0cca428d56607930dc08 to your computer and use it in GitHub Desktop.
Twitpic から写真を巻き上げるやつ
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
#!/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