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
6.2 KiB
Aniworld Web Application Development Instructions
This document provides detailed tasks for AI agents to implement a modern web application for the Aniworld anime download manager. All tasks should follow the coding guidelines specified in the project's copilot instructions.
Project Overview
The goal is to create a FastAPI-based web application that provides a modern interface for the existing Aniworld anime download functionality. The core anime logic should remain in SeriesApp.py while the web layer provides REST API endpoints and a responsive UI.
Architecture Principles
- Single Responsibility: Each file/class has one clear purpose
- Dependency Injection: Use FastAPI's dependency system
- Clean Separation: Web layer calls core logic, never the reverse
- File Size Limit: Maximum 500 lines per file
- Type Hints: Use comprehensive type annotations
- Error Handling: Proper exception handling and logging
Additional Implementation Guidelines
Code Style and Standards
- Type Hints: Use comprehensive type annotations throughout all modules
- Docstrings: Follow PEP 257 for function and class documentation
- Error Handling: Implement custom exception classes with meaningful messages
- Logging: Use structured logging with appropriate log levels
- Security: Validate all inputs and sanitize outputs
- Performance: Use async/await patterns for I/O operations
📞 Escalation
If you encounter:
- Architecture issues requiring design decisions
- Tests that conflict with documented requirements
- Breaking changes needed
- Unclear requirements or expectations
Document the issue and escalate rather than guessing.
<EFBFBD> Credentials
Admin Login:
- Username:
admin - Password:
Hallo123!
<EFBFBD>📚 Helpful Commands
# Run all tests
conda run -n AniWorld python -m pytest tests/ -v --tb=short
# Run specific test file
conda run -n AniWorld python -m pytest tests/unit/test_websocket_service.py -v
# Run specific test class
conda run -n AniWorld python -m pytest tests/unit/test_websocket_service.py::TestWebSocketService -v
# Run specific test
conda run -n AniWorld python -m pytest tests/unit/test_websocket_service.py::TestWebSocketService::test_broadcast_download_progress -v
# Run with extra verbosity
conda run -n AniWorld python -m pytest tests/ -vv
# Run with full traceback
conda run -n AniWorld python -m pytest tests/ -v --tb=long
# Run and stop at first failure
conda run -n AniWorld python -m pytest tests/ -v -x
# Run tests matching pattern
conda run -n AniWorld python -m pytest tests/ -v -k "auth"
# Show all print statements
conda run -n AniWorld python -m pytest tests/ -v -s
#Run app
conda run -n AniWorld python -m uvicorn src.server.fastapi_app:app --host 127.0.0.1 --port 8000 --reload
Implementation Notes
- Incremental Development: Implement features incrementally, testing each component thoroughly before moving to the next
- Code Review: Review all generated code for adherence to project standards
- Documentation: Document all public APIs and complex logic
- Testing: Maintain test coverage above 80% for all new code
- Performance: Profile and optimize critical paths, especially download and streaming operations
- Security: Regular security audits and dependency updates
- Monitoring: Implement comprehensive monitoring and alerting
- Maintenance: Plan for regular maintenance and updates
Task Completion Checklist
For each task completed:
- Implementation follows coding standards
- Unit tests written and passing
- Integration tests passing
- Documentation updated
- Error handling implemented
- Logging added
- Security considerations addressed
- Performance validated
- Code reviewed
- Task marked as complete in instructions.md
- Infrastructure.md updated and other docs
- Changes committed to git; keep your messages in git short and clear
- Take the next task
TODO List:
Make sure you do not produce doublicate code. the function below is mostly implemented. make sure you maintain the function on one location
-
✅ scanning anime from folder - COMPLETED Implemented initial scan tracking using SystemSettings table. Anime folder scanning now only runs during initial setup, not on each application start.
- Added SystemSettings model with initial_scan_completed flag
- Created SystemSettingsService for managing setup state
- Modified fastapi_app.py to check scan completion status on startup
- Added unit test for SystemSettingsService
-
✅ Nfo scan - COMPLETED Implemented initial NFO scan tracking using SystemSettings table. NFO scanning now only runs during initial setup, not on each application start.
- Added NFO scanning to startup process in fastapi_app.py
- Check initial_nfo_scan_completed flag before running NFO scan
- Run NFO scan only on first startup if TMDB API key is configured and NFO features enabled
- Mark NFO scan as completed after successful first run
- Skip NFO scan on subsequent startups
-
✅ nfo data - COMPLETED Implemented NFO ID extraction and database storage during NFO scan. TMDB and TVDB IDs are now read from existing NFO files and stored in the database.
- Added parse_nfo_ids() method to NFOService to extract IDs from NFO XML
- Modified process_nfo_for_series() to parse IDs and update database
- Modified scan_and_process_nfo() to pass database session for updates
- IDs are extracted from elements or dedicated / elements
- Created comprehensive unit tests for NFO ID parsing (10 tests)
- Created integration tests for database storage
-
✅ Media scan - COMPLETED Implemented initial media scan tracking using SystemSettings table. Media scanning (background loading of episode metadata) now only runs during initial setup, not on each application start.
- Check initial_media_scan_completed flag before running media scan
- Run media scan (checking for incomplete series) only on first startup
- Mark media scan as completed after successful first run
- Skip media scan on subsequent startups
- Existing SystemSettingsService methods already supported this flag