Class: YouTubeIt::Model::Video
- Defined in:
- lib/youtube_it/model/video.rb
Defined Under Namespace
Classes: Format
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
- YouTubeIt::Model::Author
-
Information about the YouTube user who owns a piece of video content.
-
#categories ⇒ Object
readonly
- Array
-
A array of YouTubeIt::Model::Category objects that describe the videos categories.
-
#description ⇒ Object
readonly
- String
-
Description of the video.
-
#duration ⇒ Object
readonly
- Fixnum
-
Duration of a video in seconds.
-
#favorite_count ⇒ Object
readonly
- Fixnum
-
Number of times that the video has been favorited.
-
#html_content ⇒ Object
readonly
- String
-
Description of the video.
-
#keywords ⇒ Object
readonly
- Array
-
An array of words associated with the video.
-
#latitude ⇒ Object
readonly
Returns the value of attribute latitude.
-
#longitude ⇒ Object
readonly
Returns the value of attribute longitude.
-
#media_content ⇒ Object
readonly
- Array
-
An array of YouTubeIt::Model::Content objects describing the individual media content data available for this video.
-
#noembed ⇒ Object
readonly
- Boolean
-
Specifies that a video may or may not be embedded on other websites.
-
#player_url ⇒ Object
readonly
- String
-
The link to watch the URL on YouTubes website.
-
#position ⇒ Object
readonly
- Fixnum
-
Specifies the order in which the video appears in a playlist.
-
#published_at ⇒ Object
readonly
- Time
-
When the video was published on Youtube.
-
#racy ⇒ Object
readonly
- Boolean
-
Specifies that a video is flagged as adult or not.
-
#rating ⇒ Object
readonly
- YouTubeIt::Model::Rating
-
Information about the videos rating.
-
#state ⇒ Object
readonly
- String
-
State of the video (processing, restricted, deleted, rejected and failed).
-
#thumbnails ⇒ Object
readonly
- Array
-
An array of YouTubeIt::Model::Thumbnail objects that contain information regarding the videos thumbnail images.
-
#title ⇒ Object
readonly
- String
-
Title for the video.
-
#updated_at ⇒ Object
readonly
- Time
-
When the video’s data was last updated.
-
#video_id ⇒ Object
readonly
String: Specifies a URI that uniquely and permanently identifies the video.
-
#view_count ⇒ Object
readonly
- Fixnum
-
Number of times that the video has been viewed.
-
#where ⇒ Object
readonly
Geodata.
-
#widescreen ⇒ Object
readonly
- Boolean
-
Specifies that a video may or may not be 16:9 ratio.
Instance Method Summary collapse
-
#default_media_content ⇒ Object
Provides a URL and various other types of information about a video.
-
#embed_html(width = 425, height = 350) ⇒ Object
Gives you the HTML to embed the video on your website.
-
#embed_html_with_width(width = 1280) ⇒ Object
Gives you the HTML to embed the video on your website.
-
#embed_url ⇒ Object
The URL needed for embedding the video in a page.
-
#embeddable? ⇒ Boolean
Allows you to check whether the video can be embedded on a webpage.
-
#related ⇒ Object
Videos related to the current video.
-
#responses ⇒ Object
Video responses to the current video.
-
#unique_id ⇒ Object
The ID of the video, useful for searching for the video again without having to store it anywhere.
-
#widescreen? ⇒ Boolean
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
#author ⇒ Object (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 |
#categories ⇒ Object (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 |
#description ⇒ Object (readonly)
- String
-
Description of the video.
89 90 91 |
# File 'lib/youtube_it/model/video.rb', line 89 def description @description end |
#duration ⇒ Object (readonly)
- Fixnum
-
Duration of a video in seconds.
59 60 61 |
# File 'lib/youtube_it/model/video.rb', line 59 def duration @duration end |
#favorite_count ⇒ Object (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 |
#html_content ⇒ Object (readonly)
- String
-
Description of the video.
95 96 97 |
# File 'lib/youtube_it/model/video.rb', line 95 def html_content @html_content end |
#keywords ⇒ Object (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 |
#latitude ⇒ Object (readonly)
Returns the value of attribute latitude.
125 126 127 |
# File 'lib/youtube_it/model/video.rb', line 125 def latitude @latitude end |
#longitude ⇒ Object (readonly)
Returns the value of attribute longitude.
126 127 128 |
# File 'lib/youtube_it/model/video.rb', line 126 def longitude @longitude end |
#media_content ⇒ Object (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 |
#noembed ⇒ Object (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 |
#player_url ⇒ Object (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 |
#position ⇒ Object (readonly)
- Fixnum
-
Specifies the order in which the video appears in a playlist.
68 69 70 |
# File 'lib/youtube_it/model/video.rb', line 68 def position @position end |
#published_at ⇒ Object (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 |
#racy ⇒ Object (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 |
#rating ⇒ Object (readonly)
- YouTubeIt::Model::Rating
-
Information about the videos rating.
110 111 112 |
# File 'lib/youtube_it/model/video.rb', line 110 def @rating end |
#state ⇒ Object (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 |
#thumbnails ⇒ Object (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 |
#title ⇒ Object (readonly)
- String
-
Title for the video.
92 93 94 |
# File 'lib/youtube_it/model/video.rb', line 92 def title @title end |
#updated_at ⇒ Object (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 |
#video_id ⇒ Object (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 |
#view_count ⇒ Object (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 |
#where ⇒ Object (readonly)
Geodata
123 124 125 |
# File 'lib/youtube_it/model/video.rb', line 123 def where @where end |
#widescreen ⇒ Object (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
#default_media_content ⇒ Object
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 |
#embed_html(width = 425, height = 350) ⇒ Object
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 |
#embed_html_with_width(width = 1280) ⇒ Object
Gives you the HTML to embed the video on your website.
Returns
String: The HTML for embedding the video on your website.
200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/youtube_it/model/video.rb', line 200 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 |
#embed_url ⇒ Object
The URL needed for embedding the video in a page.
Returns
String: Absolute URL for embedding video
217 218 219 |
# File 'lib/youtube_it/model/video.rb', line 217 def @player_url.sub('watch?', '').sub('=', '/').sub('feature/', 'feature=') end |
#embeddable? ⇒ Boolean
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 |
#related ⇒ Object
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 |
#responses ⇒ Object
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 |
#unique_id ⇒ Object
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 |
#widescreen? ⇒ Boolean
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 |