Commit Graph

119 Commits

Author SHA1 Message Date
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 08cddf7799 dll integration 2025-09-12 09:04:23 -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 c7c783570c Add configurable TMDB release type priority system
- Added TMDB_TYPE_PRIORITY environment variable for user-configurable release type preferences
- Default priority: 4,5,3,2,6,1 (Digital → Physical → Theatrical → Limited → TV → Premiere)
- Replaces random first-available selection with intelligent priority-based selection
- Enhanced logging shows selected type and full priority order
- Users can customize priority based on their preferences (e.g. theatrical first)

Version bumped to 0.2.22
2025-09-10 10:17:07 -04:00
sbcrumb 192f59e80c Document comprehensive date selection priority system in README
- Added detailed explanation of 4-tier fallback hierarchy
- Documents all TMDB release types (1-6) with clear descriptions
- Explains rename-first detection and Radarr NFO fallback logic
- Shows difference between import_then_digital vs digital_then_import priorities
- Version bumped to 0.2.21
2025-09-10 10:07:23 -04:00
sbcrumb 5df4db5878 Comprehensive fallback enhancement: Accept any TMDB type + Radarr NFO premiered dates
- TMDB now accepts ANY release type (1-6+) for maximum coverage
- Added Radarr NFO <premiered> date extraction as additional fallback
- For rename-first movies: Import → Any TMDB → Radarr NFO → File dates
- Much more aggressive about using ANY reasonable date over bad file dates
- Covers edge cases where TMDB has unusual release types

Version bumped to 0.2.20
2025-09-10 10:01:20 -04:00
sbcrumb c778cc18eb Add TMDB Type 2 (Limited theatrical) support for modern movies
- Enhanced digital release detection to accept Type 2 (Limited theatrical) dates
- Fixes "To Catch a Killer (2023)" and similar movies that only have festival/limited releases
- Better coverage for modern movies that premiere at film festivals before wide release
- Type 2 dates are better than bad file modification dates for rename-first scenarios

Version bumped to 0.2.19
2025-09-10 09:58:19 -04:00
sbcrumb 6bd7297c37 Add TMDB Type 6 (TV premiere) support for older movies and TV specials
- Enhanced digital release detection to also accept Type 6 (TV premiere) dates
- Fixes issue with 1966 "How the Grinch Stole Christmas!" and similar TV specials
- Detailed debugging revealed Type 6 was available but not being used
- Now properly handles older content that premiered on TV rather than theaters

Version bumped to 0.2.18
2025-09-10 09:29:07 -04:00
sbcrumb 23a71e066d Fix TMDB country configuration and add comprehensive API debugging
- Fixed ExternalClientManager to properly use TMDB_COUNTRY environment variable
- Added detailed TMDB API call logging to debug why external clients return None
- Will show available countries, release types, and specific API responses
- Should resolve the "no_valid_date_source" issue for rename-first movies

Version bumped to 0.2.17
2025-09-10 09:22:17 -04:00
sbcrumb c857a61d0b Bump version to 0.2.16 for TMDB debugging release
- Updated version for enhanced TMDB API debugging
- Container rebuild needed to see new diagnostic logs
- Will help identify TMDB API key and external client issues
2025-09-10 09:15:37 -04:00
sbcrumb f586185a4f Fix debug endpoint to use global movie_processor instance
- Corrected debug endpoint to use global movie_processor variable
- Was incorrectly trying to access batcher.movie_processor (doesn't exist)
- Now properly tests full TMDB fallback pipeline for rename-first movies
2025-09-10 09:08:09 -04:00
sbcrumb 41ef3d80c8 smaller image 2025-09-09 16:43:47 -04:00
sbcrumb 27cb38c3bb git updates 2025-09-09 16:26:07 -04:00
sbcrumb 4a9aecbc22 updates 2025-09-09 10:59:45 -04:00
sbcrumb 19b40c0fd5 update to db call 2025-09-08 18:00:50 -04:00
sbcrumb 678f84b6ef c4-rdarr db updates 2025-09-08 17:33:41 -04:00
sbcrumb 0def0e33af fix(radarr): improve event type parsing and grab event validation
- Fix string-based event type parsing (grabbed, downloadFolderImported, etc.)
- Filter grab events to only count actual downloads with metadata
- Fix JSON parsing errors for dict-type event data
- Enhanced chronological processing for accurate import date detection
- Validate grab events require sourceTitle or indexer info

Fixes issue where library addition events were mistaken for download grabs,
ensuring only real download timestamps are used for
2025-09-08 15:43:04 -04:00
sbcrumb 4e4ddbf92a updates to api and logging 2025-09-08 15:04:20 -04:00
sbcrumb 157ba581b7 new event ID lookup 2025-09-08 14:38:17 -04:00
sbcrumb 134fb0c5c3 feat: Track grab dates as fallback when no imports found 2025-09-08 13:34:48 -04:00
sbcrumb 8702c9556d feat: Improved import detection and reduced debug noise 2025-09-08 13:25:17 -04:00
sbcrumb 78f73845fd better radarr debug 2025-09-08 12:14:51 -04:00
sbcrumb 38bcb9cf28 api radarr debugs 2025-09-08 12:14:04 -04:00
sbcrumb 78c09e3b13 running down radarr API issues 2025-09-08 12:06:01 -04:00
sbcrumb e4da166300 radarr updates 2025-09-08 11:49:18 -04:00
sbcrumb e89eb73bb4 radarr api issues again 2025-09-08 11:41:30 -04:00
sbcrumb 1ea7edeefa more api radarr changes 2025-09-08 11:33:39 -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 932db05646 another api debug 2025-09-08 10:58:29 -04:00
sbcrumb 282717314a api updates 2025-09-08 10:55:03 -04:00
sbcrumb f942b4c253 radarr date troubshooting 2025-09-08 10:29:28 -04:00
sbcrumb 5cc237461c updates for debug scan 2025-09-08 10:21:38 -04:00
sbcrumb 5537b3b158 update missing module 2025-09-08 10:10:42 -04:00