]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blobdiff - src/websites/efukt.rb
Fix the Efukt video url regex.
[dead/whatever-dl.git] / src / websites / efukt.rb
index f4cc58d663b236af75cf8072c0025dbb58259714..0a1e10e8dad9ea50c3a7a35ae87d8d51d1c9a6cd 100644 (file)
@@ -26,7 +26,7 @@ class Efukt < Website
     return url =~ VALID_EFUKT_URL_REGEX
   end
 
-  
+
   def get_video_url()
     page_data = self.get_page_data(@url)
     video_url = self.parse_video_url(page_data)
@@ -40,46 +40,37 @@ class Efukt < Website
     # better than the superclass method because it doesn't rely on the
     # network.
     filename = @url.split('/').pop().split('.')[0]
-    
+
     # Most of the URLs will just be the video's id,
     # followed by an underscore and the video title (with
-    # all spaces replaced by underscores. Sounds look a good
+    # all spaces replaced by underscores. Sounds like a good
     # filename to me.
     filename_regex = /\/([[:alnum:]_]+)\.html/
     matches = filename_regex.match(@url)
 
     # Overwrite the default if our regex worked.
     filename = matches[1] if not (matches.nil? || matches.length < 1)
-    
+
     return (filename + '.flv')
   end
 
-  
+
   protected;
 
-  # Get the FLV file URL from the HTML page for this movie.
-  # It's stored in some Flash variable.
   def parse_video_url(page_data)
-    video_url_regex = /&file=(http:\/\/.*\.flv)&/i
+    # Get the FLV file URL from the HTML page for this movie.
+    # It's stored in some Flash variable.
+    video_url_regex = /flashvars\.file = "(http:\/\/.*\.flv)"/i
     matches = video_url_regex.match(page_data)
 
-    if (matches.nil? || matches.length < 2)
-      raise StandardError.new('Could not find the "file" flash variable on the page.');
+    if not (matches.nil? || matches.length < 2)
+      return matches[1]
+    else
+      raise StandardError.new('Could not find the "file" Flash variable.');
     end
-    
+
     return matches[1]
   end
 
 
-  # Just make a normal HTTP "get" request.
-  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