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
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