Class Viddler::Base
In: lib/viddler/base.rb
Parent: Object

A class that can be instantiated for access to a Viddler API.

Examples:

  @viddler = Viddler::Base.new(API_KEY, USERNAME, PASSWORD)

Username and password are optional, some API methods doesn‘t require them:

  @viddler = Viddler::Base.new(YOUR_API_KEY)

Methods

Public Class methods

Creates new viddler instance.

Example:

  @viddler = Viddler::Base.new(api_key, username, password)

Public Instance methods

Implements viddler.users.auth.

It‘s not necessary for you to call this method manually before each method that requires authentication. Viddler.rb will do that for you automatically. You can use this method for checking credentials and for trying if connection to Viddler works.

Example:

 @viddler.authenticate

Returns a string with session id.

Implements viddler.videos.getFeatured.

Example:

 @viddler.find_all_featured_videos

Returns array of Viddler::Video instances.

Implements viddler.videos.getByTag.

Options hash could contain next values:

  • page: The "page number" of results to retrieve (e.g. 1, 2, 3);
  • per_page: The number of results to retrieve per page (maximum 100). If not specified, the default value equals 20.

Example:

 @viddler.find_all_videos_by_tag('super tag', :per_page => 5)

Returns array of Viddler::Video instances.

Implements viddler.videos.getByUser. Authentication is optional.

Options hash could contain next values:

  • page: The "page number" of results to retrieve (e.g. 1, 2, 3);
  • per_page: The number of results to retrieve per page (maximum 100). If not specified, the default value equals 20.

Example:

 @viddler.find_all_videos_by_user(username, :page => 2)

Returns array of Viddler::Video instances.

Implements viddler.users.getProfile.

Example:

 @viddler.find_profile(viddler_username)

Returns Viddler::User instance.

Implements viddler.videos.getDetails. Authentication is optional.

Example:

 @viddler.find_video_by_id(video_id)

Returns Viddler::Video instance.

Implements viddler.videos.getDetailsByUrl. Authentication is optional.

Example:

 @viddler.find_video_by_url('http://www.viddler.com/explore/username/videos/video_num/')

Returns Viddler::Video instance.

Implements viddler.videos.getRecordToken.

Example:

 @viddler.get_record_token

Returns a string with record token.

Implements viddler.videos.getStatus.

Example:

 @viddler.get_video_status(video_id)

This methods returns OpenStruct instance with Viddler‘s status information on a given video. We don‘t control what Viddler returns and it‘s all basically technical internal information of Viddler. Use this on your own risk.

Implements viddler.users.register. Restricted to Viddler qualified API keys only.

new_attributes hash should contain next required keys:

  • user: The chosen Viddler user name;
  • email: The email address of the user;
  • fname: The user‘s first name;
  • lname: The user‘s last name;
  • password: The user‘s password with Viddler;
  • question: The text of the user‘s secret question;
  • answer: The text of the answer to the secret question;
  • lang: The language of the user for the account (e.g. EN)
  • termsaccepted: "1" indicates the user has accepted Viddler‘s terms and conditions.

and could contain next optional keys:

  • company: The user‘s company affiliation.

Example:

 @viddler.register_user(:user => 'login', :email => 'mail@example.com', ...)

Returns new user‘s username string.

Implements viddler.users.setOptions. Requires authentication. Restricted to Viddler partners only.

new_attributes hash could contain next optional keys:

  • show_account: "1", "0" - Show/hide your account in Viddler. If you set it to "0" both your account and your videos won‘t be visible on viddler.com site
  • tagging_enabled: "1", "0" - Enable/disable tagging on all your videos
  • commenting_enabled: "1", "0" - Enable/disable commenting on all your videos
  • show_related_videos: "1", "0" - Show/hide related videos on all your videos
  • embedding_enabled: "1", "0" - Enable/disable embedding of off all your videos
  • clicking_through_enabled: "1", "0" - Enable/disable redirect to viddler site while clicking on embedded player
  • email_this_enabled: "1", "0" - Enable/disable email this option on all your videos
  • trackbacks_enabled: "1", "0" - Enable/disable trackbacks on all your videos
  • favourites_enabled: "1", "0" - Enable/disable favourites on all your videos
  • custom_logo_enabled: "1", "0" - Enable/disable custom logo on all your videos. Note that logo itself must be send to viddler manually.

Example:

 @viddler.update_account(:show_account => '0')

Returns number of updated parameters.

Implements viddler.users.setProfile. Requires authentication.

new_attributes hash could contain next optional keys:

  • first_name
  • last_name
  • about_me
  • birthdate: Birthdate in yyyy-mm-dd format;
  • gender: Either m or y.
  • company
  • city

Example:

 @viddler.update_profile(:first_name => 'Vasya', :last_name => 'Pupkin')

Returns Viddler::User instance.

Implements viddler.videos.setDetails. Requires authentication.

new_attributes hash could contain next optional keys:

  • title: Video title - 500 characters max
  • description: Video description
  • tags: List of tags to be set on video. Setting tags will update current tags set (both timed and global video tags). To set timed tag use format tagname[timestamp_in_ms] as tagname. For example - using tag1,tag2,tag3[2500] will set 2 global and 1 timed tag at 2.5s
  • view_perm: View permission. Can be set to public, shared_all, shared or private
  • view_users: List of users which may view this video if view_perm is set to shared. Only your viddler friends are allowed here. If you provide multiple usernames - non valid viddler friends usernames will be ignored.
  • view_use_secret: If view_perm is set to non public value, you may activate secreturl for your video. If you want to enable or regenerate secreturl pass "1" as parameter value. If you want to disable secreturl pass "0" as parameter value.
  • embed_perm: Embedding permission. Supported permission levels are the same as for view_perm. This and all permissions below cannot be less restrictive than view_perm. You cannot set it to public if view_perm is for example shared.
  • embed_users: Same as view_users. If view_perm is shared, this list cannot contain more users than view_users. Invalid usernames will be removed.
  • commenting_perm: Commenting permission. Description is the same as for embed_perm
  • commenting_users: Same as embed_users.
  • tagging_perm: Tagging permission. Description is the same as for embed_perm
  • tagging_users: Same as embed_users.
  • download_perm: Download permission. Description is the same as for embed_perm
  • download_users: Same as embed_users.

Example:

 @viddler.update_video(video_id, :title => 'Brand new title')

Returns Viddler::Video instance.

Implements viddler.videos.upload. Requires authentication.

new_attributes hash should contain next required keys:

  • title: The video title;
  • description: The video description;
  • tags: The video tags;
  • file: The video file;
  • make_public: Use "1" for true and "0" for false to choose whether or not the video goes public when uploaded.

Example:

 @viddler.upload_video(:title => 'Great Title', :file => File.open('/movies/movie.mov'), ...)

Returns Viddler::Video instance.

[Validate]