Skip to content

Instantly share code, notes, and snippets.

@puttputt
Created July 22, 2009 16:18
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 puttputt/152086 to your computer and use it in GitHub Desktop.
Save puttputt/152086 to your computer and use it in GitHub Desktop.
a Ruby script that grabs a given user's TweetReel media.
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