]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blobdiff - src/website.rb
Add a generic parser that will hopefully supplant some site-specific subclasses.
[dead/whatever-dl.git] / src / website.rb
index 4a3f2afe36a0c009a095202e9cb2eb7e405a2395..e9e65ca1909f7add3c8b2c6ecc800a3856145528 100644 (file)
@@ -90,18 +90,28 @@ class Website
     # Factory method returning an instance of
     # the appropriate subclass.
 
+    # While we're looping through the list of subclasses,
+    # we'll set this to the Generic class.
+    generic = nil
+
     # Check the URL against each website's class.
     # The class will know whether or not the URL
     # "belongs" to its website.
     @subclasses.each do |w|
       if w.owns_url?(url)
-        return w.new(url)
+        if w.to_s == 'Generic'
+          generic = w
+        else
+          # We don't want to return Generic here because some
+          # other subclasses further down the list might match
+          # the URL.
+          return w.new(url)
+        end
       end
     end
 
-    # If nothing matched, we don't return an instance
-    # of anything.
-    return nil
+    # If nothing matched, try the generic parser.
+    return generic.new(url)
   end