[common] Add new helper function _match_id
[youtube-dl] / youtube_dl / extractor / common.py
index 403791e6b7252f2f7432d5aa98d9aab8f8a7da55..8d6a6f601e3a2d9316d6ce9fa08a1b2ac98bbf45 100644 (file)
@@ -165,6 +165,14 @@ class InfoExtractor(object):
             cls._VALID_URL_RE = re.compile(cls._VALID_URL)
         return cls._VALID_URL_RE.match(url) is not None
 
+    @classmethod
+    def _match_id(cls, url):
+        if '_VALID_URL_RE' not in cls.__dict__:
+            cls._VALID_URL_RE = re.compile(cls._VALID_URL)
+        m = cls._VALID_URL_RE.match(url)
+        assert m
+        return m.group('id')
+
     @classmethod
     def working(cls):
         """Getter method for _WORKING."""