Class: YouTubeG::Model::Video
- Defined in:
- lib/youtube_g/model/video.rb
Defined Under Namespace
Classes: Format
Instance Attribute Summary collapse
-
#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.
-
#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 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.
-
#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.
-
#where ⇒ Object
readonly
Geodata.
Instance Method Summary collapse
-
#comments_search(options = {}) ⇒ Object
Comments on the current video.
-
#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.
-
#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
#author ⇒ Object (readonly)
- YouTubeG::Model::Author
-
Information about the YouTube user who owns a piece of video content.
95 96 97 |
# File 'lib/youtube_g/model/video.rb', line 95 def @author end |
#categories ⇒ Object (readonly)
- Array
-
A array of YouTubeG::Model::Category objects that describe the videos categories.
80 81 82 |
# File 'lib/youtube_g/model/video.rb', line 80 def categories @categories end |
#description ⇒ Object (readonly)
- String
-
Description of the video.
86 87 88 |
# File 'lib/youtube_g/model/video.rb', line 86 def description @description end |
#duration ⇒ Object (readonly)
- Fixnum
-
Duration of a video in seconds.
59 60 61 |
# File 'lib/youtube_g/model/video.rb', line 59 def duration @duration end |
#favorite_count ⇒ Object (readonly)
- Fixnum
-
Number of times that the video has been favorited
113 114 115 |
# File 'lib/youtube_g/model/video.rb', line 113 def favorite_count @favorite_count end |
#html_content ⇒ Object (readonly)
- String
-
Description of the video.
92 93 94 |
# File 'lib/youtube_g/model/video.rb', line 92 def html_content @html_content end |
#keywords ⇒ Object (readonly)
- Array
-
An array of words associated with the video.
83 84 85 |
# File 'lib/youtube_g/model/video.rb', line 83 def keywords @keywords end |
#latitude ⇒ Object (readonly)
Returns the value of attribute latitude.
119 120 121 |
# File 'lib/youtube_g/model/video.rb', line 119 def latitude @latitude end |
#longitude ⇒ Object (readonly)
Returns the value of attribute longitude.
120 121 122 |
# File 'lib/youtube_g/model/video.rb', line 120 def longitude @longitude 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.
98 99 100 |
# File 'lib/youtube_g/model/video.rb', line 98 def media_content @media_content end |
#noembed ⇒ Object (readonly)
- Boolean
-
Specifies that a video may or may not be embedded on other websites.
62 63 64 |
# File 'lib/youtube_g/model/video.rb', line 62 def @noembed end |
#player_url ⇒ Object (readonly)
- String
-
The link to watch the URL on YouTubes website.
104 105 106 |
# File 'lib/youtube_g/model/video.rb', line 104 def player_url @player_url end |
#position ⇒ Object (readonly)
- Fixnum
-
Specifies the order in which the video appears in a playlist.
65 66 67 |
# File 'lib/youtube_g/model/video.rb', line 65 def position @position end |
#published_at ⇒ Object (readonly)
- Time
-
When the video was published on Youtube.
74 75 76 |
# File 'lib/youtube_g/model/video.rb', line 74 def published_at @published_at end |
#racy ⇒ Object (readonly)
- Boolean
-
Specifies that a video is flagged as adult or not.
68 69 70 |
# File 'lib/youtube_g/model/video.rb', line 68 def racy @racy end |
#rating ⇒ Object (readonly)
- YouTubeG::Model::Rating
-
Information about the videos rating.
107 108 109 |
# File 'lib/youtube_g/model/video.rb', line 107 def @rating end |
#statistics ⇒ Object (readonly)
Returns the value of attribute statistics.
122 123 124 |
# File 'lib/youtube_g/model/video.rb', line 122 def statistics @statistics end |
#thumbnails ⇒ Object (readonly)
- Array
-
An array of YouTubeG::Model::Thumbnail objects that contain information regarding the videos thumbnail images.
101 102 103 |
# File 'lib/youtube_g/model/video.rb', line 101 def thumbnails @thumbnails end |
#title ⇒ Object (readonly)
- String
-
Title for the video.
89 90 91 |
# File 'lib/youtube_g/model/video.rb', line 89 def title @title end |
#updated_at ⇒ Object (readonly)
- Time
-
When the video’s data was last updated.
77 78 79 |
# File 'lib/youtube_g/model/video.rb', line 77 def updated_at @updated_at end |
#video_id ⇒ Object (readonly)
String: Specifies a URI that uniquely and permanently identifies the video.
71 72 73 |
# File 'lib/youtube_g/model/video.rb', line 71 def video_id @video_id end |
#view_count ⇒ Object (readonly)
- Fixnum
-
Number of times that the video has been viewed
110 111 112 |
# File 'lib/youtube_g/model/video.rb', line 110 def view_count @view_count end |
#where ⇒ Object (readonly)
Geodata
117 118 119 |
# File 'lib/youtube_g/model/video.rb', line 117 def where @where end |
Instance Method Details
#comments_search(options = {}) ⇒ Object
144 145 146 147 |
# File 'lib/youtube_g/model/video.rb', line 144 def comments_search(={}) url = YouTubeG::Request::CommentsSearch.new(unique_id,).url YouTubeG::Parser::CommentsFeedParser.new(url).parse end |
#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.
175 176 177 |
# File 'lib/youtube_g/model/video.rb', line 175 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.
183 184 185 186 187 188 189 190 191 192 |
# File 'lib/youtube_g/model/video.rb', line 183 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
198 199 200 |
# File 'lib/youtube_g/model/video.rb', line 198 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.
167 168 169 |
# File 'lib/youtube_g/model/video.rb', line 167 def not @noembed end |
#related ⇒ Object
128 129 130 |
# File 'lib/youtube_g/model/video.rb', line 128 def YouTubeG::Parser::VideosFeedParser.new("http://gdata.youtube.com/feeds/api/videos/#{unique_id}/related").parse end |
#responses ⇒ Object
136 137 138 |
# File 'lib/youtube_g/model/video.rb', line 136 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.
159 160 161 |
# File 'lib/youtube_g/model/video.rb', line 159 def unique_id video_id[/videos\/([^<]+)/, 1] end |