7 Commits

Author SHA1 Message Date
b1726968e5 Refactor: Replace CallbackManager with Events pattern
- Replace callback system with events library in SerieScanner
- Update SeriesApp to subscribe to loader and scanner events
- Refactor ScanService to use Events instead of CallbackManager
- Remove CallbackManager imports and callback classes
- Add safe event calling with error handling in SerieScanner
- Update AniworldLoader to use Events for download progress
- Remove progress_callback parameter from download methods
- Update all affected tests for Events pattern
- Fix test_series_app.py for new event subscription model
- Comment out obsolete callback tests in test_scan_service.py

All core tests passing. Events provide cleaner event-driven architecture.
2025-12-30 21:04:45 +01:00
ff9dea0488 removed cancel request 2025-12-30 20:36:02 +01:00
08f816a954 Fix: Add graceful download cancellation on Ctrl+C
- Add cancellation flag to AniworldLoader with request_cancel/reset_cancel/is_cancelled methods
- Update base_provider.Loader interface with cancellation abstract methods
- Integrate cancellation check in YT-DLP progress hooks
- Add request_download_cancel method to SeriesApp and AnimeService
- Update DownloadService.stop() to request cancellation before shutdown
- Clean up temp files on cancellation
2025-12-27 19:31:57 +01:00
7437eb4c02 refactor: improve code quality - fix imports, type hints, and security issues
## 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
2025-10-22 13:00:09 +02:00
f64ba74d93 refactor: Apply PEP8 naming conventions - convert PascalCase methods to snake_case
This comprehensive refactoring applies PEP8 naming conventions across the codebase:

## Core Changes:

### src/cli/Main.py
- Renamed __InitList__() to __init_list__()
- Renamed print_Download_Progress() to print_download_progress()
- Fixed variable naming: task3 -> download_progress_task
- Fixed parameter spacing: words :str -> words: str
- Updated all method calls to use snake_case
- Added comprehensive docstrings

### src/core/SerieScanner.py
- Renamed Scan() to scan()
- Renamed GetTotalToScan() to get_total_to_scan()
- Renamed Reinit() to reinit()
- Renamed private methods to snake_case:
  - __ReadDataFromFile() -> __read_data_from_file()
  - __GetMissingEpisodesAndSeason() -> __get_missing_episodes_and_season()
  - __GetEpisodeAndSeason() -> __get_episode_and_season()
  - __GetEpisodesAndSeasons() -> __get_episodes_and_seasons()
- Added comprehensive docstrings to all methods
- Fixed long line issues

### src/core/providers/base_provider.py
- Refactored abstract base class with proper naming:
  - Search() -> search()
  - IsLanguage() -> is_language()
  - Download() -> download()
  - GetSiteKey() -> get_site_key()
  - GetTitle() -> get_title()
- Added proper type hints (Dict, List, etc.)
- Added comprehensive docstrings explaining contracts
- Fixed newline at end of file

### src/core/providers/aniworld_provider.py
- Renamed public methods to snake_case:
  - Search() -> search()
  - IsLanguage() -> is_language()
  - Download() -> download()
  - GetSiteKey() -> get_site_key()
  - GetTitle() -> get_title()
  - ClearCache() -> clear_cache()
  - RemoveFromCache() -> remove_from_cache()
- Renamed private methods to snake_case:
  - _GetLanguageKey() -> _get_language_key()
  - _GetKeyHTML() -> _get_key_html()
  - _GetEpisodeHTML() -> _get_episode_html()
- Fixed import organization
- Improved code formatting and line lengths
- Added docstrings to all methods

### src/core/SeriesApp.py
- Updated all calls to use new snake_case method names
- Updated loader calls: loader.Search() -> loader.search()
- Updated loader calls: loader.Download() -> loader.download()
- Updated scanner calls: SerieScanner.GetTotalToScan() -> SerieScanner.get_total_to_scan()
- Updated scanner calls: SerieScanner.Reinit() -> SerieScanner.reinit()
- Updated scanner calls: SerieScanner.Scan() -> SerieScanner.scan()

### tests/unit/test_series_app.py
- Updated mock calls to use new snake_case method names:
  - get_total_to_scan() instead of GetTotalToScan()
  - reinit() instead of Reinit()
  - scan() instead of Scan()

## Verification:
- All unit tests pass 
- All integration tests pass 
- All tests pass 
- No breaking changes to functionality

## Standards Applied:
- PEP 8: Function/method names use lowercase with underscores (snake_case)
- PEP 257: Added comprehensive docstrings
- Type hints: Proper type annotations where applicable
- Code formatting: Fixed line lengths and spacing
2025-10-22 12:44:42 +02:00
7a71715183 backup 2025-10-12 18:05:31 +02:00
e477780ed6 refactoring 2025-09-29 21:18:42 +02:00