Merge branch 'master' into subtitles_rework
[youtube-dl] / youtube_dl / extractor / common.py
index e2e192beff593b4768c626e6df94e61a20dbf04e..52c4483c9ecafe914270444b848ba8ac5966f802 100644 (file)
@@ -78,7 +78,13 @@ class InfoExtractor(object):
     @classmethod
     def suitable(cls, url):
         """Receives a URL and returns True if suitable for this IE."""
-        return re.match(cls._VALID_URL, url) is not None
+
+        # This does not use has/getattr intentionally - we want to know whether
+        # we have cached the regexp for *this* class, whereas getattr would also
+        # match the superclass
+        if '_VALID_URL_RE' not in cls.__dict__:
+            cls._VALID_URL_RE = re.compile(cls._VALID_URL)
+        return cls._VALID_URL_RE.match(url) is not None
 
     @classmethod
     def working(cls):