Skip to content

bananastalktome/muri

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Media URI Parser – MURI

A simple to use media URI Parser. Pass a URI in, get helpful information out.

MURI Currently supports:

Installation & basic usage

Install muri as a ruby gem (you might need to run this command as root by prepending sudo to it):


  $ gem install muri

Using muri is just as easy!


  a = Muri.parse('http://www.youtube.com/watch?v=blahblahblah&feature=rec-LGOUT-exp_fresh+div-1r-1-HM')

If a.valid? is true, you are good to go. If not, either the URI host was not recognized, or the path/parameters provided along with a known URI host were not recognized. When these two types of errors are encountered, an exception is caught and returned in a.errors as either “Muri::NoParser” or “Muri::UnrecognizedURI” (or potentially “URI::BadURIError” or “URI::InvalidURIError” if the URI passed is bad). If you don’t care about the type of error, just whether the URI was parsed, a.valid? will give you a boolean answer.

Assuming the URI was successfully parsed (thus a.valid? == true), all media types share several common attributes:


  a.media_service         # 'Youtube'
  a.media_id              # 'blahblahblah'
  a.media_uri             # URI object for 'http://www.youtube.com/watch?v=blahblahblah&feature=rec-LGOUT-exp_fresh+div-1r-1-HM'

Due to variations in information which can be gathered from a uri, some services provide more information than others. For example:

  • All but Imageshack have a media_api_id, which is the ID which can be used in API calls to the related services. Typically the same as media_id.

  a.media_api_id     # 'blahblahblah'

  • Services with a media_api_id also have a media_api_type, which indicates what sort of API call should be made (be it ‘photo’, ‘video’, ‘media’, ‘set’, ‘album’, or ‘playlist’, depending on URI type)

NOTE: Facebook content returns a media_api_id string which is the FQL compatible ID. Facebook photos can also returns a media_api_ids hash, keyed by :uid, :pid, and :fql_id (user, photo, and fql id). This is courtesy the new Facebook Graph API messing stuff up.

ALSO NOTE: Picasa media_api_id is a partial string for using the photo API call, so for example 'bananastalktome/album/TestForAPI/photoid/5450524726782297346', thus the API call would be "http://picasaweb.google.com/data/feed/api/user/#{media_api_id}"

  • A direct media url for Youtube, Photobucket (photos, not albums), Twitpic, Imageshack (http://img#{num}.imageshack.us/img#{num}/#{NUMBER}/#{IMAGENAME} format) and flickr (http://farm#{num}.static.flickr.com/ format)

  a.media_url         # 'http://www.youtube.com/v/blahblahblah'

  • A media landing website url for Facebook, Picasa, Youtube, Photobucket, Imageshack, Vimeo, Twitpic, and Flickr (flickr returns the http://flic.kr/p/#{ID} short url)

  a.media_website           # 'http://www.youtube.com/watch?v=blahblahblah'

  • Content type for Imageshack, Photobucket (photos, not albums) and Flickr (flickr in the http://farm#{num}.static.flickr.com/ format)

  a.media_content_type      # 'jpg' (Content Type also for Imageshack and Photobucket)

  • Thumbnails URL for Youtube, Photobucket (photos, not albums), Twitpic, and Flickr (flickr in the http://farm#{num}.static.flickr.com/ format)

  a.media_thumbnail   # 'http://i.ytimg.com/vi/4CYDFoEz8rg/default.jpg'

Some additional information may be provided, which can be determined by looking through each filters code.

If an attribute is not present, muri returns nil.

Contact

If you would like to get in contact with me, my email is [email protected]. I appreciate any information or assistance reverse-engineering media website URI’s. I plan on including more services and more parse information with updates. That being said, MURI is currently not production quality. Please use with caution and in development only. Thank you.

About

Media URI Parser

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages