url_expander
The idea is simple, One expander to expand them all. I’ve been working on an analytical tool for twitter.com and i wanted a way to expand all the shortened urls. Url_expander is a good start, it covers 34 services. I tried to make it as simple as possible to extend & add new services.
Install
gem install
How to use
Download the config used to authenticate with some of the shortening services
curl -s https://raw.github.com/gist/1086114/c5c401e811effc3e99ed37ae9503f267877d8e68/url_expander_credentials.yml -o ~/url_expander_credentials.yml
Require and Use
require 'rubygems' # if ruby < 1.9
require 'url_expander'
UrlExpander::Client.('http://tinyurl.com/66sekq5')
Options
-
:nested_shortening – Nested shortening is turned on by default (:nested_shortening => true)
UrlExpander::Client.("http://t.co/ZGEGdas") => "http://www.blink182.com/upallnight/" UrlExpander::Client.("http://t.co/ZGEGdas", :nested_shortening => false) => "http://bit.ly/oi029o"
-
:limit – If the nested_shortening is turned on, then :limit controls the max number of redirection allowed. Default value is 10
UrlExpander::Client.('http://tinyurl.com/66sekq5', :limit => 4)
-
:config_file – Some services Require credentials to access the api (such as bitly). You need to provide YAML file with the access credentials. Default is “~/url_expander_credentials.yml”.
UrlExpander::Client.('http://bit.ly/qpshuI', :config_file => '/Users/moski/url_expander_credentials.yml')
Supported Services:
-
4sq.com
UrlExpander::Client.("http://4sq.com/pQkuZk")
-
bit.ly
UrlExpander::Client.("http://bit.ly/qpshuI")
-
j.mp
UrlExpander::Client.("http://j.mp/qpshuI")
-
budurl.com
UrlExpander::Client.("http://budurl.com/EYOS2")
-
cli.gs
UrlExpander::Client.("http://cli.gs/2BAzKa")
-
decenturl.com
UrlExpander::Client.("http://decenturl.com/youtube/medieval") UrlExpander::Client.("http://youtube.decenturl.com/medieval")
-
fxn.ws
UrlExpander::Client.("http://fxn.ws/pBewvL")
-
goo.gl
UrlExpander::Client.("http://goo.gl/DRppM")
-
is.gd
UrlExpander::Client.("http://is.gd/wsJRhR")
-
nyti.ms
UrlExpander::Client.("http://nyti.ms/dzy2b7")
-
tcrn.ch
UrlExpander::Client.("http://tcrn.ch/oe50JN")
-
xrl.us
UrlExpander::Client.("http://xrl.us/bkz5iy")
-
adjix.com
UrlExpander::Client.("http://adjix.com/cm4m")
-
digbig.com
UrlExpander::Client.("http://digbig.com/3bbd")
-
doiop.com
UrlExpander::Client.("http://doiop.com/dz8896")
-
easyurl.jp
UrlExpander::Client.("http://easyurl.jp/1qdv")
-
just.as
UrlExpander::Client.("http://just.as/amMF3i")
-
moourl.com
UrlExpander::Client.("http://moourl.com/flsho")
-
notlong.com
UrlExpander::Client.("http://moski.notlong.com")
-
nutshellurl.com
UrlExpander::Client.("http://nutshellurl.com/1v38")
-
ow.ly
UrlExpander::Client.("http://ow.ly/5EVkL")
-
shrt.st
UrlExpander::Client.("http://shrt.st/148u")
-
snipurl.com, sn.im, cl.lk, snipr.com, snurl.com
UrlExpander::Client.("http://snipurl.com/209hem") UrlExpander::Client.("http://sn.im/209hem") UrlExpander::Client.("http://cl.lk/209hem") UrlExpander::Client.("http://snipr.com/209hem") UrlExpander::Client.("http://snurl.com/209hem")
-
t.co
UrlExpander::Client.("http://t.co/ZGEGdas")
-
tighturl.com
UrlExpander::Client.("http://tighturl.com/3eoz")
-
tiny.cc
UrlExpander::Client.("http://tiny.cc/pabx5")
-
tinyurl.com
UrlExpander::Client.("http://tinyurl.com/66sekq5")
-
twurl.nl
UrlExpander::Client.("http://twurl.nl/e6mglc")
-
url.ie
UrlExpander::Client.("http://url.ie/cert")
-
youtu.be
UrlExpander::Client.("http://youtu.be/bINUfbLV_0M")
-
y2u.be
UrlExpander::Client.("http://y2u.be/bINUfbLV_0M")
-
qsr.li
UrlExpander::Client.("http://qsr.li/5Zg9")
-
shorl.com
UrlExpander::Client.("http://shorl.com/nigekohalenu")
-
simurl.com
UrlExpander::Client.("http://simurl.com/fendaz")
Services are divided into 3 categories:
-
Provide an API for expanding
-
Support 301 redirection
-
Manual Scraping
Contributing to url_expander
-
Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
-
Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
-
Fork the project
-
Start a feature/bugfix branch
-
Commit and push until you are happy with your contribution
-
Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright
Copyright © 2011 Moski. See LICENSE.txt for further details.