Class: YouTubeG::Model::Video
- Defined in:
- lib/youtube_g/model/video.rb
Defined Under Namespace
Classes: AppControl, Format
Instance Attribute Summary collapse
-
#app_control ⇒ Object
readonly
YouTubeG::Model::Video::AppControl The state of this video if post upload.
-
#author ⇒ Object
readonly
- YouTubeG::Model::Author
-
Information about the YouTube user who owns a piece of video content.
-
#categories ⇒ Object
readonly
- Array
-
A array of YouTubeG::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.
-
#html_content ⇒ Object
readonly
- String
-
Description of the video.
-
#keywords ⇒ Object
readonly
- Array
-
An array of words associated with the video.
-
#media_content ⇒ Object
readonly
- Array
-
An array of YouTubeG::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
- YouTubeG::Model::Rating
-
Information about the videos rating.
-
#statistics ⇒ Object
readonly
Returns the value of attribute statistics.
-
#status_url ⇒ Object
readonly
- String
-
The URL to check the processing status of the video at YT.
-
#thumbnails ⇒ Object
readonly
- Array
-
An array of YouTubeG::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.
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_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.
-
#processed? ⇒ Boolean
Has this vid been processed by YT?.
-
#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.
Methods inherited from Record
Constructor Details
This class inherits a constructor from YouTubeG::Record
Instance Attribute Details
#app_control ⇒ Object (readonly)
YouTubeG::Model::Video::AppControl The state of this video if post upload
84 85 86 |
# File 'lib/youtube_g/model/video.rb', line 84 def app_control @app_control end |
#author ⇒ Object (readonly)
- YouTubeG::Model::Author
-
Information about the YouTube user who owns a piece of video content.
111 112 113 |
# File 'lib/youtube_g/model/video.rb', line 111 def @author end |
#categories ⇒ Object (readonly)
- Array
-
A array of YouTubeG::Model::Category objects that describe the videos categories.
96 97 98 |
# File 'lib/youtube_g/model/video.rb', line 96 def categories @categories end |
#description ⇒ Object (readonly)
- String
-
Description of the video.
102 103 104 |
# File 'lib/youtube_g/model/video.rb', line 102 def description @description end |
#duration ⇒ Object (readonly)
- Fixnum
-
Duration of a video in seconds.
72 73 74 |
# File 'lib/youtube_g/model/video.rb', line 72 def duration @duration end |
#html_content ⇒ Object (readonly)
- String
-
Description of the video.
108 109 110 |
# File 'lib/youtube_g/model/video.rb', line 108 def html_content @html_content end |
#keywords ⇒ Object (readonly)
- Array
-
An array of words associated with the video.
99 100 101 |
# File 'lib/youtube_g/model/video.rb', line 99 def keywords @keywords end |
#media_content ⇒ Object (readonly)
- Array
-
An array of YouTubeG::Model::Content objects describing the individual media content data available for this video. Most, but not all, videos offer this.
114 115 116 |
# File 'lib/youtube_g/model/video.rb', line 114 def media_content @media_content end |
#noembed ⇒ Object (readonly)
- Boolean
-
Specifies that a video may or may not be embedded on other websites.
75 76 77 |
# File 'lib/youtube_g/model/video.rb', line 75 def @noembed end |
#player_url ⇒ Object (readonly)
- String
-
The link to watch the URL on YouTubes website.
120 121 122 |
# File 'lib/youtube_g/model/video.rb', line 120 def player_url @player_url end |
#position ⇒ Object (readonly)
- Fixnum
-
Specifies the order in which the video appears in a playlist.
78 79 80 |
# File 'lib/youtube_g/model/video.rb', line 78 def position @position end |
#published_at ⇒ Object (readonly)
- Time
-
When the video was published on Youtube.
90 91 92 |
# File 'lib/youtube_g/model/video.rb', line 90 def published_at @published_at end |
#racy ⇒ Object (readonly)
- Boolean
-
Specifies that a video is flagged as adult or not.
81 82 83 |
# File 'lib/youtube_g/model/video.rb', line 81 def racy @racy end |
#rating ⇒ Object (readonly)
- YouTubeG::Model::Rating
-
Information about the videos rating.
126 127 128 |
# File 'lib/youtube_g/model/video.rb', line 126 def @rating end |
#statistics ⇒ Object (readonly)
Returns the value of attribute statistics.
131 132 133 |
# File 'lib/youtube_g/model/video.rb', line 131 def statistics @statistics end |
#status_url ⇒ Object (readonly)
- String
-
The URL to check the processing status of the video at YT.
123 124 125 |
# File 'lib/youtube_g/model/video.rb', line 123 def status_url @status_url end |
#thumbnails ⇒ Object (readonly)
- Array
-
An array of YouTubeG::Model::Thumbnail objects that contain information regarding the videos thumbnail images.
117 118 119 |
# File 'lib/youtube_g/model/video.rb', line 117 def thumbnails @thumbnails end |
#title ⇒ Object (readonly)
- String
-
Title for the video.
105 106 107 |
# File 'lib/youtube_g/model/video.rb', line 105 def title @title end |
#updated_at ⇒ Object (readonly)
- Time
-
When the video’s data was last updated.
93 94 95 |
# File 'lib/youtube_g/model/video.rb', line 93 def updated_at @updated_at end |
#video_id ⇒ Object (readonly)
String: Specifies a URI that uniquely and permanently identifies the video.
87 88 89 |
# File 'lib/youtube_g/model/video.rb', line 87 def video_id @video_id end |
#view_count ⇒ Object (readonly)
- Fixnum
-
Number of times that the video has been viewed
129 130 131 |
# File 'lib/youtube_g/model/video.rb', line 129 def view_count @view_count end |
Instance Method Details
#default_media_content ⇒ Object
Provides a URL and various other types of information about a video.
Returns
YouTubeG::Model::Content: Data about the embeddable video.
174 175 176 |
# File 'lib/youtube_g/model/video.rb', line 174 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.
182 183 184 185 186 187 188 189 190 191 |
# File 'lib/youtube_g/model/video.rb', line 182 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_url ⇒ Object
The URL needed for embedding the video in a page.
Returns
String: Absolute URL for embedding video
197 198 199 |
# File 'lib/youtube_g/model/video.rb', line 197 def @player_url.sub('watch?', '').sub('=', '/') 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.
166 167 168 |
# File 'lib/youtube_g/model/video.rb', line 166 def not @noembed end |
#processed? ⇒ Boolean
Has this vid been processed by YT?
Returns
Boolean
205 206 207 208 |
# File 'lib/youtube_g/model/video.rb', line 205 def processed? return true if self.app_control == nil return false if self.app_control.state.upcase == 'PROCESSING' || self.app_control.state.upcase == 'REJECTED' || self.app_control.state.upcase == 'FAILED' end |
#related ⇒ Object
137 138 139 |
# File 'lib/youtube_g/model/video.rb', line 137 def YouTubeG::Parser::VideosFeedParser.new("http://gdata.youtube.com/feeds/api/videos/#{unique_id}/related").parse end |
#responses ⇒ Object
145 146 147 |
# File 'lib/youtube_g/model/video.rb', line 145 def responses YouTubeG::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.
158 159 160 |
# File 'lib/youtube_g/model/video.rb', line 158 def unique_id video_id[/videos\/([^<]+)/, 1] end |