This commit is contained in:
2026-01-11 14:46:41 -08:00
parent 1f3de7db1c
commit 275f18cb31
19 changed files with 2741 additions and 394 deletions

View File

@@ -131,7 +131,7 @@ class Provider(ABC):
#
# Example:
# TABLE_AUTO_STAGES = {"youtube": ["download-file"]}
# TABLE_AUTO_PREFIXES = {"hifi": ["download-file"]} # matches hifi.*
# TABLE_AUTO_PREFIXES = {"tidal": ["download-file"]} # matches tidal.*
TABLE_AUTO_STAGES: Dict[str, Sequence[str]] = {}
TABLE_AUTO_PREFIXES: Dict[str, Sequence[str]] = {}
AUTO_STAGE_USE_SELECTION_ARGS: bool = False

View File

@@ -69,11 +69,11 @@ class ProviderRegistry:
if override_name:
_add(override_name)
else:
# Use class name as the primary canonical name
_add(getattr(provider_class, "__name__", None))
_add(getattr(provider_class, "PROVIDER_NAME", None))
_add(getattr(provider_class, "NAME", None))
_add(getattr(provider_class, "__name__", None))
for alias in getattr(provider_class, "PROVIDER_ALIASES", ()) or ():
_add(alias)
@@ -193,9 +193,23 @@ class ProviderRegistry:
def has_name(self, name: str) -> bool:
return self.get(name) is not None
def _sync_subclasses(self) -> None:
"""Walk all Provider subclasses in memory and register them."""
def _walk(cls: Type[Provider]) -> None:
for sub in cls.__subclasses__():
if sub in {SearchProvider, FileProvider}:
_walk(sub)
continue
try:
self.register(sub)
except Exception:
pass
_walk(sub)
_walk(Provider)
REGISTRY = ProviderRegistry("Provider")
REGISTRY.discover()
REGISTRY._sync_subclasses()
def register_provider(
@@ -382,7 +396,7 @@ def match_provider_name_for_url(url: str) -> Optional[str]:
dom = dom_raw.lower()
if not dom:
continue
if dom.startswith("magnet:") or dom.startswith("http://") or dom.startswith("https://"):
if "://" in dom or dom.startswith("magnet:"):
if raw_url_lower.startswith(dom):
return info.canonical_name
continue