Class: Cherrypicker::Vimeo
- Inherits:
-
PluginBase
- Object
- PluginBase
- Cherrypicker::Vimeo
- Defined in:
- lib/cherrypicker/plugins/vimeo.rb
Instance Attribute Summary collapse
-
#download_url ⇒ Object
Returns the value of attribute download_url.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#link ⇒ Object
Returns the value of attribute link.
-
#location ⇒ Object
Returns the value of attribute location.
Class Method Summary collapse
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(link, opts = {}) ⇒ Vimeo
constructor
A new instance of Vimeo.
Methods inherited from PluginBase
Constructor Details
#initialize(link, opts = {}) ⇒ Vimeo
Returns a new instance of Vimeo.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cherrypicker/plugins/vimeo.rb', line 19 def initialize(link, opts={}) o = { :location => nil, }.merge(opts) @link = link @filename = "" @location = o[:location] @download_url = "" hostname = "http://www.vimeo.com/moogaloop/play/clip" #the vimeo ID consists of decimal numbers in the URL vimeo_id = @link[/\d+/] response = Cherrypicker::remote_query("http://www.vimeo.com/moogaloop/load/clip:#{vimeo_id}") title = response.body[/<caption>(.*)<\/caption>/, 1] request_signature = response.body[/<request_signature>(.*)<\/request_signature>/, 1] request_signature_expires = response.body[/<request_signature_expires>(\d+)<\/request_signature_expires>/, 1] hd = response.body[/<isHD>(.*)<\/isHD>/, 1] if hd.to_i == 0 download_url = ":#{vimeo_id}/#{request_signature}/#{request_signature_expires}" else download_url = ":#{vimeo_id}/#{request_signature}/#{request_signature_expires}/?q=hd" end @filename = title.delete("\"'").gsub(/[^0-9A-Za-z]/, '_') + ".mp4" #strip out _quote_ marks @filename.gsub!('_quot_', '') reply = Cherrypicker::remote_query("#{hostname}#{download_url}") @download_url = reply.response['location'] end |
Instance Attribute Details
#download_url ⇒ Object
Returns the value of attribute download_url.
13 14 15 |
# File 'lib/cherrypicker/plugins/vimeo.rb', line 13 def download_url @download_url end |
#filename ⇒ Object
Returns the value of attribute filename.
13 14 15 |
# File 'lib/cherrypicker/plugins/vimeo.rb', line 13 def filename @filename end |
#link ⇒ Object
Returns the value of attribute link.
13 14 15 |
# File 'lib/cherrypicker/plugins/vimeo.rb', line 13 def link @link end |
#location ⇒ Object
Returns the value of attribute location.
13 14 15 |
# File 'lib/cherrypicker/plugins/vimeo.rb', line 13 def location @location end |
Class Method Details
.matches_provider?(url) ⇒ Boolean
15 16 17 |
# File 'lib/cherrypicker/plugins/vimeo.rb', line 15 def self.matches_provider?(url) url.include?("vimeo.com") end |
Instance Method Details
#download ⇒ Object
53 54 55 |
# File 'lib/cherrypicker/plugins/vimeo.rb', line 53 def download Cherrypicker::download_file(@download_url, :location => @location, :filename => @filename) end |