Commit Graph

33 Commits

Author SHA1 Message Date
sbcrumb b881c7944c initial updates to mirror github files 2025-09-21 09:30:12 -04:00
sbcrumb c6d5d2e6dc updates 2025-09-21 09:28:06 -04:00
sbcrumb 22483717c4 initial update 2025-09-21 09:25:36 -04:00
sbcrumb d64228cc82 Add NFO-based identification and smart episode renaming v1.6.0
- Add dual identification system: directory names + NFO file parsing
- Support <uniqueid type="imdb">, <imdbid>, <imdb> XML tags
- Implement smart episode NFO renaming to S##E##.nfo format
- Detect existing Sonarr/other NFO files and preserve metadata
- Add comprehensive Project.md for context recovery
- Update documentation with new capabilities
2025-09-16 21:14:09 -04:00
sbcrumb 1353b53cc8 CRITICAL: Fix database upsert bug preventing manual scan date persistence
**Root Cause**: upsert_movie_dates() was UPDATE-only, not proper upsert
- Manual scans failed to save dateadded to database (NULL values)
- Webhooks found database entries but with NULL dateadded
- Fell back to current timestamp instead of using proper import dates

**Database Fix**:
- Changed core/database.py upsert_movie_dates() from UPDATE to INSERT OR REPLACE
- Now properly saves dateadded during manual scans
- Preserves existing path with COALESCE fallback

**Webhook Enhancement**:
- Added comprehensive debug logging for database lookups
- Enhanced webhook date decision logic with proper fallback chain
- Only uses current timestamp as absolute last resort

**Impact**:
- Movies: Manual scans now persist dates, webhooks find existing entries 
- TV Shows: Not affected - already using proper INSERT OR REPLACE 
- Version: 1.5.5
2025-09-15 12:18:53 -04:00
sbcrumb ed4a9c0a19 Fix Radarr rename event handling - add missing event type filtering
- Add event type filtering to Radarr webhook handler (Download, Upgrade, Rename)
- Ensures consistency with Sonarr webhook processing
- Fixes issue where Radarr rename events weren't properly updating NFO files
- Bump version to v1.5.3
- Update SUMMARY.md with complete webhook workflow documentation
2025-09-15 09:35:41 -04:00
sbcrumb df04cf9aec update 2025-09-15 09:16:28 -04:00
sbcrumb 75b8338b86 remove hardcode debug statments in favor of variables 2025-09-14 14:38:14 -04:00
sbcrumb 1dae7df3d2 updates to paths again 2025-09-14 14:23:25 -04:00
sbcrumb 1a562f7b41 missing path 2025-09-14 14:21:09 -04:00
sbcrumb f5ae8c7768 cleanup 2025-09-14 14:19:39 -04:00
sbcrumb a9c90d2939 remove debug 2025-09-14 14:15:19 -04:00
sbcrumb 2657729975 dates for TV shows 2025-09-14 13:56:31 -04:00
sbcrumb d7db924510 dates at bottom 2025-09-14 13:54:04 -04:00
sbcrumb 179f8f51d7 nfo dates to the bottom 2025-09-14 13:49:15 -04:00
sbcrumb e7b65cfed6 nfo fix again 2025-09-14 13:44:56 -04:00
sbcrumb 49266d651a fix nfo 2025-09-14 13:40:22 -04:00
sbcrumb 05ba16666e another DB table 2025-09-14 13:31:54 -04:00
sbcrumb d168cc8317 path helper 2025-09-14 13:21:05 -04:00
sbcrumb ebd1191598 updates to flow 2025-09-14 12:51:15 -04:00
sbcrumb 91881262ce docs: complete API keys documentation in README.md
Documentation Enhancement:
- Add missing TVDB_API_KEY to all relevant sections in README.md
- Create comprehensive API keys reference table with purposes and sources
- Add centralized API Keys Configuration section with clear examples
- Document how to resolve "TVDB API key not configured" warnings
- Include direct links to obtain API keys from each service

API Keys Covered:
- TMDB_API_KEY - Movie release dates and metadata fallbacks
- TVDB_API_KEY - TV show metadata and Emby compatibility (was missing!)
- RADARR_API_KEY - Movie import history and database access
- SONARR_API_KEY - TV episode import history

This resolves user questions about the TVDB API key warning and provides
complete documentation for all external API integrations.
2025-09-14 12:07:23 -04:00
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 df5785e8ad feat: MAJOR - implement webhook-first architecture with database priority
Revolutionary Workflow Changes (v0.7.0):
This fundamentally changes how NFOGuard handles timestamps and processing priority.

Webhooks = Source of Truth:
- First webhook fires → Use current timestamp → Store as permanent database entry
- Subsequent webhooks (upgrades) → Check database → Use original first-seen timestamp
- No more API calls during webhook processing → Webhook timing is ultimate authority
- Movies and TV episodes both use webhook-first approach

Manual Scans = Smart Fallback Logic:
- Priority 1: Our database (webhook timestamps) - database always wins
- Priority 2: Sonarr/Radarr import history (first import only)
- Priority 3: Air date as dateadded (final fallback)

Technical Implementation:
- Enhanced _get_webhook_episode_date() to use current timestamp as source of truth
- Added webhook_mode parameter to process_movie() for separate webhook logic
- All manual scans prioritize database entries before making API calls
- All timestamps converted to container timezone (Eastern Time)
- Enhanced debug logging for database lookups and timestamp decisions

Expected Workflow:
First download at 8:30am → webhook timestamp stored in database
Upgrade at 2:00pm → database entry found → original 8:30am timestamp preserved
Manual scan → database entry found → 8:30am timestamp used

This ensures the first-seen webhook timestamp is the permanent source of truth,
with upgrades and manual scans always preserving the original download time.
2025-09-14 10:52:43 -04:00
sbcrumb e188706001 fix: webhook episode processing now uses real Sonarr import history
Critical Fix for Episode Import Dates:
- Webhook episodes now query Sonarr import history instead of using current time
- Fix _get_webhook_episode_date() to follow same logic as manual scans
- Convert import dates from UTC to local timezone for NFO dateadded fields
- Episodes now show 'sonarr:history.import' source instead of 'webhook:new_download'

Before: <dateadded>2025-09-14T12:40:07+00:00</dateadded> (current webhook time)
After:  <dateadded>2025-09-14T08:40:07-04:00</dateadded> (real import time in local timezone)

This fixes the issue where episodes downloaded at 8:40am EST were showing
12:40pm UTC webhook time instead of the actual import timestamp.

Enhanced webhook processing now:
1. Checks database for existing entries (prevents duplicates)
2. Queries Sonarr import history for real import dates
3. Converts UTC import dates to local timezone
4. Only uses current time as last resort for true new downloads
2025-09-14 10:41:43 -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 5c7300fc74 update: VERSION to v0.6.4 and add development workflow instructions
- Update VERSION file from 0.6.1 to 0.6.4 to match timezone logging release
- Add development workflow instructions to SUMMARY.md for future updates
- Document Claude Code's authority to write commits and push changes
- Establish version consistency requirements across VERSION, SUMMARY.md, and git tags
2025-09-14 09:51:11 -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 2d89e87191 feat: revolutionize TV episode date handling for webhook processing
🎯 Problem Fixed:
- TV episodes downloaded today showed historical air dates (1951) as dateadded
- Episodes appeared as old content instead of "recently added" in media servers
- Incorrect fallback logic used air dates instead of actual download times

 Revolutionary Changes:
- Webhook-first processing: When Sonarr webhook fires → use current timestamp
- Database priority: Existing NFOguard entries preserved (no re-processing)
- Smart backfill: Manual scans check Sonarr import history first
- Clear separation: Webhook vs backfill use different logic paths

🔧 Technical Implementation:
- New method: _get_webhook_episode_date() for webhook-specific handling
- Enhanced method: _get_single_episode_date() for proper backfill priority
- Database-first approach: Always check NFOguard DB before external APIs

📋 Correct Processing Flow:
1. New episode download → Sonarr webhook → current time as dateadded
2. Re-download same episode → use existing stored date (preserve original)
3. Backfill scan → NFOguard DB → Sonarr history → air dates (last resort)
4. No bulk import - database populated through webhooks and manual scans

🏆 Results:
- Episodes downloaded today now show today's date as dateadded
- Historical air dates preserved in aired field for accuracy
- "Recently Added" functionality restored in media servers
- No regression for existing properly-dated episodes

🐛 Bug Fixes:
- Fixed f-string syntax error in core/nfo_manager.py:324
- Resolved backslash escaping issue preventing startup
2025-09-13 19:49:39 -04:00
sbcrumb afe93b4a8a imdb updates 2025-09-09 17:13:14 -04:00
sbcrumb 0aa9655d25 digital logic updates 2025-09-09 09:52:55 -04:00
sbcrumb fed82a9e13 digital release logic 2025-09-09 09:30:20 -04:00