X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fwebsites%2Fyouporn.rb;h=3e98e9bbabfb4c400daaaa203acb9d94be692c12;hb=e756e0b650774f2503702512ccdc02e86eee1788;hp=ef2fb28242d97a733bb50df4c11fc04b6142a9a4;hpb=168ef3b2ccf5b97d561a3c542a18e8e7587de291;p=dead%2Fwhatever-dl.git diff --git a/src/websites/youporn.rb b/src/websites/youporn.rb index ef2fb28..3e98e9b 100644 --- a/src/websites/youporn.rb +++ b/src/websites/youporn.rb @@ -18,23 +18,18 @@ require 'src/website' -# Needed to download the page, which is in turn -# needed because it contains the video URL. -require 'net/http' -require 'uri' - class Youporn < Website - VALID_YOUPORN_URL_REGEX = /^(http:\/\/)?(www\.)?youporn\.com\/watch\/(\d+)$/ + VALID_YOUPORN_URL_REGEX = /^(http:\/\/)?(www\.)?youporn\.com\/watch\/(\d+)(\/.*)?$/ def self.owns_url?(url) return url =~ VALID_YOUPORN_URL_REGEX end - def get_video_url(url) - page_data = self.get_page_data(url) + def get_video_url() + page_data = self.get_page_data(@url) video_url = self.parse_video_url(page_data) return video_url end @@ -61,15 +56,16 @@ class Youporn < Website response = Net::HTTP.start(uri.host, uri.port) do |http| # Bypass the stupid age verification. form_data = 'user_choice=Enter' - http.post(uri.path, form_data, self.get_headers(url)) + http.post(uri.path, form_data, self.get_headers()) end return response.body end # Build the header hash from the URL we're requesting. - def get_headers(url) - headers = { 'Referer' => url } + def get_headers() + headers = { 'Referer' => @url, + 'Content-Type' => 'application/x-www-form-urlencoded' } end