Class: YouTubeIt::Model::Video
- Inherits:
-
Record
- Object
- Record
- YouTubeIt::Model::Video
- Defined in:
- lib/youtube_it/model/video.rb
Defined Under Namespace
Classes: Format
Instance Attribute Summary (collapse)
-
- (Object) author
readonly
YouTubeIt::Model::Author
Information about the YouTube user who owns a piece of video content.
-
- (Object) categories
readonly
Array
A array of YouTubeIt::Model::Category objects that describe the videos categories.
-
- (Object) description
readonly
String
Description of the video.
-
- (Object) duration
readonly
Fixnum
Duration of a video in seconds.
-
- (Object) favorite_count
readonly
Fixnum
Number of times that the video has been favorited.
-
- (Object) html_content
readonly
String
Description of the video.
-
- (Object) keywords
readonly
Array
An array of words associated with the video.
-
- (Object) latitude
readonly
Returns the value of attribute latitude.
-
- (Object) longitude
readonly
Returns the value of attribute longitude.
-
- (Object) media_content
readonly
Array
An array of YouTubeIt::Model::Content objects describing the individual media content data available for this video.
-
- (Object) noembed
readonly
Boolean
Specifies that a video may or may not be embedded on other websites.
-
- (Object) player_url
readonly
String
The link to watch the URL on YouTubes website.
-
- (Object) position
readonly
Returns the value of attribute position.
-
- (Object) published_at
readonly
Time
When the video was published on Youtube.
-
- (Object) racy
readonly
Boolean
Specifies that a video is flagged as adult or not.
-
- (Object) rating
readonly
YouTubeIt::Model::Rating
Information about the videos rating.
-
- (Object) state
readonly
String
State of the video (processing, restricted, deleted, rejected and failed).
-
- (Object) thumbnails
readonly
Array
An array of YouTubeIt::Model::Thumbnail objects that contain information regarding the videos thumbnail images.
-
- (Object) title
readonly
String
Title for the video.
-
- (Object) updated_at
readonly
Time
When the video's data was last updated.
-
- (Object) video_id
readonly
String: Specifies a URI that uniquely and permanently identifies the video.
-
- (Object) view_count
readonly
Fixnum
Number of times that the video has been viewed.
-
- (Object) where
readonly
Geodata.
-
- (Object) widescreen
readonly
Boolean
Specifies that a video may or may not be 16:9 ratio.
Instance Method Summary (collapse)
-
- (Object) default_media_content
Provides a URL and various other types of information about a video.
-
- (Object) embed_html(width = 425, height = 350)
Gives you the HTML to embed the video on your website.
-
- (Object) embed_html5(params = {})
Gives you the HTML 5 to embed the video on your website.
-
- (Object) embed_html_with_width(width = 1280)
Gives you the HTML to embed the video on your website.
-
- (Object) embed_url
The URL needed for embedding the video in a page.
-
- (Boolean) embeddable?
Allows you to check whether the video can be embedded on a webpage.
-
- (Object) related
Videos related to the current video.
-
- (Object) responses
Video responses to the current video.
-
- (Object) unique_id
The ID of the video, useful for searching for the video again without having to store it anywhere.
-
- (Boolean) widescreen?
Allows you to check whether the video is widescreen (16:9) or not.
Methods inherited from Record
Constructor Details
This class inherits a constructor from YouTubeIt::Record
Instance Attribute Details
- (Object) author (readonly)
YouTubeIt::Model::Author |
Information about the YouTube user who owns a piece of video content. |
98 99 100 |
# File 'lib/youtube_it/model/video.rb', line 98 def @author end |
- (Object) categories (readonly)
Array |
A array of YouTubeIt::Model::Category objects that describe the videos categories. |
83 84 85 |
# File 'lib/youtube_it/model/video.rb', line 83 def categories @categories end |
- (Object) description (readonly)
String |
Description of the video. |
89 90 91 |
# File 'lib/youtube_it/model/video.rb', line 89 def description @description end |
- (Object) duration (readonly)
Fixnum |
Duration of a video in seconds. |
59 60 61 |
# File 'lib/youtube_it/model/video.rb', line 59 def duration @duration end |
- (Object) favorite_count (readonly)
Fixnum |
Number of times that the video has been favorited |
116 117 118 |
# File 'lib/youtube_it/model/video.rb', line 116 def favorite_count @favorite_count end |
- (Object) html_content (readonly)
String |
Description of the video. |
95 96 97 |
# File 'lib/youtube_it/model/video.rb', line 95 def html_content @html_content end |
- (Object) keywords (readonly)
Array |
An array of words associated with the video. |
86 87 88 |
# File 'lib/youtube_it/model/video.rb', line 86 def keywords @keywords end |
- (Object) latitude (readonly)
Returns the value of attribute latitude
125 126 127 |
# File 'lib/youtube_it/model/video.rb', line 125 def latitude @latitude end |
- (Object) longitude (readonly)
Returns the value of attribute longitude
126 127 128 |
# File 'lib/youtube_it/model/video.rb', line 126 def longitude @longitude end |
- (Object) media_content (readonly)
Array |
An array of YouTubeIt::Model::Content objects describing the individual media content data available for this video. Most, but not all, videos offer this. |
101 102 103 |
# File 'lib/youtube_it/model/video.rb', line 101 def media_content @media_content end |
- (Object) noembed (readonly)
Boolean |
Specifies that a video may or may not be embedded on other websites. |
65 66 67 |
# File 'lib/youtube_it/model/video.rb', line 65 def @noembed end |
- (Object) player_url (readonly)
String |
The link to watch the URL on YouTubes website. |
107 108 109 |
# File 'lib/youtube_it/model/video.rb', line 107 def player_url @player_url end |
- (Object) position (readonly)
Returns the value of attribute position
68 69 70 |
# File 'lib/youtube_it/model/video.rb', line 68 def position @position end |
- (Object) published_at (readonly)
Time |
When the video was published on Youtube. |
77 78 79 |
# File 'lib/youtube_it/model/video.rb', line 77 def published_at @published_at end |
- (Object) racy (readonly)
Boolean |
Specifies that a video is flagged as adult or not. |
71 72 73 |
# File 'lib/youtube_it/model/video.rb', line 71 def racy @racy end |
- (Object) rating (readonly)
YouTubeIt::Model::Rating |
Information about the videos rating. |
110 111 112 |
# File 'lib/youtube_it/model/video.rb', line 110 def @rating end |
- (Object) state (readonly)
String |
State of the video (processing, restricted, deleted, rejected and failed) |
119 120 121 |
# File 'lib/youtube_it/model/video.rb', line 119 def state @state end |
- (Object) thumbnails (readonly)
Array |
An array of YouTubeIt::Model::Thumbnail objects that contain information regarding the videos thumbnail images. |
104 105 106 |
# File 'lib/youtube_it/model/video.rb', line 104 def thumbnails @thumbnails end |
- (Object) title (readonly)
String |
Title for the video. |
92 93 94 |
# File 'lib/youtube_it/model/video.rb', line 92 def title @title end |
- (Object) updated_at (readonly)
Time |
When the video's data was last updated. |
80 81 82 |
# File 'lib/youtube_it/model/video.rb', line 80 def updated_at @updated_at end |
- (Object) video_id (readonly)
String: Specifies a URI that uniquely and permanently identifies the video.
74 75 76 |
# File 'lib/youtube_it/model/video.rb', line 74 def video_id @video_id end |
- (Object) view_count (readonly)
Fixnum |
Number of times that the video has been viewed |
113 114 115 |
# File 'lib/youtube_it/model/video.rb', line 113 def view_count @view_count end |
- (Object) where (readonly)
Geodata
123 124 125 |
# File 'lib/youtube_it/model/video.rb', line 123 def where @where end |
- (Object) widescreen (readonly)
Boolean |
Specifies that a video may or may not be 16:9 ratio. |
62 63 64 |
# File 'lib/youtube_it/model/video.rb', line 62 def widescreen @widescreen end |
Instance Method Details
- (Object) default_media_content
Provides a URL and various other types of information about a video.
Returns
YouTubeIt::Model::Content: Data about the embeddable video.
177 178 179 |
# File 'lib/youtube_it/model/video.rb', line 177 def default_media_content @media_content.find { |c| c.is_default? } end |
- (Object) embed_html(width = 425, height = 350)
Gives you the HTML to embed the video on your website.
Returns
String: The HTML for embedding the video on your website.
185 186 187 188 189 190 191 192 193 194 |
# File 'lib/youtube_it/model/video.rb', line 185 def (width = 425, height = 350) <<EDOC <object width="#{width}" height="#{height}"> <param name="movie" value="#{}"></param> <param name="wmode" value="transparent"></param> <embed src="#{}" type="application/x-shockwave-flash" wmode="transparent" width="#{width}" height="#{height}"></embed> </object> EDOC end |
- (Object) embed_html5(params = {})
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.
200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/youtube_it/model/video.rb', line 200 def (params = {}) opts = {:class => params[:class] || "", :id => params[:id] || "", :width => params[:width] || "425", :height => params[:height] || "350", :frameborder => params[:frameborder] || "0" } <<EDOC <iframe class="#{opts[:class]}" id="#{opts[:id]}" type="text/html" width="#{opts[:width]}" height="#{opts[:height]}" src="http://www.youtube.com/embed/#{unique_id}" frameborder="#{opts[:frameborder]}"> EDOC end |
- (Object) embed_html_with_width(width = 1280)
Gives you the HTML to embed the video on your website.
Returns
String: The HTML for embedding the video on your website.
216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/youtube_it/model/video.rb', line 216 def (width = 1280) height = (widescreen? ? width * 9/16 : width * 3/4) + 25 <<EDOC <object width="#{width}" height="#{height}"> <param name="movie" value="#{}"></param> <param name="wmode" value="transparent"></param> <embed src="#{}" type="application/x-shockwave-flash" wmode="transparent" width="#{width}" height="#{height}"></embed> </object> EDOC end |
- (Object) embed_url
The URL needed for embedding the video in a page.
Returns
String: Absolute URL for embedding video
233 234 235 |
# File 'lib/youtube_it/model/video.rb', line 233 def @player_url.sub('watch?', '').sub('=', '/').sub('feature/', 'feature=') end |
- (Boolean) embeddable?
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.
161 162 163 |
# File 'lib/youtube_it/model/video.rb', line 161 def not @noembed end |
- (Object) related
Videos related to the current video.
Returns
YouTubeIt::Response::VideoSearch
132 133 134 |
# File 'lib/youtube_it/model/video.rb', line 132 def YouTubeIt::Parser::VideosFeedParser.new("http://gdata.youtube.com/feeds/api/videos/#{unique_id}/related").parse end |
- (Object) responses
Video responses to the current video.
Returns
YouTubeIt::Response::VideoSearch
140 141 142 |
# File 'lib/youtube_it/model/video.rb', line 140 def responses YouTubeIt::Parser::VideosFeedParser.new("http://gdata.youtube.com/feeds/api/videos/#{unique_id}/responses").parse end |
- (Object) unique_id
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.
153 154 155 |
# File 'lib/youtube_it/model/video.rb', line 153 def unique_id video_id[/videos\/([^<]+)/, 1] || video_id[/video\:([^<]+)/, 1] end |
- (Boolean) widescreen?
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.
169 170 171 |
# File 'lib/youtube_it/model/video.rb', line 169 def widescreen? @widescreen end |