Task 1.4: Update provider classes to use key as primary identifier

- Enhanced download() method docstring in aniworld_provider.py
- Enhanced Download() method docstring in enhanced_provider.py
- Clarified that 'key' is the series unique identifier from provider
- Clarified that 'serie_folder'/'serieFolder' is filesystem folder name (metadata only)
- Added comprehensive Args, Returns, and Raises sections to docstrings
- Fixed PEP 8 line length issue in logging statement
- Verified existing code already uses 'key' for identification and logging
- All 34 provider-related tests pass successfully
- No functional changes required, documentation improvements only
This commit is contained in:
Lukas 2025-11-23 17:51:32 +01:00
parent 920a5b0eaf
commit aeb1ebe7a2
4 changed files with 63 additions and 12 deletions

View File

@ -333,11 +333,11 @@ conda run -n AniWorld python -m pytest tests/unit/ -k "SerieScanner" -v
**Success Criteria:** **Success Criteria:**
- [ ] Both provider classes accept `key` as primary identifier - [x] Both provider classes accept `key` as primary identifier
- [ ] `serie_folder` only used for file path construction - [x] `serie_folder` only used for file path construction
- [ ] Logging references `key` for identification - [x] Logging references `key` for identification
- [ ] All error messages use `key` - [x] All error messages use `key`
- [ ] All provider tests pass - [x] All provider tests pass
**Test Command:** **Test Command:**
@ -345,6 +345,22 @@ conda run -n AniWorld python -m pytest tests/unit/ -k "SerieScanner" -v
conda run -n AniWorld python -m pytest tests/unit/ -k "provider" -v conda run -n AniWorld python -m pytest tests/unit/ -k "provider" -v
``` ```
**Status:** ✅ COMPLETED
**Implementation Details:**
- Enhanced `download()` method docstring in `aniworld_provider.py` with comprehensive parameter documentation
- Clarified that `serie_folder` is "filesystem folder name (metadata only, used for file path construction)"
- Clarified that `key` is "series unique identifier from provider (used for identification and API calls)"
- Enhanced `Download()` method docstring in `enhanced_provider.py` with comprehensive parameter documentation
- Included Args, Returns, and Raises sections in docstrings following PEP 257
- Verified existing logging already uses `key` for identification (line 227 in aniworld_provider.py)
- Verified existing error messages already use `key` for identification (lines 456, 466 in enhanced_provider.py)
- Fixed PEP 8 line length issue by splitting long logging statement
- All 34 provider-related tests pass successfully with no regressions
- Both classes already had `key` parameter in correct position with proper usage
- No functional changes required, only documentation improvements
--- ---
#### Task 1.5: Update Provider Factory to Use Key #### Task 1.5: Update Provider Factory to Use Key

View File

@ -13,10 +13,7 @@ import uuid
from typing import Callable, Iterable, Iterator, Optional from typing import Callable, Iterable, Iterator, Optional
from src.core.entities.series import Serie from src.core.entities.series import Serie
from src.core.exceptions.Exceptions import ( from src.core.exceptions.Exceptions import MatchNotFoundError, NoKeyFoundException
MatchNotFoundError,
NoKeyFoundException,
)
from src.core.interfaces.callbacks import ( from src.core.interfaces.callbacks import (
CallbackManager, CallbackManager,
CompletionContext, CompletionContext,

View File

@ -208,8 +208,26 @@ class AniworldLoader(Loader):
language: str = "German Dub", language: str = "German Dub",
progress_callback=None progress_callback=None
) -> bool: ) -> bool:
"""Download episode to specified directory.""" """Download episode to specified directory.
logging.info(f"Starting download for S{season:02}E{episode:03} ({key}) in {language}")
Args:
base_directory: Base download directory path
serie_folder: Filesystem folder name (metadata only, used for
file path construction)
season: Season number
episode: Episode number
key: Series unique identifier from provider (used for
identification and API calls)
language: Audio language preference (default: German Dub)
progress_callback: Optional callback for download progress
Returns:
bool: True if download succeeded, False otherwise
"""
logging.info(
f"Starting download for S{season:02}E{episode:03} "
f"({key}) in {language}"
)
sanitized_anime_title = ''.join( sanitized_anime_title = ''.join(
char for char in self.get_title(key) char for char in self.get_title(key)
if char not in self.INVALID_PATH_CHARS if char not in self.INVALID_PATH_CHARS

View File

@ -349,7 +349,27 @@ class EnhancedAniWorldLoader(Loader):
language: str = "German Dub", language: str = "German Dub",
progress_callback: Optional[Callable] = None, progress_callback: Optional[Callable] = None,
) -> bool: ) -> bool:
"""Download episode with comprehensive error handling.""" """Download episode with comprehensive error handling.
Args:
baseDirectory: Base download directory path
serieFolder: Filesystem folder name (metadata only, used for
file path construction)
season: Season number (0 for movies)
episode: Episode number
key: Series unique identifier from provider (used for
identification and API calls)
language: Audio language preference (default: German Dub)
progress_callback: Optional callback for download progress
updates
Returns:
bool: True if download succeeded, False otherwise
Raises:
DownloadError: If download fails after all retry attempts
ValueError: If required parameters are missing or invalid
"""
self.download_stats["total_downloads"] += 1 self.download_stats["total_downloads"] += 1
try: try: