Skip to content

aphyr/ruby-vodpod

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Vodpod - Ruby bindings for the Vodpod API.
==========================================

Vodpod is a web site that allows you to collect videos. This library lets you
interact with those collections and videos over their REST-style API, using
clean Ruby. Maybe you want to integrate with a content management system, or
copy videos automatically from a social bookmarking site.  Be creative. :-)

You can search for videos, retrieve users, collections, videos, and their tags and comments. You can filter by tags, sort and paginate every dataset, and generally be awesome.

Source code: http://github.com/aphyr/ruby-vodpod.

Gem: gem install vodpod

Examples
--------

Vodpod.start(:api_key => '...', :auth_key => '...') do |v|
  # View the user associated with this API key
  v.me 
  #=> #<Vodpod::User spencer {"name"=>"Spencer", "thumbnail"=>"http://s3.amazonaws.com/vodpod.com.users.image/8.medium.jpg", "videos_count"=>670, "description"=>"Co-founder and Engineer at Vodpod", "key"=>"spencer"}>

  # Attributes are accessed like so...
  v.me.name #=> "Spencer"

  # Get a user, with some extra attributes
  v.user :aphyr, :include => [:collections, :followers] 
  #=> #<Vodpod::User aphyr {"name"=>"aphyr", "collections"=>[#<Vodpod::User aphyr {"name"=>"aphyr's videos", "key"=>"aphyr"}>], "followers"=>[#<Vodpod::User spencer {"name"=>"Spencer", "thumbnail"=>"http://s3.amazonaws.com/vodpod.com.users.image/8.medium.jpg", "key"=>"spencer"}>, #<Vodpod::User pkulak {"name"=>"pkulak", "thumbnail"=>"http://s3.amazonaws.com/vodpod.com.users.image/11221.medium.jpg", "key"=>"pkulak"}>], "thumbnail"=>"http://s3.amazonaws.com/vodpod.com.users.image/493234.medium.jpg", "videos_count"=>69, "description"=>"I'm a developer here at Vodpod. I'm also a freelance photographer, Aikido nut, gamer, book enthusiast, and physics and math geek.", "key"=>"aphyr"}>

  # Associated objects are automatically instantiated.
  v.user(:aphyr, :include => :collections).collections
  # => [#<Vodpod::Collection aphyr {"name"=>"aphyr's videos", "key"=>"aphyr"}>]

  # You can get more detail about a collection with collection(user_key,
  # collection_key). Let's build a tag cloud for aphyr's collection named
  # "aphyr".
  v.collection(:aphyr, :aphyr, :include => :tags).tags.map { |t| t.count, t.name }
  # => [[16, "funny"], [12, "awesome"], [6, "music"], [4, "trailer"], [4, "game"], [3, "apple"], [3, "ruby"], [3, "_why"], [3, "math"], [3, "fail"], [3, "robot"], [3, "lego"], [3, "neotokyo"], [2, "future-occupation?"], [2, "microsoft"], [2, "gay"], [2, "cat"], [2, "evil"], [2, "parkour"], [2, "science fiction"]]

  # You can find videos by searching...
  v.search(:kittens, :limit => 1, :offset => 14).first
  # => #<Vodpod::Video 29740 {"autoplay_embed"=>"<embed src=\"http://www.youtube.com/v/jn0Fo0Mt6xo&autoplay=1&fs=1&showinfo=0&showsearch=0&rel=0&\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\" width=\"100%\" height=\"100%\" id=\"myytplayer\"></embed>", "total_views"=>77, "created_at"=>#<DateTime: 10602058157/4320,-5/24,2299161>, "title"=>"Samson the Kitten", "video_host"=>{"url"=>"http://www.youtube.com/v/jn0Fo0Mt6xo", "domain"=>"youtube.com", "description"=>"Zachary gets Samson nodding and shaking his head."}, "thumbnail"=>"http://assetscdn.vodpod.com/images/missing_video_100.gif", "down_votes"=>0, "url"=>"http://vodpod.com/watch/29740-samson-the-kitten", "up_votes"=>0, "embed"=>"<embed src=\"http://www.youtube.com/v/jn0Fo0Mt6xo&autoplay=&fs=1&showinfo=0&showsearch=0&rel=0&\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\" width=\"100%\" height=\"100%\" id=\"myytplayer\"></embed>", "description"=>nil, "key"=>29740}>

  # Or by tags...
  v.videos(:tags => ['star trek', :bloopers]).total
  # => 494
  
  # You can retrieve specific videos if you know their key
  v.video(29740)
  # => (same video as from search)

  # You can also get CollectionVideos--the version of a video belonging to a
  # specific user/collection.
  v.videos(:spencer, :electro, :limit => 1).first
  # => #<Vodpod::CollectionVideo 1002751 {"autoplay_embed"=>"<embed src=\"http://www.youtube.com/v/v-3jOg5QpJo&autoplay=1&fs=1&showinfo=0&showsearch=0&rel=0&autoplay=&border=0&rel=0\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\" width=\"100%\" height=\"100%\" id=\"myytplayer\"></embed>", "total_views"=>3, "created_at"=>#<DateTime: 42417586163/17280,-5/24,2299161>, "title"=>"Crystal Castles - Knights", "video_host"=>{"url"=>"http://www.pitchforkmedia.com/article/download/145440-video-crystal-castles-knights", "domain"=>"pitchforkmedia.com", "description"=>""}, "thumbnail"=>"http://img.vodpod.com/1002751.medium100.jpg", "down_votes"=>0, "url"=>"http://vodpod.com/watch/1002751-crystal-castles-knights?pod=electro", "up_votes"=>1, "embed"=>"<embed src=\"http://www.youtube.com/v/v-3jOg5QpJo&autoplay=&fs=1&showinfo=0&showsearch=0&rel=0&autoplay=&border=0&rel=0\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\" width=\"100%\" height=\"100%\" id=\"myytplayer\"></embed>", "description"=>"", "key"=>1002751}>
end

You can contact support@vodpod.com for help with the toolkit. Patches welcome
on github!

About

Ruby bindings for the Vodpod API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages