Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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 = ''+ username +''
buffer = open(url, "UserAgent" => "Ruby-Wget").read
result = JSON.parse(buffer)
#connect to tweetreel API
server = ''
h =, 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'
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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment