Files
Aniworld/src/server/providers/provider_factory.py
Lukas 5526ab884a refactor: restructure core→server, split large entity files into database module
- Move src/core/ → src/server/
- Split SerieList.py (531 lines) and series.py (414 lines) into src/server/database/
- Add database/models.py for SQLAlchemy models
- Update all test imports to reflect new structure
- Remove deprecated test files (test_serie_class.py, test_serie_folder_with_year.py)
2026-06-04 21:11:53 +02:00

57 lines
2.0 KiB
Python

"""Provider factory for managing anime content providers.
This module provides a factory class for accessing different anime content
providers (loaders). The factory uses provider identifiers (keys) to return
the appropriate provider instance.
Note: The 'key' parameter in this factory refers to the provider identifier
(e.g., 'aniworld.to'), not to be confused with series keys used within
providers to identify specific anime series.
"""
from typing import Dict
from .aniworld_provider import AniworldLoader
from .base_provider import Loader
class Loaders:
"""Factory class for managing and retrieving anime content providers.
This factory maintains a registry of available providers and provides
access to them via provider keys. Each provider implements the Loader
interface for searching and downloading anime content.
Attributes:
dict: Dictionary mapping provider keys to provider instances.
Provider keys are site identifiers (e.g., 'aniworld.to').
"""
def __init__(self) -> None:
"""Initialize the provider factory with available providers.
Currently supports:
- 'aniworld.to': AniworldLoader for aniworld.to content
"""
self.dict: Dict[str, Loader] = {"aniworld.to": AniworldLoader()}
def GetLoader(self, key: str) -> Loader:
"""Retrieve a provider instance by its provider key.
Args:
key: Provider identifier (e.g., 'aniworld.to').
This is the site/provider key, not a series key.
Returns:
Loader instance for the specified provider.
Raises:
KeyError: If the provider key is not found in the registry.
Note:
The 'key' parameter here identifies the provider/site, while
series-specific operations on the returned Loader use series
keys to identify individual anime series.
"""
return self.dict[key]