X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fwebsites%2Fvimeo.rb;h=a6a4ea36b3e5ae793b4fadf7aa24972535304956;hb=8e886df259246365023322b78f58e4037cb536a4;hp=56243fad3ecd5d0616db0d5fdd5aa605bf01d2b2;hpb=83e06f83d8274cb32a406739839d56e759664b09;p=dead%2Fwhatever-dl.git diff --git a/src/websites/vimeo.rb b/src/websites/vimeo.rb index 56243fa..a6a4ea3 100644 --- a/src/websites/vimeo.rb +++ b/src/websites/vimeo.rb @@ -18,12 +18,6 @@ require 'src/website' -# Needed to download the video XML file, which is in turn -# needed because it contains the junk we need to construct -# the video URL. -require 'net/http' -require 'uri' - class Vimeo < Website @@ -41,16 +35,23 @@ class Vimeo < Website # the junk we need to construct the video URL. Note that the file # URL given in the XML is *not* valid. video_id = self.parse_video_id() - details_url = "http://www.vimeo.com/moogaloop/load/clip:#{video_id}/local" + details_url = "http://vimeo.com/moogaloop/load/clip:#{video_id}/local" details_data = get_page_data(details_url) - request_signature = parse_request_signature(details_data) request_signature_expires = parse_request_signature_expires(details_data) quality = parse_quality(details_data) + + referer = "http://a.vimeocdn.com/p/flash/moogaloop/5.1.15/moogaloop.swf" + referer += "?v=1.0.0" + referer += "&time=#{request_signature_expires}" + self.headers['Referer'] = referer - # Being slightly explicit about what we're doing here... - video_url = "http://www.vimeo.com/moogaloop/play/clip:#{video_id}/#{request_signature}/#{request_signature_expires}/?q=#{quality}" + video_url = "http://player.vimeo.com/play_redirect?clip_id=#{video_id}" + video_url += "&sig=#{request_signature}" + video_url += "&time=#{request_signature_expires}" + video_url += "&quality=#{quality}" + video_url += "&codecs=H264,VP8,VP6" return video_url end @@ -76,9 +77,9 @@ class Vimeo < Website # If that didn't work, the URL must be of the clip_id= form. video_id_regex = /clip_id\=(\d+)/ matches = video_id_regex.match(@url) - video_id = matches[1] if not (matches.nil? || matches.length < 1) + video_id = matches[1] if not matches.nil? || matches.length < 1 else - video_id = matches[1] if not (matches.nil? || matches.length < 1) + video_id = matches[1] if not matches.nil? || matches.length < 1 end return video_id @@ -89,7 +90,7 @@ class Vimeo < Website # It's XML. rs_regex = /(.*?)<\/request_signature>/ matches = rs_regex.match(page_data) - request_signature = matches[1] if not (matches.nil? || matches.length < 1) + request_signature = matches[1] if not matches.nil? || matches.length < 1 return request_signature end @@ -98,16 +99,16 @@ class Vimeo < Website def parse_request_signature_expires(page_data) rse_regex = /(.*?)<\/request_signature_expires>/ matches = rse_regex.match(page_data) - request_signature_expires = matches[1] if not (matches.nil? || matches.length < 1) + rse = matches[1] if not matches.nil? || matches.length < 1 - return request_signature_expires + return rse end def parse_quality(page_data) - quality_regex = /([01])<\isHD>/ + quality_regex = /([01])<\/isHD>/ matches = quality_regex.match(page_data) - is_hd = matches[1] if not (matches.nil? || matches.length < 1) + is_hd = matches[1] if not matches.nil? || matches.length < 1 if is_hd == '1' then # High-definition @@ -119,14 +120,4 @@ class Vimeo < Website end - def get_page_data(url) - uri = URI.parse(url) - - response = Net::HTTP.start(uri.host, uri.port) do |http| - http.get(uri.path) - end - - return response.body - end - end