A feature-rich command-line audio/video downloader
[extractor] Support multiple `_VALID_URL`s (#5812)
pukkandan5fd8367496b4
diff --git a/devscripts/lazy_load_template.py b/devscripts/lazy_load_template.pyindex c8815e01bc..6f52165c5c 100644--- a/devscripts/lazy_load_template.py+++ b/devscripts/lazy_load_template.py@@ -6,6 +6,7 @@ from ..utils import (age_restricted,bug_reports_message,classproperty,+ variadic,write_string,)diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.pyindex 2ea36c63da..3f7dcb82bb 100644--- a/yt_dlp/extractor/common.py+++ b/yt_dlp/extractor/common.py@@ -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 functionsignature is preserved and that this function imports everything it needs@@ -566,8 +566,8 @@ class InfoExtractor:# we have cached the regexp for *this* class, whereas getattr would also# match the superclassif '_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)@classmethoddef suitable(cls, url):