This commit is contained in:
Elan Ruusamäe 2020-09-25 02:15:53 +02:00 committed by GitHub
commit 1932a81704
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 7 deletions

View File

@ -402,21 +402,24 @@ class InfoExtractor(object):
self.set_downloader(downloader)
@classmethod
def suitable(cls, url):
"""Receives a URL and returns True if suitable for this IE."""
def valid_url_match(cls, url):
# 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
m = cls._VALID_URL_RE.match(url)
return m
@classmethod
def suitable(cls, url):
"""Receives a URL and returns True if suitable for this IE."""
m = cls.valid_url_match(url)
return m 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)
m = cls.valid_url_match(url)
assert m
return compat_str(m.group('id'))