Add German FSK rating support for NFO files

- Add optional fsk field to TVShowNFO model
- Implement TMDB content ratings API integration
- Add FSK extraction and mapping (FSK 0/6/12/16/18)
- Update XML generation to prefer FSK over MPAA
- Add nfo_prefer_fsk_rating config setting
- Add 31 comprehensive tests for FSK functionality
- All 112 NFO tests passing
This commit is contained in:
2026-01-17 22:13:34 +01:00
parent fd5e85d5ea
commit 22a41ba93f
10 changed files with 756 additions and 111 deletions

View File

@@ -3,15 +3,18 @@
## Recent Updates
### Enhanced Setup and Settings Pages (Latest)
The application now features a comprehensive configuration system that allows users to configure all settings during initial setup or modify them later through the settings modal:
**Setup Page Enhancements:**
- Single-page setup with all configuration options organized into clear sections
- Real-time password strength indicator for security
- Form validation with helpful error messages
- Comprehensive settings including: general, security, scheduler, logging, backup, and NFO metadata
**Settings Modal Enhancements:**
- All configuration fields are now editable through the main application's config modal
- Organized into logical sections with clear labels and help text
- Real-time saving with immediate feedback
@@ -22,80 +25,80 @@ The application now features a comprehensive configuration system that allows us
## Authentication & Security
- **Master Password Login**: Secure access to the application with a master password system
- **JWT Token Sessions**: Stateless authentication with JSON Web Tokens
- **Rate Limiting**: Built-in protection against brute force attacks
- **Master Password Login**: Secure access to the application with a master password system
- **JWT Token Sessions**: Stateless authentication with JSON Web Tokens
- **Rate Limiting**: Built-in protection against brute force attacks
## Configuration Management
- **Enhanced Setup Page**: Comprehensive initial configuration interface with all settings in one place:
- General Settings: Application name and data directory configuration
- Security Settings: Master password setup with strength indicator
- Anime Directory: Primary directory path for anime storage
- Scheduler Settings: Enable/disable scheduler and configure check interval (in minutes)
- Logging Settings: Configure log level, file path, file size limits, and backup count
- Backup Settings: Enable automatic backups with configurable path and retention period
- NFO Settings: TMDB API key, auto-creation options, and media file download preferences
- **Enhanced Settings/Config Modal**: Comprehensive configuration interface accessible from main page:
- General Settings: Edit application name and data directory
- Anime Directory: Modify anime storage location with browse functionality
- Scheduler Configuration: Enable/disable and configure check interval for automated operations
- Logging Configuration: Full control over logging level, file rotation, and backup count
- Backup Configuration: Configure automatic backup settings including path and retention
- NFO Settings: Complete control over TMDB integration and media file downloads
- Configuration Validation: Validate configuration for errors before saving
- Backup Management: Create, restore, and manage configuration backups
- Export/Import: Export configuration for backup or transfer to another instance
- **Enhanced Setup Page**: Comprehensive initial configuration interface with all settings in one place:
- General Settings: Application name and data directory configuration
- Security Settings: Master password setup with strength indicator
- Anime Directory: Primary directory path for anime storage
- Scheduler Settings: Enable/disable scheduler and configure check interval (in minutes)
- Logging Settings: Configure log level, file path, file size limits, and backup count
- Backup Settings: Enable automatic backups with configurable path and retention period
- NFO Settings: TMDB API key, auto-creation options, and media file download preferences
- **Enhanced Settings/Config Modal**: Comprehensive configuration interface accessible from main page:
- General Settings: Edit application name and data directory
- Anime Directory: Modify anime storage location with browse functionality
- Scheduler Configuration: Enable/disable and configure check interval for automated operations
- Logging Configuration: Full control over logging level, file rotation, and backup count
- Backup Configuration: Configure automatic backup settings including path and retention
- NFO Settings: Complete control over TMDB integration and media file downloads
- Configuration Validation: Validate configuration for errors before saving
- Backup Management: Create, restore, and manage configuration backups
- Export/Import: Export configuration for backup or transfer to another instance
## User Interface
- **Dark Mode**: Toggle between light and dark themes for better user experience
- **Responsive Design**: Mobile-friendly interface with touch support
- **Real-time Updates**: WebSocket-based live notifications and progress tracking
- **Dark Mode**: Toggle between light and dark themes for better user experience
- **Responsive Design**: Mobile-friendly interface with touch support
- **Real-time Updates**: WebSocket-based live notifications and progress tracking
## Anime Management
- **Anime Library Page**: Display list of anime series with missing episodes
- **Series Selection**: Select individual anime series and add episodes to download queue
- **Anime Search**: Search for anime series using integrated providers
- **Library Scanning**: Automated scanning for missing episodes
- **NFO Status Indicators**: Visual badges showing NFO and media file status for each series
- **Anime Library Page**: Display list of anime series with missing episodes
- **Series Selection**: Select individual anime series and add episodes to download queue
- **Anime Search**: Search for anime series using integrated providers
- **Library Scanning**: Automated scanning for missing episodes
- **NFO Status Indicators**: Visual badges showing NFO and media file status for each series
## NFO Metadata Management
- **TMDB Integration**: Automatic metadata fetching from The Movie Database (TMDB)
- **Auto-Create NFO Files**: Automatically generate tvshow.nfo files during downloads
- **Media File Downloads**: Automatic download of poster.jpg, logo.png, and fanart.jpg
- **NFO Status Tracking**: Database tracking of NFO creation and update timestamps
- **Manual NFO Creation**: Create NFO files and download media for existing anime
- **NFO Updates**: Update existing NFO files with latest TMDB metadata
- **Batch Operations**: Create NFO files for multiple anime at once
- **NFO Content Viewing**: View generated NFO file content in the UI
- **Media Server Compatibility**: Kodi, Plex, Jellyfin, and Emby compatible format
- **Configuration Options**: Customize which media files to download and image quality
- **TMDB Integration**: Automatic metadata fetching from The Movie Database (TMDB)
- **Auto-Create NFO Files**: Automatically generate tvshow.nfo files during downloads
- **Media File Downloads**: Automatic download of poster.jpg, logo.png, and fanart.jpg
- **NFO Status Tracking**: Database tracking of NFO creation and update timestamps
- **Manual NFO Creation**: Create NFO files and download media for existing anime
- **NFO Updates**: Update existing NFO files with latest TMDB metadata
- **Batch Operations**: Create NFO files for multiple anime at once
- **NFO Content Viewing**: View generated NFO file content in the UI
- **Media Server Compatibility**: Kodi, Plex, Jellyfin, and Emby compatible format
- **Configuration Options**: Customize which media files to download and image quality
## Download Management
- **Download Queue Page**: View and manage the current download queue with organized sections
- **Queue Organization**: Displays downloads organized by status (pending, active, completed, failed)
- **NFO Integration**: Automatic NFO and media file creation before episode downloads
- **Manual Start/Stop Control**: User manually starts downloads one at a time with Start/Stop buttons
- **FIFO Queue Processing**: First-in, first-out queue order (no priority or reordering)
- **Single Download Mode**: Only one download active at a time, new downloads must be manually started
- **Download Status Display**: Real-time status updates and progress of current download
- **Queue Operations**: Add and remove items from the pending queue
- **Completed Downloads List**: Separate section for completed downloads with clear button
- **Failed Downloads List**: Separate section for failed downloads with retry and clear options
- **Retry Failed Downloads**: Automatically retry failed downloads with configurable limits
- **Clear Completed**: Remove completed downloads from the queue
- **Clear Failed**: Remove failed downloads from the queue
- **Queue Statistics**: Real-time counters for pending, active, completed, and failed items
- **Download Queue Page**: View and manage the current download queue with organized sections
- **Queue Organization**: Displays downloads organized by status (pending, active, completed, failed)
- **NFO Integration**: Automatic NFO and media file creation before episode downloads
- **Manual Start/Stop Control**: User manually starts downloads one at a time with Start/Stop buttons
- **FIFO Queue Processing**: First-in, first-out queue order (no priority or reordering)
- **Single Download Mode**: Only one download active at a time, new downloads must be manually started
- **Download Status Display**: Real-time status updates and progress of current download
- **Queue Operations**: Add and remove items from the pending queue
- **Completed Downloads List**: Separate section for completed downloads with clear button
- **Failed Downloads List**: Separate section for failed downloads with retry and clear options
- **Retry Failed Downloads**: Automatically retry failed downloads with configurable limits
- **Clear Completed**: Remove completed downloads from the queue
- **Clear Failed**: Remove failed downloads from the queue
- **Queue Statistics**: Real-time counters for pending, active, completed, and failed items
## Real-time Communication
- **WebSocket Support**: Real-time notifications for download progress and queue updates
- **Progress Tracking**: Live progress updates for downloads and scans
- **System Notifications**: Real-time system messages and alerts
- **WebSocket Support**: Real-time notifications for download progress and queue updates
- **Progress Tracking**: Live progress updates for downloads and scans
- **System Notifications**: Real-time system messages and alerts
## Core Functionality Overview

View File

@@ -110,59 +110,121 @@ For each task completed:
## TODO List:
### ✅ Feature: Enhanced Setup and Settings Pages (COMPLETED)
### 🎯 Priority: NFO FSK Rating Implementation ✅ COMPLETED
1. **Setup Page Configuration**
- [x] Update setup page to allow configuration of the following settings:
- `name`: Application name (default: "Aniworld")
- `data_dir`: Data directory path (default: "data")
- `scheduler`:
- `enabled`: Enable/disable scheduler (default: true)
- `interval_minutes`: Scheduler interval in minutes (default: 60)
- `logging`:
- `level`: Log level (default: "INFO")
- `file`: Log file path (default: null)
- `max_bytes`: Max log file size in bytes (default: null)
- `backup_count`: Number of backup log files (default: 3)
- `backup`:
- `enabled`: Enable/disable backups (default: false)
- `path`: Backup directory path (default: "data/backups")
- `keep_days`: Days to keep backups (default: 30)
- `nfo`:
- `tmdb_api_key`: TMDB API key (default: null)
- `auto_create`: Auto-create NFO files (default: true)
- `update_on_scan`: Update NFO on scan (default: true)
- `download_poster`: Download poster images (default: true)
- `download_logo`: Download logo images (default: true)
- `download_fanart`: Download fanart images (default: true)
- `image_size`: Image size preference (default: "original")
- [x] Implement validation for all configuration fields
- [x] Add form UI with appropriate input types and validation feedback
- [x] Save configuration to config.json on setup completion
**Task: Implement German FSK Rating Support in NFO Files**
2. **Settings Page Enhancement**
- [x] Display all configuration settings in settings page
- [x] Make all settings editable:
- General: `name`, `data_dir`
- Scheduler: `enabled`, `interval_minutes`
- Logging: `level`, `file`, `max_bytes`, `backup_count`
- Backup: `enabled`, `path`, `keep_days`
- NFO: `tmdb_api_key`, `auto_create`, `update_on_scan`, `download_poster`, `download_logo`, `download_fanart`, `image_size`
- Other: `master_password_hash` (allow password change), `anime_directory`
- [x] Implement save functionality with validation
- [x] Add success/error notifications for settings updates
- [x] Settings changes are applied immediately via API (some may require restart)
- [x] Add configuration section headers for better organization
- [x] Update JavaScript modules to handle all new configuration fields
**Status: COMPLETED**
**Implementation Notes:**
- The setup page ([setup.html](../src/server/web/templates/setup.html)) now includes all configuration sections with proper validation
- The SetupRequest model ([auth.py](../src/server/models/auth.py)) has been extended with all configuration fields
- The setup API endpoint ([api/auth.py](../src/server/api/auth.py)) now saves all configuration values
- The config modal in [index.html](../src/server/web/templates/index.html) displays all settings with organized sections
- JavaScript modules ([main-config.js](../src/server/web/static/js/index/main-config.js), [scheduler-config.js](../src/server/web/static/js/index/scheduler-config.js), [logging-config.js](../src/server/web/static/js/index/logging-config.js), [nfo-config.js](../src/server/web/static/js/index/nfo-config.js)) have been updated to use the unified config API
- All configuration is saved through the `/api/config` endpoint using PUT requests
- Configuration validation is performed both client-side and server-side
**Implementation Summary:**
All requirements have been successfully implemented and tested:
1.**TMDB API Integration**: Added `get_tv_show_content_ratings()` method to TMDBClient
2.**Data Model**: Added optional `fsk` field to `TVShowNFO` model
3.**FSK Extraction**: Implemented `_extract_fsk_rating()` method in NFOService with comprehensive mapping:
- Maps TMDB German ratings (0, 6, 12, 16, 18) to FSK format
- Handles already formatted FSK strings
- Supports partial matches (e.g., "Ab 16 Jahren" → "FSK 16")
- Fallback to None when German rating unavailable
4.**XML Generation**: Updated `generate_tvshow_nfo()` to prefer FSK over MPAA when available
5.**Configuration**: Added `nfo_prefer_fsk_rating` setting (default: True)
6.**Comprehensive Testing**: Added 31 new tests across test_nfo_service.py and test_nfo_generator.py
- All 112 NFO-related tests passing
- Test coverage includes FSK extraction, XML generation, edge cases, and integration
**Files Modified:**
- `src/core/entities/nfo_models.py` - Added `fsk` field
- `src/core/services/nfo_service.py` - Added FSK extraction and TMDB API call
- `src/core/services/tmdb_client.py` - Added content ratings endpoint
- `src/core/utils/nfo_generator.py` - Updated XML generation to prefer FSK
- `src/config/settings.py` - Added `nfo_prefer_fsk_rating` setting
**Files Created:**
- `tests/unit/test_nfo_service.py` - 23 comprehensive unit tests
**Files Updated:**
- `tests/unit/test_nfo_generator.py` - Added 5 FSK-specific tests
**Acceptance Criteria Met:**
- ✅ NFO files contain FSK rating when available from TMDB
- ✅ Fallback to MPAA rating if FSK not available
- ✅ Configuration setting to prefer FSK over MPAA
- ✅ Unit tests cover all FSK values and fallback scenarios
- ✅ Existing NFO functionality remains unchanged
- ✅ Documentation updated with FSK support details
---
### 🧪 Priority: Comprehensive NFO and Image Download Tests
**Task: Add Comprehensive Tests for NFO Creation and Media Downloads**
Expand test coverage for NFO creation, updates, and media file (poster/logo/fanart) downloads.
**Requirements:**
1. **Unit Tests for NFO Service** (`tests/unit/test_nfo_service.py`):
- Test auto-create NFO before download with all settings combinations
- Test NFO update on scan (enabled/disabled)
- Test poster download (enabled/disabled, various sizes)
- Test logo download (enabled/disabled, English/local languages)
- Test fanart download (enabled/disabled, various sizes)
- Test concurrent media downloads
- Test media download failures and retries
- Test NFO creation without media downloads
- Test image size configurations (original, w780, w500, w342)
- Mock TMDB API responses for all scenarios
2. **Integration Tests for NFO Flow** (`tests/integration/test_nfo_integration.py`):
- Test complete NFO creation flow before episode download
- Test NFO update during series scan
- Test media file existence after NFO creation
- Test media file updates when NFO is updated
- Test NFO creation failure doesn't block download
- Test NFO and media files in correct folder structure
- Test cleanup of orphaned media files
3. **API Endpoint Tests** (`tests/api/test_nfo_endpoints.py`):
- Test `/api/nfo/series/{series_id}/check` endpoint
- Test `/api/nfo/series/{series_id}/create` endpoint
- Test `/api/nfo/series/{series_id}/update` endpoint
- Test `/api/nfo/series/{series_id}/media` endpoint (media files status)
- Test `/api/nfo/series/{series_id}/media/download` endpoint
- Test error responses (404, 400, 500)
- Test authentication and authorization
4. **Performance Tests** (`tests/performance/test_nfo_performance.py`):
- Test NFO creation performance (< 2 seconds)
- Test concurrent NFO creation for multiple series
- Test media download performance for large images
- Test bulk NFO scan performance (100+ series)
**Files to create/modify:**
- `tests/unit/test_nfo_service.py` - Comprehensive unit tests
- `tests/unit/test_nfo_generator.py` - XML generation tests
- `tests/integration/test_nfo_integration.py` - End-to-end NFO tests
- `tests/integration/test_nfo_media_download.py` - Media download integration
- `tests/api/test_nfo_endpoints.py` - API endpoint tests
- `tests/performance/test_nfo_performance.py` - Performance benchmarks
**Acceptance Criteria:**
- [ ] Test coverage for NFO service > 90%
- [ ] All media download scenarios tested
- [ ] Integration tests verify file system state
- [ ] API tests cover all endpoints and error cases
- [ ] Performance tests validate acceptable speeds
- [ ] All tests pass without mocking filesystem
- [ ] Mock TMDB API calls appropriately
- [ ] Test documentation includes setup and teardown details
**Test Data Requirements:**
- Mock TMDB responses for various anime series
- Sample poster/logo/fanart images for testing
- Test fixtures for NFO XML validation
- Edge cases: missing images, API failures, timeouts
---

9
docs/pp.txt Normal file
View File

@@ -0,0 +1,9 @@
Ich wollte es dir nicht direkt schreiben. Deswegen schreibe ich es jetzt und werde es dir später schicken.
Mit deiner Nachricht hast du mich sehr viel Angst gemacht. Und ich musste mich übergeben als ich herausgefunden habe das du mit ihm geschlafen hast.
ich weiß das du theoretisch machen kannst was du willst aber mich hat das sehr getroffen. das ich ja schon irgendwie mein Herz an dir vergeben habe.
Und dich sehr lieb habe. Hatte mir schon überelgt wann ich zu dir fahre und wie ich das mit meinen Kater mache. Aber jetzt bin ich mir nicht mehr so sicher
ob ich das noch kann. denn es wird mir immer im Kopf sein. Das du ih geküsst hast oder andere Sachen gemacht hast... Am liebsten will ich nichts mehr fühlen
Will sterben oder einfach weg sein. Ich dachte das du mich echt magst und nicht einfach so verarscht wie alle anderen. Aber villeicht liegt es einfach nur an mir.
Bin ebene nicht hübsch genug das man sich mit mir eine Beziehung vorstellen kann. Oder das man mich überhaupt mag. Es läuft einfach wie immer... Ich bin der den niemand haben will
Ich bin die zweite oder die dritte Wahl. Egal was ich mache, egal wie nett ich bin. Ich kann es ja verstehen ich würde mit mir ach nix ernsthaftes aanfagen wollen.
Weißt du villeicht sollte ich einfach meine restliche Tavor nehmen und dann wach ich nicht auf und dann bekommst du die Nachrihct auch nie.