class Tubeclip::Model::Video

Attributes

access_control[R]
Hash

string-keyed, string-valued permissions e.g., {'comment'=>'allowed','videoRespond'=>'moderated'}

author[R]
Tubeclip::Model::Author

Information about the YouTube user who owns a piece of video content.

categories[R]
Array

A array of Tubeclip::Model::Category objects that describe the videos categories.

comment_count[R]
Fixnum

Number of comments for this video

description[R]
String

Description of the video.

duration[R]
Fixnum

Duration of a video in seconds.

favorite_count[R]
Fixnum

Number of times that the video has been favorited

html_content[R]
String

Description of the video.

insight_uri[R]
String

URI for insight for this video, if present; nil otherwise

keywords[R]
Array

An array of words associated with the video.

latitude[R]
longitude[R]
media_content[R]
Array

An array of Tubeclip::Model::Content objects describing the individual media content data available for this video. Most, but not all, videos offer this.

noembed[R]
Boolean

Specifies that a video may or may not be embedded on other websites.

perm_private[R]
Boolean

Whether or not a video is private. Non-standard name to avoid collision with Rubys own 'private' stuff.

player_url[R]
String

The link to watch the URL on YouTubes website.

position[R]
Fixnum

Specifies the order in which the video appears in a playlist.

published_at[R]
Time

When the video was published on Youtube.

rating[R]
Tubeclip::Model::Rating

Information about the videos rating.

raw_content[R]
String

Description of the video.

recorded_at[R]
Time

When the video's was recorded.

state[R]
String

State of the video (processing, restricted, deleted, rejected and failed)

thumbnails[R]
Array

An array of Tubeclip::Model::Thumbnail objects that contain information regarding the videos thumbnail images.

title[R]
String

Title for the video.

updated_at[R]
Time

When the video's data was last updated.

uploaded_at[R]
Time

When the video's was uploaded.

video_id[R]

String: Specifies a URI that uniquely and permanently identifies the video.

video_position[R]

Playlist position

view_count[R]
Fixnum

Number of times that the video has been viewed

widescreen[R]
Boolean

Specifies that a video may or may not be 16:9 ratio.

Public Instance Methods

default_media_content() click to toggle source

Provides a URL and various other types of information about a video.

Returns

Tubeclip::Model::Content: Data about the embeddable video.
# File lib/tubeclip/model/video.rb, line 233
def default_media_content
  @media_content.find { |c| c.is_default? }
end
embed_html(width = 425, height = 350) click to toggle source

Gives you the HTML to embed the video on your website.

Returns

String: The HTML for embedding the video on your website.
# File lib/tubeclip/model/video.rb, line 241
      def embed_html(width = 425, height = 350)
        <<EDOC
<object width="#{width}" height="#{height}">
  <param name="movie" value="#{embed_url}"></param>
  <param name="wmode" value="transparent"></param>
  <embed src="#{embed_url}" type="application/x-shockwave-flash"
   wmode="transparent" width="#{width}" height="#{height}"></embed>
</object>
EDOC
      end
embed_html5(params = {}) click to toggle source

Gives you the HTML 5 to embed the video on your website. Usefull for mobile that not support flash but has html5 browser

Returns

String: The HTML for embedding the video on your website.
# File lib/tubeclip/model/video.rb, line 256
      def embed_html5(params = {})
        opts = {:class  => params[:class]  || "",
                :id     => params[:id]     || "",
                :width  => params[:width]  || "425",
                :height => params[:height] || "350",
                :protocol => params[:protocol] || "http",
                :frameborder => params[:frameborder] || "0",
                :url_params => params[:url_params] || {},
                :sandbox => params[:sandbox] || false,
                :fullscreen => params[:fullscreen] || false,
                }
        url_opts = opts[:url_params].empty? ? "" : "?#{Rack::Utils::build_query(opts[:url_params])}"
        <<EDOC
<iframe class="#{opts[:class]}" id="#{opts[:id]}" type="text/html" width="#{opts[:width]}" height="#{opts[:height]}" src="#{opts[:protocol]}://www.youtube.com/embed/#{unique_id}#{url_opts}" frameborder="#{opts[:frameborder]}" #{" sandbox=\"#{opts[:sandbox]}\" " if opts[:sandbox]} #{"allowfullscreen" if opts[:fullscreen]}></iframe>
EDOC
      end
embed_html_with_width(width = 1280) click to toggle source

Gives you the HTML to embed the video on your website.

Returns

String: The HTML for embedding the video on your website.

# File lib/tubeclip/model/video.rb, line 277
      def embed_html_with_width(width = 1280)
        height = (widescreen? ? width * 9/16 : width * 3/4) + 25

        <<EDOC
<object width="#{width}" height="#{height}">
<param name="movie" value="#{embed_url}"></param>
<param name="wmode" value="transparent"></param>
<embed src="#{embed_url}" type="application/x-shockwave-flash"
wmode="transparent" width="#{width}" height="#{height}"></embed>
</object>
EDOC
      end
embed_url() click to toggle source

The URL needed for embedding the video in a page.

Returns

String: Absolute URL for embedding video
# File lib/tubeclip/model/video.rb, line 294
def embed_url
  @player_url.sub('watch?', '').sub('=', '/').sub('feature/', 'feature=')
end
embeddable?() click to toggle source

Allows you to check whether the video can be embedded on a webpage.

Returns

Boolean: True if the video can be embedded, false if not.
# File lib/tubeclip/model/video.rb, line 209
def embeddable?
  not @noembed
end
in_playlist_id() click to toggle source

ID of video in playlist listing Useful if you have to delete this video from a playlist

Example

>> video.in_playlist_id 
=> "PLk3UVPlPEkey09s2W02R48WMDKjvSb6Hq"

Returns

String the video id
# File lib/tubeclip/model/video.rb, line 178
def in_playlist_id
  @video_id.split(':').last
end
listed?() click to toggle source

Allows you to check whether the video is listed and searchable on youtube.

Returns

Boolean
# File lib/tubeclip/model/video.rb, line 217
def listed?
  access_control['list'] == 'allowed'
end
responses() click to toggle source

Video responses to the current video.

Returns

Tubeclip::Response::VideoSearch
# File lib/tubeclip/model/video.rb, line 163
def responses
  Tubeclip::Parser::VideosFeedParser.new("http://gdata.youtube.com/feeds/api/videos/#{unique_id}/responses?v=#{Tubeclip::API_VERSION}").parse
end
unique_id() click to toggle source

The ID of the video, useful for searching for the video again without having to store it anywhere. A regular query search, with this id will return the same video.

Example

>> video.unique_id
=> "ZTUVgYoeN_o"

Returns

String: The Youtube video id.
# File lib/tubeclip/model/video.rb, line 191
def unique_id
  @unique_id || video_id[/videos\/([^<]+)/, 1] || video_id[/video\:([^<]+)/, 1]
end
watch_later_id() click to toggle source

ID of this video in the watch later list (work only if you are listing watch later videos) Can be use to modify or remove the entry from the watch later list

Example

>> @client.watchlater.videos.first.watch_later_id
=> "PL78jdHcOatSF7DGMd4O9K6Mbo0cNlxm_j"
# File lib/tubeclip/model/video.rb, line 201
def watch_later_id
  video_id[/watch_later\:([^:]+)/, 1]
end
widescreen?() click to toggle source

Allows you to check whether the video is widescreen (16:9) or not.

Returns

Boolean: True if the video is (approximately) 16:9, false if not.

# File lib/tubeclip/model/video.rb, line 225
def widescreen?
  @widescreen
end