novela/containers/novela/scrapers/__init__.py

18 lines
540 B
Python

from .base import BaseScraper
from .awesomedude import AwesomeDudeScraper
from .gayauthors import GayAuthorsScraper
# Register scrapers in priority order (first match wins)
_SCRAPERS: list[type[BaseScraper]] = [
AwesomeDudeScraper,
GayAuthorsScraper,
]
def get_scraper(url: str) -> BaseScraper:
"""Return the appropriate scraper instance for the given URL."""
for scraper_cls in _SCRAPERS:
if scraper_cls.matches(url):
return scraper_cls()
raise ValueError(f"No scraper available for URL: {url}")