- Add showtitle and namedseason to mapper output
- Add multi-language fallback (en-US, ja-JP) for empty overview
- Use search result overview as last resort fallback
- Add tests for new NFO creation behavior
- Fixed _remove_episode_from_missing_list to also update in-memory
Serie.episodeDict and refresh series_list
- Added _remove_episode_from_memory helper method
- Enhanced logging for download completion and episode removal
- Added 5 unit tests for missing episode removal
When TMDB returns an empty German (de-DE) overview for anime (e.g.
Basilisk), the NFO plot tag was missing. Now both create and update
paths call _enrich_details_with_fallback() which fetches the English
(en-US) overview as a fallback.
Additionally, the <plot> XML element is always written (even when
empty) via the always_write parameter on _add_element(), ensuring
consistent NFO structure regardless of creation path.
Changes:
- nfo_service.py: add _enrich_details_with_fallback() method, call it
in create_tvshow_nfo and update_tvshow_nfo
- nfo_generator.py: add always_write param to _add_element(), use it
for <plot> tag
- test_nfo_service.py: add TestEnrichDetailsWithFallback with 4 tests
- Implement sync_single_series_after_scan to persist scanned series to database
- Enhanced _broadcast_series_updated to include full NFO metadata (nfo_created_at, nfo_updated_at, tmdb_id, tvdb_id)
- Add immediate episode scanning in add_series endpoint when background loader isn't running
- Implement updateSingleSeries in frontend to handle series_updated WebSocket events
- Add SERIES_UPDATED event constant to WebSocket event definitions
- Update background loader to use sync_single_series_after_scan method
- Simplified background loader initialization in FastAPI app
- Add comprehensive tests for series update WebSocket payload and episode counting logic
- Import reorganization: move get_background_loader_service to dependencies module
✅ COMPLETE: 18/18 tests passing
Test Coverage:
- Concurrent scan prevention: Second scan blocked, multiple attempts handled, lock released after completion
- Scan cancellation: Cancel active scan, cancel when none active, cancelled scans in history, new scan after cancellation
- Database race conditions: AsyncIO lock prevents races, scan state consistency with concurrent reads, thread-safe history updates
- Scan state consistency: is_scanning flag consistency, current_scan object consistency, status API consistency, concurrent status checks
- Scheduler prevention: Scheduler skips rescan if already running, properly sets scan_in_progress flag
- AnimeService: Ignores concurrent rescan requests
All concurrent operation scenarios validated with proper lock management and state consistency.
- Created tests/unit/test_nfo_batch_operations.py
* 19 comprehensive unit tests all passing
* Test concurrent operations with max_concurrent limits
* Test partial failure handling (continues processing)
* Test skip_existing and overwrite functionality
* Test media download options
* Test result accuracy and error messages
* Test edge cases (empty, single, large, duplicates)
- Updated docs/instructions.md
* Marked NFO batch operations tests as completed
* Documented 19/19 passing tests
- Implemented comprehensive test suite for NFO service
- 73 unit tests covering:
- FSK rating extraction from German content ratings
- Year extraction from series names with parentheses
- TMDB to NFO model conversion
- NFO file creation with TMDB integration
- NFO file updates with media refresh
- Media file downloads (poster, logo, fanart)
- NFO ID parsing (TMDB, TVDB, IMDb)
- Edge cases for empty data, malformed XML, missing fields
- Configuration options (image sizes, auto-create)
- File cleanup and close operations
Coverage: 90.65% (target: 80%+)
- Statements covered: 202/222
- Branches covered: 79/88
Test results: All 73 tests passing
- Mocked TMDB API client and image downloader
- Used AsyncMock for async operations
- Tested both success and error paths
- Verified concurrent operations work correctly
- Validated XML parsing and ID extraction
- Modified BackgroundLoaderService to use multiple workers (default: 5)
- Anime additions now process in parallel without blocking
- Added comprehensive unit tests for concurrent behavior
- Updated integration tests for compatibility
- Updated architecture documentation
Critical bug fix: The filter was returning the wrong series because of
a misunderstanding of the episode table semantics.
ISSUE:
- Episodes table contains MISSING episodes (from episodeDict)
- is_downloaded=False means episode file not found in folder
- Original query logic was backwards - returned series with NO missing
episodes instead of series WITH missing episodes
SOLUTION:
- Simplified query to directly check for episodes with is_downloaded=False
- Changed from complex join with count aggregation to simple subquery
- Now correctly returns series that have at least one undownloaded episode
CHANGES:
- src/server/database/service.py: Rewrote get_series_with_no_episodes()
method with corrected logic and clearer documentation
- tests/unit/test_series_filter.py: Updated test expectations to match
corrected behavior with detailed comments explaining episode semantics
- docs/API.md: Enhanced documentation explaining filter behavior and
episode table meaning
TESTS:
All 5 unit tests pass with corrected logic
- Added get_series_with_no_episodes() method to AnimeSeriesService
- Updated list_anime endpoint to support filter='no_episodes' parameter
- Added comprehensive unit tests for the new filtering functionality
- All tests passing successfully
- Modified SeriesManagerService to create SerieList with skip_load=True
- Changed scan_and_process_nfo() to load series from database instead of filesystem
- Fixed database transaction issue by creating separate session per task
- Verified scans only run once during initial setup, not on normal startup
- Test media scan runs on first startup
- Test media scan skipped on subsequent startup
- Test error handling for flag check/mark
- Test _check_incomplete_series_on_startup behavior
- Test detection of incomplete series
- Test all edge cases (8 tests total)
Task 3 (NFO data):
- Add parse_nfo_ids() method to NFOService
- Extract TMDB/TVDB IDs from NFO files during scan
- Update database with extracted IDs
- Add comprehensive unit and integration tests
Task 4 (Media scan):
- Track initial media scan with SystemSettings flag
- Run background loading only on first startup
- Skip media scan on subsequent runs
- Add SystemSettings model to track setup completion status
- Create SystemSettingsService for managing setup flags
- Modify fastapi_app startup to check and set initial_scan_completed flag
- Anime folder scanning now only runs on first startup
- Update DATABASE.md with new system_settings table documentation
- Add unit test for SystemSettingsService functionality
This ensures expensive one-time operations like scanning the entire anime
directory only occur during initial setup, not on every application restart.