public
Last active

a Ruby script that grabs a given user's TweetReel media.

  • Download Gist
TweetReel API Get?.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.