Created
July 22, 2009 16:18
-
-
Save puttputt/152086 to your computer and use it in GitHub Desktop.
a Ruby script that grabs a given user's TweetReel media.
This file contains 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 'rubygems' | |
require 'open-uri' | |
require 'json' | |
require 'net/http' | |
#what user? | |
username = 'kylesmyth' | |
#form url and get JSON | |
url = 'http://search.twitter.com/search.json?q='+ username +'+tweetreel.com' | |
buffer = open(url, "UserAgent" => "Ruby-Wget").read | |
result = JSON.parse(buffer) | |
#connect to tweetreel API | |
server = 'tweetreel.s3.amazonaws.com' | |
h = Net::HTTP.new(server, 80) | |
mentions = result['results'] | |
mentions.each do |tweet| | |
#get HTTP Header Response, parse it's content type | |
response = h.request_head('/images/'+ tweet['id'].to_s() + '.jpg') | |
if (response['content-type'] == 'image/jpeg') | |
p 'http://' + server + '/images/' + tweet['id'].to_s() + '.jpg' | |
end | |
response = h.request_head('/video/'+ tweet['id'].to_s() + '.mov') | |
if(response['content-type'] == 'text/plain') | |
p 'http://' + server + '/video/'+ tweet['id'].to_s() + '.mov' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment