Class: YouTubeIt::Model::Video

Inherits:
Record
  • Object
show all
Defined in:
lib/youtube_it/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 YouTubeIt::Record

Instance Attribute Details

- (Object) access_control (readonly)

Returns the value of attribute access_control



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

def access_control
  @access_control
end

- (Object) author (readonly)

Returns the value of attribute author



109
110
111
# File 'lib/youtube_it/model/video.rb', line 109

def author
  @author
end

- (Object) categories (readonly)

Returns the value of attribute categories



91
92
93
# File 'lib/youtube_it/model/video.rb', line 91

def categories
  @categories
end

- (Object) comment_count (readonly)

Returns the value of attribute comment_count



133
134
135
# File 'lib/youtube_it/model/video.rb', line 133

def comment_count
  @comment_count
end

- (Object) description (readonly)

Returns the value of attribute description



97
98
99
# File 'lib/youtube_it/model/video.rb', line 97

def description
  @description
end

- (Object) duration (readonly)

Returns the value of attribute duration



61
62
63
# File 'lib/youtube_it/model/video.rb', line 61

def duration
  @duration
end

- (Object) favorite_count (readonly)

Returns the value of attribute favorite_count



130
131
132
# File 'lib/youtube_it/model/video.rb', line 130

def favorite_count
  @favorite_count
end

- (Object) html_content (readonly)

Returns the value of attribute html_content



103
104
105
# File 'lib/youtube_it/model/video.rb', line 103

def html_content
  @html_content
end

- (Object) insight_uri (readonly)

Returns the value of attribute insight_uri



139
140
141
# File 'lib/youtube_it/model/video.rb', line 139

def insight_uri
  @insight_uri
end

- (Object) keywords (readonly)

Returns the value of attribute keywords



94
95
96
# File 'lib/youtube_it/model/video.rb', line 94

def keywords
  @keywords
end

- (Object) latitude (readonly)

Returns the value of attribute latitude



146
147
148
# File 'lib/youtube_it/model/video.rb', line 146

def latitude
  @latitude
end

- (Object) longitude (readonly)

Returns the value of attribute longitude



147
148
149
# File 'lib/youtube_it/model/video.rb', line 147

def longitude
  @longitude
end

- (Object) media_content (readonly)

Returns the value of attribute media_content



112
113
114
# File 'lib/youtube_it/model/video.rb', line 112

def media_content
  @media_content
end

- (Object) noembed (readonly)

Returns the value of attribute noembed



67
68
69
# File 'lib/youtube_it/model/video.rb', line 67

def noembed
  @noembed
end

- (Object) perm_private (readonly)

Returns the value of attribute perm_private



142
143
144
# File 'lib/youtube_it/model/video.rb', line 142

def perm_private
  @perm_private
end

- (Object) player_url (readonly)

Returns the value of attribute player_url



121
122
123
# File 'lib/youtube_it/model/video.rb', line 121

def player_url
  @player_url
end

- (Object) position (readonly)

Returns the value of attribute position



70
71
72
# File 'lib/youtube_it/model/video.rb', line 70

def position
  @position
end

- (Object) published_at (readonly)

Returns the value of attribute published_at



79
80
81
# File 'lib/youtube_it/model/video.rb', line 79

def published_at
  @published_at
end

- (Object) rating (readonly)

Returns the value of attribute rating



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

def rating
  @rating
end

- (Object) raw_content (readonly)

Returns the value of attribute raw_content



106
107
108
# File 'lib/youtube_it/model/video.rb', line 106

def raw_content
  @raw_content
end

- (Object) recorded_at (readonly)

Returns the value of attribute recorded_at



88
89
90
# File 'lib/youtube_it/model/video.rb', line 88

def recorded_at
  @recorded_at
end

- (Object) safe_search (readonly)

Returns the value of attribute safe_search



73
74
75
# File 'lib/youtube_it/model/video.rb', line 73

def safe_search
  @safe_search
end

- (Object) state (readonly)

Returns the value of attribute state



136
137
138
# File 'lib/youtube_it/model/video.rb', line 136

def state
  @state
end

- (Object) thumbnails (readonly)

Returns the value of attribute thumbnails



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

def thumbnails
  @thumbnails
end

- (Object) title (readonly)

Returns the value of attribute title



100
101
102
# File 'lib/youtube_it/model/video.rb', line 100

def title
  @title
end

- (Object) updated_at (readonly)

Returns the value of attribute updated_at



82
83
84
# File 'lib/youtube_it/model/video.rb', line 82

def updated_at
  @updated_at
end

- (Object) uploaded_at (readonly)

Returns the value of attribute uploaded_at



85
86
87
# File 'lib/youtube_it/model/video.rb', line 85

def uploaded_at
  @uploaded_at
end

- (Object) video_id (readonly)

Returns the value of attribute video_id



76
77
78
# File 'lib/youtube_it/model/video.rb', line 76

def video_id
  @video_id
end

- (Object) video_position (readonly)

Returns the value of attribute video_position



150
151
152
# File 'lib/youtube_it/model/video.rb', line 150

def video_position
  @video_position
end

- (Object) view_count (readonly)

Returns the value of attribute view_count



127
128
129
# File 'lib/youtube_it/model/video.rb', line 127

def view_count
  @view_count
end

- (Object) widescreen (readonly)

Returns the value of attribute widescreen



64
65
66
# File 'lib/youtube_it/model/video.rb', line 64

def widescreen
  @widescreen
end

Instance Method Details

- (Object) default_media_content



233
234
235
# File 'lib/youtube_it/model/video.rb', line 233

def default_media_content
  @media_content.find { |c| c.is_default? }
end

- (Object) embed_html(width = 425, height = 350)



241
242
243
244
245
246
247
248
249
250
# File 'lib/youtube_it/model/video.rb', line 241

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

- (Object) embed_html5(params = {})



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/youtube_it/model/video.rb', line 256

def embed_html5(params = {})
  opts = {:class  => params[:class]  || "",
          :id     => params[:id]     || "",
          :width  => params[:width]  || "425",
          :height => params[:height] || "350",
          :protocol => params[:protocol] || "http",
          :frameborder => params[:frameborder] || "0",
          :url_params => params[:url_params] || {},
          :sandbox => params[:sandbox] || false,
          :fullscreen => params[:fullscreen] || false,
          }
  url_opts = opts[:url_params].empty? ? "" : "?#{Rack::Utils::build_query(opts[:url_params])}"
  <<EDOC
<iframe class="#{opts[:class]}" id="#{opts[:id]}" type="text/html" width="#{opts[:width]}" height="#{opts[:height]}" src="#{opts[:protocol]}://www.youtube.com/embed/#{unique_id}#{url_opts}" frameborder="#{opts[:frameborder]}" #{" sandbox=\"#{opts[:sandbox]}\" " if opts[:sandbox]} #{"allowfullscreen" if opts[:fullscreen]}></iframe>
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.



277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/youtube_it/model/video.rb', line 277

def embed_html_with_width(width = 1280)
  height = (widescreen? ? width * 9/16 : width * 3/4) + 25

  <<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

- (Object) embed_url

The URL needed for embedding the video in a page.

Returns

String: Absolute URL for embedding video


294
295
296
# File 'lib/youtube_it/model/video.rb', line 294

def embed_url
  @player_url.sub('watch?', '').sub('=', '/').sub('feature/', 'feature=')
end

- (Boolean) embeddable?

Returns:

  • (Boolean)


209
210
211
# File 'lib/youtube_it/model/video.rb', line 209

def embeddable?
  not @noembed
end

- (Object) in_playlist_id



178
179
180
# File 'lib/youtube_it/model/video.rb', line 178

def in_playlist_id
  @video_id.split(':').last
end

- (Boolean) listed?

Returns:

  • (Boolean)


217
218
219
# File 'lib/youtube_it/model/video.rb', line 217

def listed?
  access_control['list'] == 'allowed'
end


156
157
158
# File 'lib/youtube_it/model/video.rb', line 156

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

- (Object) responses



163
164
165
# File 'lib/youtube_it/model/video.rb', line 163

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

- (Object) unique_id



191
192
193
# File 'lib/youtube_it/model/video.rb', line 191

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

- (Object) watch_later_id



201
202
203
# File 'lib/youtube_it/model/video.rb', line 201

def watch_later_id
  video_id[/watch_later\:([^:]+)/, 1]
end

- (Boolean) widescreen?

Returns:

  • (Boolean)


225
226
227
# File 'lib/youtube_it/model/video.rb', line 225

def widescreen?
  @widescreen
end