## Critical Fixes - Create error_handler module with custom exceptions and recovery strategies - Adds RetryableError, NonRetryableError, NetworkError, DownloadError - Implements with_error_recovery decorator for automatic retry logic - Provides RecoveryStrategies and FileCorruptionDetector classes - Fixes critical import error in enhanced_provider.py - Fix CORS security vulnerability in fastapi_app.py - Replace allow_origins=['*'] with environment-based config - Use settings.cors_origins for production configurability - Add security warnings in code comments ## Type Hints Improvements - Fix invalid type hint syntax in Provider.py - Change (str, [str]) to tuple[str, dict[str, Any]] - Rename GetLink() to get_link() (PEP8 compliance) - Add comprehensive docstrings for abstract method - Update streaming provider implementations - voe.py: Add full type hints, update method signature - doodstream.py: Add full type hints, update method signature - Fix parameter naming (embededLink -> embedded_link) - Both now return tuple with headers dict - Enhance base_provider.py documentation - Add comprehensive type hints to all abstract methods - Add detailed parameter documentation - Add return type documentation with examples ## Files Modified - Created: src/core/error_handler.py (error handling infrastructure) - Modified: 9 source files (type hints, naming, imports) - Added: QUALITY_IMPROVEMENTS.md (implementation details) - Added: TEST_VERIFICATION_REPORT.md (test status) - Updated: QualityTODO.md (progress tracking) ## Testing - All tests passing (unit, integration, API) - No regressions detected - All 10+ type checking violations resolved - Code follows PEP8 and PEP257 standards ## Quality Metrics - Import errors: 1 -> 0 - CORS security: High Risk -> Resolved - Type hint errors: 12+ -> 0 - Abstract method docs: Minimal -> Comprehensive - Test coverage: Maintained with no regressions
96 lines
2.7 KiB
Python
96 lines
2.7 KiB
Python
from abc import ABC, abstractmethod
|
|
from typing import Any, Callable, Dict, List, Optional
|
|
|
|
|
|
class Loader(ABC):
|
|
"""Abstract base class for anime data loaders/providers."""
|
|
|
|
@abstractmethod
|
|
def search(self, word: str) -> List[Dict[str, Any]]:
|
|
"""Search for anime series by name.
|
|
|
|
Args:
|
|
word: Search term to look for
|
|
|
|
Returns:
|
|
List of found series as dictionaries containing series information
|
|
"""
|
|
|
|
@abstractmethod
|
|
def is_language(
|
|
self,
|
|
season: int,
|
|
episode: int,
|
|
key: str,
|
|
language: str = "German Dub",
|
|
) -> bool:
|
|
"""Check if episode exists in specified language.
|
|
|
|
Args:
|
|
season: Season number (1-indexed)
|
|
episode: Episode number (1-indexed)
|
|
key: Unique series identifier/key
|
|
language: Language to check (default: German Dub)
|
|
|
|
Returns:
|
|
True if episode exists in specified language, False otherwise
|
|
"""
|
|
|
|
@abstractmethod
|
|
def download(
|
|
self,
|
|
base_directory: str,
|
|
serie_folder: str,
|
|
season: int,
|
|
episode: int,
|
|
key: str,
|
|
language: str = "German Dub",
|
|
progress_callback: Optional[Callable[[str, Dict], None]] = None,
|
|
) -> bool:
|
|
"""Download episode to specified directory.
|
|
|
|
Args:
|
|
base_directory: Base directory for downloads
|
|
serie_folder: Series folder name within base directory
|
|
season: Season number (0 for movies, 1+ for series)
|
|
episode: Episode number within season
|
|
key: Unique series identifier/key
|
|
language: Language version to download (default: German Dub)
|
|
progress_callback: Optional callback for progress updates
|
|
called with (event_type: str, data: Dict)
|
|
|
|
Returns:
|
|
True if download successful, False otherwise
|
|
"""
|
|
|
|
@abstractmethod
|
|
def get_site_key(self) -> str:
|
|
"""Get the site key/identifier for this provider.
|
|
|
|
Returns:
|
|
Site key string (e.g., 'aniworld.to', 'voe.com')
|
|
"""
|
|
|
|
@abstractmethod
|
|
def get_title(self, key: str) -> str:
|
|
"""Get the human-readable title of a series.
|
|
|
|
Args:
|
|
key: Unique series identifier/key
|
|
|
|
Returns:
|
|
Series title string
|
|
"""
|
|
|
|
@abstractmethod
|
|
def get_season_episode_count(self, slug: str) -> Dict[int, int]:
|
|
"""Get season and episode counts for a series.
|
|
|
|
Args:
|
|
slug: Series slug/key identifier
|
|
|
|
Returns:
|
|
Dictionary mapping season number (int) to episode count (int)
|
|
"""
|
|
|