Add comprehensive TV show enhancements and URL-safe endpoints

 Features Added:
• Single season/episode processing capability via new endpoints
• Enhanced NFO generation with full Sonarr API metadata (titles, plots, ratings)
• NFOGuard timestamp tracking in all NFO source comments
• URL-safe /tv/scan-season and /tv/scan-episode endpoints

🔧 Technical Improvements:
• Fixed URL encoding issues for paths with spaces and special characters
• Enhanced TVProcessor with process_season() and process_episode_file() methods
• Rich metadata extraction from Sonarr API (episode titles, plots, runtime, ratings)
• XML escaping for special characters in metadata
• Comprehensive episode parsing (SxxExx and numeric formats)

📚 Documentation:
• Updated README with new TV processing endpoints
• Added enhanced NFO generation examples showing before/after
• Documented URL-safe alternatives to manual scan paths

🎯 User Benefits:
• Can now process single seasons: Chicago Fire Season 13
• Can now process single episodes: S13E21 files
• Enhanced NFO files with full episode metadata for better Emby/Plex experience
• Timestamps show when NFOGuard processed each file
This commit is contained in:
2025-09-11 09:39:42 -04:00
parent c7c783570c
commit c705fb4d6d
3 changed files with 426 additions and 12 deletions
+76 -2
View File
@@ -14,9 +14,11 @@ It integrates with **Sonarr** and **Radarr**, listens for import/rename/upgrade
- **Import Date Locking**
Captures the original date a movie or episode was imported and preserves it across upgrades.
- **NFO Management**
- **Enhanced NFO Management**
Creates and updates `.nfo` files for movies and TV episodes with consistent `<dateadded>` fields.
Optionally adds `<lockdata>` to prevent metadata drift from scrapers.
**NEW**: Full metadata integration from Sonarr API (episode titles, plots, ratings, runtime).
Optionally adds `<lockdata>` to prevent metadata drift from scrapers.
**NEW**: Timestamps all NFO files with creation/update dates.
- **Filesystem Time Fixing**
Updates file and directory modification times (`mtime`) to match the preserved import date.
@@ -165,6 +167,32 @@ curl -X POST "http://localhost:8080/manual/scan?path=/media/movies"
curl -X POST "http://localhost:8080/bulk/update"
```
### TV Show Processing (NEW in v0.6.0+)
```bash
# Process a specific TV season (URL-safe)
curl -X POST "http://localhost:8080/tv/scan-season" \
-H "Content-Type: application/json" \
-d '{
"series_path": "/media/TV/tv/Chicago Fire (2012) [imdb-tt2261391]",
"season_name": "Season 13"
}'
# Process a specific TV episode (URL-safe)
curl -X POST "http://localhost:8080/tv/scan-episode" \
-H "Content-Type: application/json" \
-d '{
"series_path": "/media/TV/tv/Chicago Fire (2012) [imdb-tt2261391]",
"season_name": "Season 13",
"episode_name": "Chicago Fire (2012)-S13E21-The Bad Guy[WEBDL-1080p][AAC2.0][h264].mkv"
}'
# Process single season via manual scan (URL encoding required for spaces)
curl -X POST "http://localhost:8080/manual/scan?path=/media/TV/tv/Chicago%20Fire%20(2012)%20%5Bimdb-tt2261391%5D/Season%2013"
# Process single episode via manual scan (URL encoding required for spaces)
curl -X POST "http://localhost:8080/manual/scan?path=/media/TV/tv/Chicago%20Fire%20(2012)%20%5Bimdb-tt2261391%5D/Season%2013/episode.mkv"
```
### Testing & Validation
```bash
# Test database connections
@@ -427,6 +455,52 @@ Emby/Jellyfin/Plex see the file as unchanged in chronology.
Result: no more "old shows" showing up in "Recently Added."
## 📺 Enhanced NFO Generation (NEW)
NFOGuard now creates **full-featured NFO files** with rich metadata from Sonarr:
### Before (Basic Format):
```xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<episodedetails>
<season>13</season>
<episode>2</episode>
<aired>2024-10-03</aired>
<dateadded>2025-02-19T23:10:35+00:00</dateadded>
<premiered>2025-02-19</premiered>
<lockdata>true</lockdata>
<!-- source: TV Episode; sonarr:history.import -->
<!-- managed by NFOGuard -->
</episodedetails>
```
### After (Enhanced Format):
```xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<episodedetails>
<season>13</season>
<episode>2</episode>
<title>Ride the Blade</title>
<plot>Firehouse 51 tackles a fire at a local restaurant. Boden has an emotional conversation with his stepson.</plot>
<runtime>42</runtime>
<rating>8.2</rating>
<votes>1543</votes>
<aired>2024-10-03</aired>
<dateadded>2025-02-19T23:10:35+00:00</dateadded>
<premiered>2025-02-19</premiered>
<lockdata>true</lockdata>
<!-- source: TV Episode; sonarr:history.import -->
<!-- managed by NFOGuard at 2025-09-11T13:45:22+00:00 -->
</episodedetails>
```
**Enhanced features:**
-**Episode titles** from Sonarr API
-**Plot summaries** for better library browsing
-**Runtime** and **ratings** data
-**Timestamps** showing when NFOGuard processed the file
-**Smart URL-safe endpoints** for processing individual seasons/episodes
🔍 Logging & Debugging
# Enable verbose logging
DEBUG=true