VOODOO - Video tOOlkit and Data for OOyala. ActiveResource client that consumes the non-REST API OOYALA V2 API. It allows you to interface with the Ooyala v2 API using simple ActiveRecord-like syntax. Provides a DSL for querying video records that abstracts away the SQL like queries expected by this API.
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib bump version Sep 4, 2013
spec
.gitignore more setup Jun 28, 2013
.rspec
Gemfile get rid of Timecop gem Sep 3, 2013
Gemfile.lock update gemfile Sep 4, 2013
LICENSE
README.md
Rakefile use bundler to make gem file structure May 27, 2012
acts_as_voodoo.gemspec

README.md

Code Climate

Ooyala API V2 wrapper for Ruby (using ActiveResource)

VOODOO - VIDEO TOOLKIT and DATA for OOYALA

ActiveResource client that consumes a non-REST API OOYALA V2 API.

ActiveResource code base was heavily modified during the development process to process the non-RESTful HTTP requests.

It allows you to interface with the Ooyala v2 API using simple ActiveRecord-like syntax and provides a DSL for querying video records that abstracts away the SQL like queries expected by this API.

Requirements

  • Ruby 1.9.3 or greater
  • ActiveResource 4.0.0
  • ActiveSupport 4.0.0

See the examples directory for more usage examples.

Installation

cd <PATH>/acts_as_voodoo

bundle install

Usage

Query equality and relational operators
== equals
>= greater than or equal to
<= less than or equal to
> greater than
< less than
!= not equal to
* Get assets IN list of embed codes vid.embed_code * "('g0YzBnMjoGiHUtGoWW4pFzzhTZpKLZUi','g1YzBnMjrEWdqX0gNdtKwTwQREhEkf9e')"
=~ INCLUDES for querying assets within labels vid.labels =~ "Case Study" gives assets contained in label "Case Study"
class Asset < ActiveResource::Base
   my_api_key    = '<API KEY HERE>'
   my_api_secret = '<API SECRET HERE>'

   acts_as_voodoo :api_key => my_api_key, :api_secret => my_api_secret

   self.site = "https://api.ooyala.com/v2"
   
   # if your class is not name Asset 
   # then you define element name as 'asset'
   # self.element_name = "asset"
end

results = Asset.find(:one) do |vid|
   vid.description == "Under the sea."
   vid.duration > 600
end

The Query API can be used to request detailed information about your assets.

Queries are built using a SQL-like interface.

A sample query might look like:

/v2/assets?where=description='Under the sea.' AND duration < 600

So using acts_as_voodoo, you would do this

results = Asset.find(:first) do |vid|
   vid.description == "Under the sea."
   vid.duration > 600
end

Query API Examples

For scopes, you can use :all, :first, :last.

:one is not working as of now.

scopes of integer id values are not recognized by the API. Use embed codes in place of integer IDs.

Note: :all will give an array of AR instances. :first or :last will give an instance of AR.

Find all assets.

Asset.all

Find a single asset by name.

Asset.find(:first) { |vid| vid.name == "Iron Sky" }

Find a single asset by embed code.

Asset.find('9nbnkwYjqofX8NsCm9vISLV6iJ6bRZod')

The first 5 movies where the description is "Under the sea." that are greater than ten minutes long. The videos are ordered by created_at in ascending order.

SELECT * WHERE description = 'Under the sea.' AND duration > 600 ORDER BY created_at descending

/v2/assets?where=description='Under the sea.' AND duration > 600&orderby=created_at descending&limit=5

results = Asset.find(:all, :params => { 'orderby' => "created_at descending", 'limit' => 5 }) do |vid|
   vid.description == "Under the sea."
   vid.duration > 600
end

Get assets given a list of embed codes

SELECT * WHERE embed_code IN ('g0YzBnMjoGiHUtGoWW4pFzzhTZpKLZUi', 'g1YzBnMjrEWdqX0gNdtKwTwQREhEkf9e')

/v2/assets?where=embed_code IN ('g0YzBnMjoGiHUtGoWW4pFzzhTZpKLZUi','g1YzBnMjrEWdqX0gNdtKwTwQREhEkf9e')

results = Asset.find(:first) do |vid|
   vid.embed_code * "('g0YzBnMjoGiHUtGoWW4pFzzhTZpKLZUi','g1YzBnMjrEWdqX0gNdtKwTwQREhEkf9e')"
end

All assets tagged with the label "Case Study"

SELECT * WHERE labels INCLUDES 'Case Study'

/v2/assets?where=labels INCLUDES 'Case Study'

results = Asset.find(:all) do |vid|
   vid.labels =~ "Case Study"
end

Asset API Examples

Create a channel or channel set

Required fields: name, asset_type.

Use an asset type of "channel_set" to create a channel set.

new_channel            = Asset.new
new_channel.asset_type = "channel"
new_channel.name       = "new channel test"
new_channel.save

Delete an asset

# find by video embed code
video = Asset.find('g2cXI5NDpVyT8R0xlrun8tfzDB_d3rLc')
video.destroy

Label API Examples

class Label < ActiveResource::Base
   my_api_key    = '<API KEY HERE>'
   my_api_secret = '<API SECRET HERE>'

   acts_as_voodoo :api_key => my_api_key, :api_secret => my_api_secret

   self.site = "https://api.ooyala.com/v2"
   
   # if your class is not name Label 
   # then you define element name as 'label'
   # self.element_name = "label"
end

Create a label

Required parameters: name.

new_label = Label.new
new_label.name = "my new label"
new_label.save

Note: The name cannot contain hidden characters. Hidden characters are those with ascii values between 0 and 31, except for 10 (newline) and 13 (carriage return).

Delete labels

Deleting a label will automatically delete all its children.

all_labels = Label.find(:all)

all_labels.each do |label|
  if label.name == "my new label"
    label.destroy
  end
end

View all labels

all_labels = Label.find(:all)

View one label

# find by label id
label = Label.find('9459731df17043a08055fcc3e401ef9e')

Uploading Videos

TODO: Write usage instructions here