]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blobdiff - src/websites/youporn.rb
Made the output filename the responsibility of the website subclass.
[dead/whatever-dl.git] / src / websites / youporn.rb
index ef2fb28242d97a733bb50df4c11fc04b6142a9a4..07d7ca022cadeda6f5c5403cfbea96801c2e453e 100644 (file)
@@ -26,15 +26,15 @@ 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 +61,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