Class: YouTubeG::Model::Video

Inherits:
Record
  • Object
show all
Defined in:
lib/youtube_g/model/video.rb

Defined Under Namespace

Classes: Format

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Record

#initialize

Constructor Details

This class inherits a constructor from YouTubeG::Record

Instance Attribute Details

#authorObject (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
  @author
end

#categoriesObject (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

#descriptionObject (readonly)

String

Description of the video.



86
87
88
# File 'lib/youtube_g/model/video.rb', line 86

def description
  @description
end

#durationObject (readonly)

Fixnum

Duration of a video in seconds.



59
60
61
# File 'lib/youtube_g/model/video.rb', line 59

def duration
  @duration
end

#html_contentObject (readonly)

String

Description of the video.



92
93
94
# File 'lib/youtube_g/model/video.rb', line 92

def html_content
  @html_content
end

#keywordsObject (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

#latitudeObject (readonly)

Returns the value of attribute latitude.



115
116
117
# File 'lib/youtube_g/model/video.rb', line 115

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



116
117
118
# File 'lib/youtube_g/model/video.rb', line 116

def longitude
  @longitude
end

#media_contentObject (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

#noembedObject (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
  @noembed
end

#player_urlObject (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

#positionObject (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_atObject (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

#racyObject (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

#ratingObject (readonly)

YouTubeG::Model::Rating

Information about the videos rating.



107
108
109
# File 'lib/youtube_g/model/video.rb', line 107

def rating
  @rating
end

#statisticsObject (readonly)

Returns the value of attribute statistics.



118
119
120
# File 'lib/youtube_g/model/video.rb', line 118

def statistics
  @statistics
end

#thumbnailsObject (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

#titleObject (readonly)

String

Title for the video.



89
90
91
# File 'lib/youtube_g/model/video.rb', line 89

def title
  @title
end

#updated_atObject (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_idObject (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_countObject (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

#whereObject (readonly)

Geodata



113
114
115
# File 'lib/youtube_g/model/video.rb', line 113

def where
  @where
end

Instance Method Details

#default_media_contentObject

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

Returns

YouTubeG::Model::Content: Data about the embeddable video.


161
162
163
# File 'lib/youtube_g/model/video.rb', line 161

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.


169
170
171
172
173
174
175
176
177
178
# File 'lib/youtube_g/model/video.rb', line 169

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_urlObject

The URL needed for embedding the video in a page.

Returns

String: Absolute URL for embedding video


184
185
186
# File 'lib/youtube_g/model/video.rb', line 184

def embed_url
  @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.

Returns:

  • (Boolean)


153
154
155
# File 'lib/youtube_g/model/video.rb', line 153

def embeddable?
  not @noembed
end

Videos related to the current video.

Returns

YouTubeG::Response::VideoSearch


124
125
126
# File 'lib/youtube_g/model/video.rb', line 124

def related
  YouTubeG::Parser::VideosFeedParser.new("http://gdata.youtube.com/feeds/api/videos/#{unique_id}/related").parse
end

#responsesObject

Video responses to the current video.

Returns

YouTubeG::Response::VideoSearch


132
133
134
# File 'lib/youtube_g/model/video.rb', line 132

def responses
  YouTubeG::Parser::VideosFeedParser.new("http://gdata.youtube.com/feeds/api/videos/#{unique_id}/responses").parse
end

#unique_idObject

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.


145
146
147
# File 'lib/youtube_g/model/video.rb', line 145

def unique_id
  video_id[/videos\/([^<]+)/, 1]
end