This commit is contained in:
2026-01-16 14:21:42 -08:00
parent 0f71ec7873
commit 9dce32cbe3
2 changed files with 66 additions and 13 deletions

View File

@@ -10,7 +10,7 @@ This keeps format selection logic in ytdlp and leaves add-file plug-and-play.
from __future__ import annotations
import sys
from typing import Any, Dict, Iterable, List, Optional
from typing import Any, Dict, Iterable, List, Optional, Tuple
from ProviderCore.base import Provider, SearchResult
from SYS.provider_helpers import TableProviderMixin
@@ -65,31 +65,31 @@ class ytdlp(TableProviderMixin, Provider):
# Dynamically load URL domains from yt-dlp's extractors
# This enables provider auto-discovery for format selection routing
@property
def URL(self) -> List[str]:
"""Get list of supported domains from yt-dlp extractors."""
@classmethod
def url_patterns(cls) -> Tuple[str, ...]:
"""Return supported domains from yt-dlp extractors."""
try:
import yt_dlp
# Build a comprehensive list from known extractors and fallback domains
domains = set(self._fallback_domains)
domains = set(cls._fallback_domains)
# Try to get extractors and extract domain info
try:
extractors = yt_dlp.gen_extractors()
for extractor_class in extractors:
# Get extractor name and try to convert to domain
name = getattr(extractor_class, 'IE_NAME', '')
if name and name not in ('generic', 'http'):
name = getattr(extractor_class, "IE_NAME", "")
if name and name not in ("generic", "http"):
# Convert extractor name to domain (e.g., 'YouTube' -> 'youtube.com')
name_lower = name.lower().replace('ie', '').strip()
name_lower = name.lower().replace("ie", "").strip()
if name_lower and len(name_lower) > 2:
domains.add(f"{name_lower}.com")
except Exception:
pass
return list(domains) if domains else self._fallback_domains
return tuple(domains) if domains else tuple(cls._fallback_domains)
except Exception:
return self._fallback_domains
return tuple(cls._fallback_domains)
# Fallback common domains in case extraction fails
_fallback_domains = [