ruby-mtv

by Tieg Zaharia
http://github.com/tiegz/ruby-mtv

DESCRIPTION:

This is a Ruby library for the MTV Networks api. Right now it has classes for Artists and Videos, although there is much to be done, spec’d and/or tested!

REQUIREMENTS:

  • ActiveSupport

INSTALL:

$ gem sources -a http://gems.github.com/ (you only need to do this once)
$ gem install tiegz-ruby-mtv

USAGE:

Require the gem…

require 'tiegz-ruby-mtv'

To find an artist,

artist = MTV::Artist.search('dinosaur jr').first
# => #<MTV::Artist name: "Dinosaur Jr.", uid: "dinosaur_jr", uri: "http://api.mtvnservices.com/1/artist/dinosaur_jr/">

To find related artists,

artist.related
# => [#<MTV::Artist name: "Afghan Whigs", uid: "afghan_whigs", uri: "http://api.mtvnservices.com/1/artist/afghan_whigs/">, 
      #<MTV::Artist name: "The Breeders", uid: "breeders", uri: "http://api.mtvnservices.com/1/artist/breeders/">, ... ]

To find a video,

video = MTV::Video.search('dinosaur jr').first
# => #<MTV::Video title: "Been There All the Time", uid: "hznHivqrbHHDAXBAZ", artist_name: "Dinosaur Jr.", 
                  uri: "http://api.mtvnservices.com/1/video/hznHivqrbHHDAXB...", 
                  artist_uri: "http://api.mtvnservices.com/1/artist/dinosaur_jr/">
v.artist
# => #<MTV::Artist name: "Dinosaur Jr.", uid: "dinosaur_jr", uri: "http://api.mtvnservices.com/1/artist/dinosaur_jr/">

To get html embed markup for the video swf,

v.embed_code(:width => 200)
# => "<embed src=\"http://media.mtvnservices.com/mgid:uma:video:api.mtvnservices.com:143042\" 
             type=\"application/x-shockwave-flash\" width=\"200\" height=\"163\"
             allowFullScreen=\"true\" allowScriptAccess=\"always\" />"

To find all videos for an artist,

artist.videos
# => [#<MTV::Video title: ["Been There All the Time"], uid: "hznHivqrbHHDAXBAZ", artist_name: ["Dinosaur Jr."] ...>, ... ]
MTVN api docs: http://developer.mtvnservices.com/docs