Commit Graph

67 Commits

Author SHA1 Message Date
sbcrumb 5b7d4cdbd0 feat: improve NFO file organization by moving NFOGuard elements to bottom
NFO Organization Enhancement:
- Move all NFOGuard elements (dateadded, lockdata, comments) to bottom of NFO files
- Remove existing NFOGuard elements and re-add at bottom for clean organization
- Provides better separation between media metadata and NFOGuard management
- Easier to read NFO files when Radarr/Sonarr has already populated extensive metadata

Before: NFOGuard elements mixed throughout existing metadata
After: All media metadata first, then NFOGuard elements grouped at bottom

This addresses user feedback about NFO readability when files already contain
extensive metadata from Radarr, making it easier to see both media info and
NFOGuard management details in a logical order.
2025-09-14 11:21:44 -04:00
sbcrumb d8754e41a7 fix: NFO timestamp consistency and enhanced episode processing debug
NFO Management Timestamp Fix:
- Fix NFO management comments to use local timezone instead of UTC
- Both movie and TV episode NFO files now show consistent local timezone
- Comments now show: <!-- managed by NFOGuard at 2025-09-14T09:29:06-04:00 -->

Enhanced Episode Processing Debug:
- Add comprehensive debug logging for webhook episode database lookups
- Track IMDb ID and season/episode info throughout processing pipeline
- Add database write verification to catch storage issues immediately
- Enhanced logging will help identify duplicate processing root causes

This addresses the issue where episodes were being treated as new downloads
instead of finding existing database entries, helping prevent duplicate processing.
2025-09-14 10:27:05 -04:00
sbcrumb 7af7b1c43e feat: complete timezone support for NFO dateadded fields
- Fix NFO dateadded timestamps to use local timezone instead of UTC
- Convert Radarr/Sonarr import dates from UTC to local timezone for NFO files
- Update webhook episode processing to use local time for new downloads
- Convert file modification time fallbacks to local timezone
- Preserve historical dates (aired, premiered) in original UTC format
- Replace all placeholder logging functions with centralized timezone-aware logging
- Add convert_utc_to_local() utility function for timestamp conversion
- Now all logs AND NFO files show consistent local timezone formatting

Users with TZ=America/New_York will now see:
- Logs: [2025-09-14T09:37:00-04:00]
- NFO files: <dateadded>2025-09-14T09:37:00-04:00</dateadded>
2025-09-14 09:56:27 -04:00
sbcrumb 17ef94ec4f feat: implement timezone-aware logging system
- Fix inconsistent timestamp formats in logs for easier troubleshooting
- All logging systems now respect Docker TZ environment variable (e.g., TZ=America/New_York)
- Add TimezoneAwareFormatter for Python's standard logging module
- Enhance _log function with robust timezone support and fallbacks
- Replace placeholder logging functions with centralized core.logging._log
- Support both zoneinfo (Python 3.9+) and pytz (older versions)
- Users now see consistent timezone formatting across all log outputs
2025-09-14 09:45:32 -04:00
sbcrumb f4c56f6cbe feat: smart NFO management and correct episode date field mapping
💾 Smart NFO File Management:
- Add intelligent content comparison to prevent unnecessary file overwrites
- Only update NFO files when content actually changes (ignoring timestamp differences)
- Dramatically reduce file system writes and improve scan performance
- Applied to both TV episodes and movies for comprehensive efficiency
- New _nfo_content_matches() method for smart content comparison

🗓️ Fix Episode Date Field Mapping:
- BREAKING: Correct date field usage in episode NFOs
- <aired> and <premiered>: Now use historical air dates (e.g., 1951-10-15)
- <dateadded>: Correctly shows actual download/import date (e.g., 2025-09-13)
- Resolves confusion between when show aired vs when user downloaded it
- Media servers now show historically accurate metadata with working "Recently Added"

🎯 Technical Changes:
- Enhanced create_episode_nfo() with content comparison logic
- Enhanced create_movie_nfo() with content comparison logic
- Separated historical date logic from import date logic
- Added comprehensive debug logging for file skip/update decisions

🏆 User Experience:
- Faster scans with fewer unnecessary file operations
- Correct historical context in media servers
- "Recently Added" functionality preserved and working
- No more metadata confusion between air dates and import dates

Example NFO output:
- <aired>1951-10-15</aired> (historical)
- <dateadded>2025-09-13T21:39:28+00:00</dateadded> (when downloaded)
- <premiered>1951-10-15</premiered> (historical)
2025-09-13 19:52:43 -04:00
sbcrumb f998a64cdb update f string 2025-09-13 19:23:16 -04:00
sbcrumb 4ef28c3021 updates 2025-09-12 13:54:29 -04:00
sbcrumb dcbb25ca9e Fix Emby TV episode date handling by using <aired> field for import dates
- Issue: Emby displays DateCreated field which gets updated on metadata refresh
- Root cause: Emby ignores <dateadded> but reads <aired> for TV episodes
- Solution: Write import date to <aired> field instead of actual air date
- Emby will now display import date (Feb 19) instead of scan date (Sep 11)
- Maintains backward compatibility with fallback to actual air date
2025-09-11 16:45:36 -04:00
sbcrumb 52fa0b6060 Add missing get_episode_date method and bump version to v0.6.0
🐛 Database Fix:
• Add missing get_episode_date() method to NFOGuardDatabase
• Fixes: 'NFOGuardDatabase' object has no attribute 'get_episode_date'

🔄 Version Update:
• Bump VERSION from 0.2.22 to 0.6.0
• Major feature release with comprehensive TV enhancements

 Now Works:
• Single season processing via /tv/scan-season
• Single episode processing via /tv/scan-episode
• Enhanced NFO generation with Sonarr API metadata
• Database queries for existing episode dates
2025-09-11 09:59:15 -04:00
sbcrumb aff6179ddb Fix missing typing imports in NFOManager
🐛 Fix:
• Add missing Dict, Any imports from typing module
• Resolves NameError: name 'Dict' is not defined
2025-09-11 09:46:23 -04:00
sbcrumb c705fb4d6d 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
2025-09-11 09:39:42 -04:00
sbcrumb afe93b4a8a imdb updates 2025-09-09 17:13:14 -04:00
sbcrumb 4e4ddbf92a updates to api and logging 2025-09-08 15:04:20 -04:00
sbcrumb 946b024fd3 more radarr debugs 2025-09-08 11:20:00 -04:00
sbcrumb 75bf1b470e api update 2025-09-08 11:06:56 -04:00
sbcrumb 5537b3b158 update missing module 2025-09-08 10:10:42 -04:00
sbcrumb f73875acdd refactor 2025-09-08 10:05:04 -04:00