Class: VgVimeo
Instance Method Summary collapse
- #download_url ⇒ Object
- #duration ⇒ Object
- #embed_html(width = 425, height = 344, options = {}, params = {}) ⇒ Object
- #embed_url ⇒ Object
- #flv ⇒ Object
-
#initialize(url = nil, options = {}) ⇒ VgVimeo
constructor
A new instance of VgVimeo.
- #service ⇒ Object
- #thumbnail ⇒ Object
- #title ⇒ Object
- #video_id ⇒ Object
Constructor Details
#initialize(url = nil, options = {}) ⇒ VgVimeo
Returns a new instance of VgVimeo.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 9 def initialize(url=nil, ={}) # general settings @url = url @video_id = parse_url(url) if !(@vimeo_id =~ /^[0-9]+$/) r = Net::HTTP.get_response(URI.parse(url)) if r.code == "301" @url = "http://vimeo.com#{r.header['location']}" @video_id = parse_url(@url) end end res = Net::HTTP.get(URI.parse("http://vimeo.com/api/v2/video/#{@video_id}.xml")) @feed = REXML::Document.new(res) end |
Instance Method Details
#download_url ⇒ Object
58 59 60 61 62 |
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 58 def download_url request_signature = REXML::XPath.first( @feed, "//request_signature" )[0] request_signature_expires = REXML::XPath.first( @feed, "//request_signature_expires" )[0] "http://www.vimeo.com/moogaloop/play/clip:#{@video_id}/#{request_signature}/#{request_signature_expires}/?q=hd" end |
#duration ⇒ Object
39 40 41 |
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 39 def duration REXML::XPath.first( @feed, "//duration" )[0].to_s.to_i end |
#embed_html(width = 425, height = 344, options = {}, params = {}) ⇒ Object
47 48 49 |
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 47 def (width=425, height=344, ={}, params={}) "<object width='#{width}' height='#{height}'><param name='movie' value='#{}'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='#{}' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='#{width}' height='#{height}'></embed></object>" end |
#embed_url ⇒ Object
43 44 45 |
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 43 def "http://vimeo.com/moogaloop.swf?clip_id=#{@video_id}&force_embed=1&server=vimeo.com&show_title=1&show_byline=0&show_portrait=1&color=ffffff&fullscreen=1&autoplay=0&loop=0" end |
#flv ⇒ Object
51 52 53 54 55 56 |
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 51 def flv res = Net::HTTP.get(URI.parse("http://vimeo.com/42966264?action=download")) request_signature = res.split("\"signature\":\"")[1].split("\"")[0] = res.split("\"cached_timestamp\":")[1].split(",")[0] "http://player.vimeo.com/play_redirect?clip_id=#{@video_id}&sig=#{request_signature}&time=#{}&quality=sd&codecs=H264,VP8,VP6&type=moogaloop&embed_location=" end |
#service ⇒ Object
64 65 66 |
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 64 def service "Vimeo" end |
#thumbnail ⇒ Object
35 36 37 |
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 35 def thumbnail REXML::XPath.first( @feed, "//thumbnail_medium" )[0].to_s end |
#title ⇒ Object
31 32 33 |
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 31 def title REXML::XPath.first( @feed, "//title" )[0].to_s end |
#video_id ⇒ Object
27 28 29 |
# File 'lib/acts_as_unvlogable/vg_vimeo.rb', line 27 def video_id @video_id end |