Class: VgYoutube
Instance Method Summary collapse
- #download_url ⇒ Object
- #duration ⇒ Object
-
#embed_html(width = 425, height = 344, options = {}) ⇒ Object
options You can read more about the youtube player options in code.google.com/intl/en/apis/youtube/player_parameters.html Use them in options (ex => 0, :color1 => ‘0x333333’).
- #embed_url ⇒ Object
- #flv ⇒ Object
-
#initialize(url = nil, options = {}) ⇒ VgYoutube
constructor
A new instance of VgYoutube.
- #service ⇒ Object
- #thumbnail ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(url = nil, options = {}) ⇒ VgYoutube
Returns a new instance of VgYoutube.
9 10 11 12 13 14 15 16 |
# File 'lib/acts_as_unvlogable/vg_youtube.rb', line 9 def initialize(url=nil, ={}) object = YouTubeIt::Client.new({}) @url = url @video_id = @url.query_param('v') @details = object.video_by(@video_id) @details.instance_variable_set(:@noembed, false) raise if @details.blank? end |
Instance Method Details
#download_url ⇒ Object
49 50 51 |
# File 'lib/acts_as_unvlogable/vg_youtube.rb', line 49 def download_url flv end |
#duration ⇒ Object
26 27 28 |
# File 'lib/acts_as_unvlogable/vg_youtube.rb', line 26 def duration @details.duration end |
#embed_html(width = 425, height = 344, options = {}) ⇒ Object
options
You can read more about the youtube player options in
http://code.google.com/intl/en/apis/youtube/player_parameters.html
Use them in options (ex {:rel => 0, :color1 => '0x333333'})
39 40 41 |
# File 'lib/acts_as_unvlogable/vg_youtube.rb', line 39 def (width=425, height=344, ={}) "<object width='#{width}' height='#{height}'><param name='movie' value='#{}#{.map {|k,v| "&#{k}=#{v}"}}'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='#{}#{.map {|k,v| "&#{k}=#{v}"}}' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='#{width}' height='#{height}'></embed></object>" if @details. == false end |
#embed_url ⇒ Object
30 31 32 |
# File 'lib/acts_as_unvlogable/vg_youtube.rb', line 30 def @details.media_content.first.url if @details. == false end |
#flv ⇒ Object
44 45 46 47 |
# File 'lib/acts_as_unvlogable/vg_youtube.rb', line 44 def flv doc = URI::parse("http://www.youtube.com/get_video_info?&video_id=#{@video_id}").read CGI::unescape(doc.split("&fmt_url_map=")[1].split("&")[0]).split("|")[1].split(",")[0] end |
#service ⇒ Object
53 54 55 |
# File 'lib/acts_as_unvlogable/vg_youtube.rb', line 53 def service "Youtube" end |
#thumbnail ⇒ Object
22 23 24 |
# File 'lib/acts_as_unvlogable/vg_youtube.rb', line 22 def thumbnail @details.thumbnails.first.url end |
#title ⇒ Object
18 19 20 |
# File 'lib/acts_as_unvlogable/vg_youtube.rb', line 18 def title @details.title end |