# File lib/youtube.rb, line 291 def initialize(payload) @author = payload['author'].to_s @comment_count = payload['comment_count'].to_i @description = payload['description'].to_s @id = payload['id'] @length_seconds = payload['length_seconds'].to_i @rating_avg = payload['rating_avg'].to_f @rating_count = payload['rating_count'].to_i @tags = payload['tags'] @thumbnail_url = payload['thumbnail_url'] @title = payload['title'].to_s @upload_time = YouTube._string_to_time(payload['upload_time']) @url = payload['url'] @view_count = payload['view_count'].to_i # the url provided via the API links to the video page -- for # convenience, generate the url used to embed in a page @embed_url = @url.delete('?').sub('=', '/') end
Returns HTML analogous to that provided by the YouTube web site to allow for easy embedding of
this video in a web page. Optional width and
height parameters allow specifying the dimensions of the video
for display.
# File lib/youtube.rb, line 315 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