Class: YouTubeIt::Model::Video
- Defined in:
- lib/youtube_it/model/video.rb
Defined Under Namespace
Classes: Format
Instance Attribute Summary collapse
-
#access_control ⇒ Object
readonly
Returns the value of attribute access_control.
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
-
#comment_count ⇒ Object
readonly
Returns the value of attribute comment_count.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#favorite_count ⇒ Object
readonly
Returns the value of attribute favorite_count.
-
#html_content ⇒ Object
readonly
Returns the value of attribute html_content.
-
#insight_uri ⇒ Object
readonly
Returns the value of attribute insight_uri.
-
#keywords ⇒ Object
readonly
Returns the value of attribute keywords.
-
#latitude ⇒ Object
readonly
Returns the value of attribute latitude.
-
#longitude ⇒ Object
readonly
Returns the value of attribute longitude.
-
#media_content ⇒ Object
readonly
Returns the value of attribute media_content.
-
#noembed ⇒ Object
readonly
Returns the value of attribute noembed.
-
#perm_private ⇒ Object
readonly
Returns the value of attribute perm_private.
-
#player_url ⇒ Object
readonly
Returns the value of attribute player_url.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#published_at ⇒ Object
readonly
Returns the value of attribute published_at.
-
#rating ⇒ Object
readonly
Returns the value of attribute rating.
-
#raw_content ⇒ Object
readonly
Returns the value of attribute raw_content.
-
#recorded_at ⇒ Object
readonly
Returns the value of attribute recorded_at.
-
#safe_search ⇒ Object
readonly
Returns the value of attribute safe_search.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#thumbnails ⇒ Object
readonly
Returns the value of attribute thumbnails.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#uploaded_at ⇒ Object
readonly
Returns the value of attribute uploaded_at.
-
#video_id ⇒ Object
readonly
Returns the value of attribute video_id.
-
#video_position ⇒ Object
readonly
Returns the value of attribute video_position.
-
#view_count ⇒ Object
readonly
Returns the value of attribute view_count.
-
#widescreen ⇒ Object
readonly
Returns the value of attribute widescreen.
Instance Method Summary collapse
- #default_media_content ⇒ Object
- #embed_html(width = 425, height = 350) ⇒ Object
- #embed_html5(params = {}) ⇒ Object
-
#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
- #in_playlist_id ⇒ Object
- #listed? ⇒ Boolean
- #related ⇒ Object
- #responses ⇒ Object
- #unique_id ⇒ Object
- #watch_later_id ⇒ Object
- #widescreen? ⇒ Boolean
Methods inherited from Record
Constructor Details
This class inherits a constructor from YouTubeIt::Record
Instance Attribute Details
#access_control ⇒ Object (readonly)
Returns the value of attribute access_control.
113 114 115 |
# File 'lib/youtube_it/model/video.rb', line 113 def access_control @access_control end |
#author ⇒ Object (readonly)
Returns the value of attribute author.
107 108 109 |
# File 'lib/youtube_it/model/video.rb', line 107 def @author end |
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
89 90 91 |
# File 'lib/youtube_it/model/video.rb', line 89 def categories @categories end |
#comment_count ⇒ Object (readonly)
Returns the value of attribute comment_count.
131 132 133 |
# File 'lib/youtube_it/model/video.rb', line 131 def comment_count @comment_count end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
95 96 97 |
# File 'lib/youtube_it/model/video.rb', line 95 def description @description end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
59 60 61 |
# File 'lib/youtube_it/model/video.rb', line 59 def duration @duration end |
#favorite_count ⇒ Object (readonly)
Returns the value of attribute favorite_count.
128 129 130 |
# File 'lib/youtube_it/model/video.rb', line 128 def favorite_count @favorite_count end |
#html_content ⇒ Object (readonly)
Returns the value of attribute html_content.
101 102 103 |
# File 'lib/youtube_it/model/video.rb', line 101 def html_content @html_content end |
#insight_uri ⇒ Object (readonly)
Returns the value of attribute insight_uri.
137 138 139 |
# File 'lib/youtube_it/model/video.rb', line 137 def insight_uri @insight_uri end |
#keywords ⇒ Object (readonly)
Returns the value of attribute keywords.
92 93 94 |
# File 'lib/youtube_it/model/video.rb', line 92 def keywords @keywords end |
#latitude ⇒ Object (readonly)
Returns the value of attribute latitude.
144 145 146 |
# File 'lib/youtube_it/model/video.rb', line 144 def latitude @latitude end |
#longitude ⇒ Object (readonly)
Returns the value of attribute longitude.
145 146 147 |
# File 'lib/youtube_it/model/video.rb', line 145 def longitude @longitude end |
#media_content ⇒ Object (readonly)
Returns the value of attribute media_content.
110 111 112 |
# File 'lib/youtube_it/model/video.rb', line 110 def media_content @media_content end |
#noembed ⇒ Object (readonly)
Returns the value of attribute noembed.
65 66 67 |
# File 'lib/youtube_it/model/video.rb', line 65 def @noembed end |
#perm_private ⇒ Object (readonly)
Returns the value of attribute perm_private.
140 141 142 |
# File 'lib/youtube_it/model/video.rb', line 140 def perm_private @perm_private end |
#player_url ⇒ Object (readonly)
Returns the value of attribute player_url.
119 120 121 |
# File 'lib/youtube_it/model/video.rb', line 119 def player_url @player_url end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
68 69 70 |
# File 'lib/youtube_it/model/video.rb', line 68 def position @position end |
#published_at ⇒ Object (readonly)
Returns the value of attribute published_at.
77 78 79 |
# File 'lib/youtube_it/model/video.rb', line 77 def published_at @published_at end |
#rating ⇒ Object (readonly)
Returns the value of attribute rating.
122 123 124 |
# File 'lib/youtube_it/model/video.rb', line 122 def @rating end |
#raw_content ⇒ Object (readonly)
Returns the value of attribute raw_content.
104 105 106 |
# File 'lib/youtube_it/model/video.rb', line 104 def raw_content @raw_content end |
#recorded_at ⇒ Object (readonly)
Returns the value of attribute recorded_at.
86 87 88 |
# File 'lib/youtube_it/model/video.rb', line 86 def recorded_at @recorded_at end |
#safe_search ⇒ Object (readonly)
Returns the value of attribute safe_search.
71 72 73 |
# File 'lib/youtube_it/model/video.rb', line 71 def safe_search @safe_search end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
134 135 136 |
# File 'lib/youtube_it/model/video.rb', line 134 def state @state end |
#thumbnails ⇒ Object (readonly)
Returns the value of attribute thumbnails.
116 117 118 |
# File 'lib/youtube_it/model/video.rb', line 116 def thumbnails @thumbnails end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
98 99 100 |
# File 'lib/youtube_it/model/video.rb', line 98 def title @title end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
80 81 82 |
# File 'lib/youtube_it/model/video.rb', line 80 def updated_at @updated_at end |
#uploaded_at ⇒ Object (readonly)
Returns the value of attribute uploaded_at.
83 84 85 |
# File 'lib/youtube_it/model/video.rb', line 83 def uploaded_at @uploaded_at end |
#video_id ⇒ Object (readonly)
Returns the value of attribute video_id.
74 75 76 |
# File 'lib/youtube_it/model/video.rb', line 74 def video_id @video_id end |
#video_position ⇒ Object (readonly)
Returns the value of attribute video_position.
148 149 150 |
# File 'lib/youtube_it/model/video.rb', line 148 def video_position @video_position end |
#view_count ⇒ Object (readonly)
Returns the value of attribute view_count.
125 126 127 |
# File 'lib/youtube_it/model/video.rb', line 125 def view_count @view_count end |
#widescreen ⇒ Object (readonly)
Returns the value of attribute widescreen.
62 63 64 |
# File 'lib/youtube_it/model/video.rb', line 62 def widescreen @widescreen end |
Instance Method Details
#default_media_content ⇒ Object
231 232 233 |
# File 'lib/youtube_it/model/video.rb', line 231 def default_media_content @media_content.find { |c| c.is_default? } end |
#embed_html(width = 425, height = 350) ⇒ Object
239 240 241 242 243 244 245 246 247 248 |
# File 'lib/youtube_it/model/video.rb', line 239 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_html5(params = {}) ⇒ Object
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/youtube_it/model/video.rb', line 254 def (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 |
#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.
275 276 277 278 279 280 281 282 283 284 285 286 |
# File 'lib/youtube_it/model/video.rb', line 275 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
292 293 294 |
# File 'lib/youtube_it/model/video.rb', line 292 def @player_url.sub('watch?', '').sub('=', '/').sub('feature/', 'feature=') end |
#embeddable? ⇒ Boolean
207 208 209 |
# File 'lib/youtube_it/model/video.rb', line 207 def not @noembed end |
#in_playlist_id ⇒ Object
176 177 178 |
# File 'lib/youtube_it/model/video.rb', line 176 def in_playlist_id @video_id.split(':').last end |
#listed? ⇒ Boolean
215 216 217 |
# File 'lib/youtube_it/model/video.rb', line 215 def listed? access_control['list'] == 'allowed' end |
#related ⇒ Object
154 155 156 |
# File 'lib/youtube_it/model/video.rb', line 154 def YouTubeIt::Parser::VideosFeedParser.new("http://gdata.youtube.com/feeds/api/videos/#{unique_id}/related?v=#{YouTubeIt::API_VERSION}").parse end |
#responses ⇒ Object
161 162 163 |
# File 'lib/youtube_it/model/video.rb', line 161 def responses YouTubeIt::Parser::VideosFeedParser.new("http://gdata.youtube.com/feeds/api/videos/#{unique_id}/responses?v=#{YouTubeIt::API_VERSION}").parse end |
#unique_id ⇒ Object
189 190 191 |
# File 'lib/youtube_it/model/video.rb', line 189 def unique_id @unique_id || video_id[/videos\/([^<]+)/, 1] || video_id[/video\:([^<]+)/, 1] end |
#watch_later_id ⇒ Object
199 200 201 |
# File 'lib/youtube_it/model/video.rb', line 199 def watch_later_id video_id[/watch_later\:([^:]+)/, 1] end |
#widescreen? ⇒ Boolean
223 224 225 |
# File 'lib/youtube_it/model/video.rb', line 223 def widescreen? @widescreen end |