/viddler-ruby

The official gem for interacting with Viddler's V2 API

Primary LanguageRubyMIT LicenseMIT

viddler-ruby

viddler-ruby is the officially supported gem for Viddler's V2 API.

Installation

$ gem install viddler-ruby

Rails 2

Add the following to your config/environment.rb:

config.gem 'viddler-ruby'

Make sure to run rake gems:install afterwards.

Rails 3 and Bundler

Add the following to your Gemfile:

gem 'viddler-ruby'

Make sure to run bundle install afterwards

Other

To use in a regular Ruby project:

require 'rubygems'
require 'viddler-ruby'

Usage

viddler-ruby provides a simple interface to Viddler's API. To use, just instantiate an instance of Viddler::Client and call the #get and #post methods. For example, to get the details of a video:

viddler = Viddler::Client.new('your api key')
video = viddler.get 'viddler.videos.getDetails', :video_id => 'abc123'

puts video['title'] # => "My video"
puts video['id']    # => "abc123"

For an authenticated client, just call authenticate! on the client:

viddler = Viddler::Client.new('your api key')
viddler.authenticate! 'username', 'password'

Then, any calls made on viddler will be done using the correct session id.

If you want to record a video, you can request a record token during authentication:

viddler = Viddler::Client.new('your api key')
viddler.authenticate! 'username', 'password', true
puts viddler.record_token   # => the record token from API

The API returns a record token that's available for you.

Uploading

To upload a file, use the upload method:

viddler.upload(File.open('./myvideo.mov'), {
  :title       => 'My video',
  :description => 'This video is awesome!',
  :tags        => 'awesome'
})