Skip to content

Commit

Permalink
[extractor] Support multiple _VALID_URLs (#5812)
Browse files Browse the repository at this point in the history
Authored by: nixxo
  • Loading branch information
pukkandan committed Jun 21, 2023
1 parent 0dff8e4 commit 5fd8367
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions devscripts/lazy_load_template.py
Expand Up @@ -6,6 +6,7 @@
age_restricted,
bug_reports_message,
classproperty,
variadic,
write_string,
)

Expand Down
8 changes: 4 additions & 4 deletions yt_dlp/extractor/common.py
Expand Up @@ -475,8 +475,8 @@ class InfoExtractor:
Subclasses of this should also be added to the list of extractors and
should define a _VALID_URL regexp and, re-define the _real_extract() and
(optionally) _real_initialize() methods.
should define _VALID_URL as a regexp or a Sequence of regexps, and
re-define the _real_extract() and (optionally) _real_initialize() methods.
Subclasses may also override suitable() if necessary, but ensure the function
signature is preserved and that this function imports everything it needs
Expand Down Expand Up @@ -566,8 +566,8 @@ def _match_valid_url(cls, url):
# 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)
cls._VALID_URL_RE = tuple(map(re.compile, variadic(cls._VALID_URL)))
return next(filter(None, (regex.match(url) for regex in cls._VALID_URL_RE)), None)

@classmethod
def suitable(cls, url):
Expand Down

0 comments on commit 5fd8367

Please sign in to comment.