Commit Graph

164 Commits

Author SHA1 Message Date
sbcrumb 47eb74da06 debug: debug airdates in TV
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-16 09:50:04 -04:00
sbcrumb 113b44b9ab testing: testing airdate pulls
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-16 09:29:29 -04:00
sbcrumb 8a3e01d966 fix: shows not seeing airdates
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-16 09:17:03 -04:00
sbcrumb c5177ba920 sonarr: fix airdates not being used.
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-16 08:51:54 -04:00
sbcrumb d17f924192 fix: nfo cache
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-15 21:13:51 -04:00
sbcrumb 857d423ae4 fix: airdates again
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-15 20:58:26 -04:00
sbcrumb 4ea202cca2 fix: airdate issues
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-15 18:51:16 -04:00
sbcrumb b8d85e356a fix: more webui issues
Local Docker Build (Dev) / build-dev (push) Successful in 5s
2025-10-15 17:29:53 -04:00
sbcrumb 366eaa2877 🛡️ Complete Protection Implemented:
Local Docker Build (Dev) / build-dev (push) Successful in 4s
1. Enhanced Debugging: Will show exact episode dict structure and contents
  2. Safe Conversion: Try/catch around int(episode) with detailed error logging
  3. Format String Protection: All print statements now have fallback error handling
  4. Response Safety: Safe episode conversion for API response object
2025-10-15 16:58:39 -04:00
sbcrumb 987ca1977b fix: update for UI and dates
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-15 16:55:02 -04:00
sbcrumb 4b77872fd5 web: more web updated and improvements
Local Docker Build (Dev) / build-dev (push) Successful in 5s
2025-10-15 16:02:51 -04:00
sbcrumb d02ee396e9 fix: not finding aridates
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-15 11:07:18 -04:00
sbcrumb 9850dc596a web: trying to fix date look up
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-15 11:02:32 -04:00
sbcrumb 068507adce web:updates again
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-15 10:57:24 -04:00
sbcrumb 79a311f8ec web: fix for unresponsive web interface
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-15 10:13:25 -04:00
sbcrumb 909df0cc83 web: update web interface for tv eps missing date
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-15 09:55:28 -04:00
sbcrumb 913aed1f60 fix: data issue not populating
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-15 08:21:27 -04:00
sbcrumb 0dfc296bf4 fix: db not filling in .nfo data
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-15 07:56:56 -04:00
sbcrumb 66ba17991e fix:updates for interface
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-14 16:38:30 -04:00
sbcrumb f903606d3a fix: fix webinterface broken when manual scan
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-14 16:29:27 -04:00
sbcrumb 051f9d7173 fix: broken interface
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-14 16:16:05 -04:00
sbcrumb 867bd008c5 fix: Improve Docker container shutdown handling
Local Docker Build (Dev) / build-dev (push) Successful in 3s
- Add proper signal handlers for graceful shutdown of all components
- Implement WebhookBatcher.shutdown() to properly close ThreadPoolExecutor and cancel timers
- Add NFOGuardDatabase.close() method to close thread-local database connections
- Increase uvicorn graceful shutdown timeout to 15 seconds
- Add cleanup in finally block to ensure resources are freed even if signal handler fails
- Reduce logging and server header overhead for better performance

This should resolve Docker container shutdown issues where containers don't respond to SIGTERM properly.

Bump version to 2.1.1

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-10-12 13:02:07 -04:00
sbcrumb a559873999 release: Clean up debug logging and bump to v2.1.0
Local Docker Build (Dev) / build-dev (push) Successful in 4s
FEATURES ADDED:
- Comprehensive TV IMDb detection (folder/filename/NFO)
- TV show batch validation prevents wrong series processing
- Fixed glob pattern for exact IMDb matching
- Enhanced webhook path mapping reliability

CLEANUP:
- Removed temporary debug print statements
- Clean production-ready logging
- Maintains all core improvements from debugging session

FIXES:
- Resolves Girls (2012) vs Golden Girls matching issue
- Proper bracket escaping in glob patterns
- Comprehensive IMDb detection for both movies and TV shows
2025-10-12 11:15:20 -04:00
sbcrumb baa6474d12 debug: Force path mapper debug logging to diagnose webhook path mapping failure
Local Docker Build (Dev) / build-dev (push) Successful in 4s
- Enable path_debug temporarily during webhook path mapping
- Version 2.0.28 to track path mapping diagnostics
- Should show Sonarr root folder matching and TV path mapping logic
2025-10-12 11:06:02 -04:00
sbcrumb 53d7753231 sonarr-matching (#48)
Local Docker Build (Dev) / build-dev (push) Successful in 4s
Reviewed-on: #48
2025-10-12 11:02:36 -04:00
sbcrumb 80df0a0278 chore: Bump version to 2.0.26 for enhanced debug logging
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-12 10:57:33 -04:00
sbcrumb 716dcc05e8 chore: Bump version to 2.0.25 for sonarr-matching fixes
- Increment version for comprehensive TV IMDb detection fixes
- Includes glob pattern fix and batch validation improvements
- Ready for deployment and testing
2025-10-12 10:53:50 -04:00
sbcrumb 0827d30a76 Fix NFO extraction to handle lockdata+aired but no dateadded
Local Docker Build (Dev) / build-dev (push) Successful in 3s
The root issue was that NFO extraction methods required both dateadded
AND lockdata=true to return any data. But "The Chosen" NFOs have
lockdata=true and aired dates but no dateadded field, so extraction
returned None and TIER 2 fallback logic never triggered.

Changes:
- Modified extract_nfoguard_dates_from_nfo() to accept lockdata=true NFOs
- Added support for extracting aired dates from episode NFOs
- Updated logic to return data when lockdata=true regardless of dateadded
- Now TIER 2 will properly apply aired->dateadded fallback logic
- Updated version to 2.0.24

This ensures episodes with incomplete NFO metadata get proper fallback
processing instead of being ignored by the three-tier system.

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-10-11 14:38:37 -04:00
sbcrumb 5b9f5c44e1 Fix TV processor TIER 2 fallback logic for NFO files with aired but no dateadded
Local Docker Build (Dev) / build-dev (push) Successful in 4s
The issue was that TIER 2 (NFO cache) wasn't applying the aired date fallback
when NFO files contained aired dates but no dateadded values. This caused
episodes like "The Chosen" to show "no date added just air" because the
system would find lockdata in TIER 2 but reject it due to missing dateadded,
without applying the fallback logic.

Changes:
- Enhanced TIER 2 NFO processing to apply aired->dateadded fallback
- Added debug logging for NFO fallback cases
- Updated version to 2.0.23

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-10-11 13:12:36 -04:00
sbcrumb fb3040c554 Implement optimal caching hierarchy for both movies and TV shows
Perfect the caching strategy as requested:
1. Database check first (fastest lookup)
2. NFO file extraction with database caching
3. API calls only when absolutely necessary

Movies: Fixed order from NFO->DB->API to DB->NFO->API
TV Shows: Added missing NFO extraction tier between database and API

Benefits:
- First scan: Extract existing NFOGuard data from NFOs and cache in DB
- Subsequent scans: ~99% database cache hits, minimal API calls
- NFO recovery: Rebuild database from existing NFO files
- Webhook processing: Cache webhook dates in database immediately

Expected performance: Manual scans now use 3-tier optimization
2025-10-10 16:18:34 -04:00
sbcrumb 88b75230a7 Bump version to 2.0.21 to resolve merge conflict with dev branch
Local Docker Build (Dev) / build-dev (pull_request) Successful in 4s
2025-10-10 15:30:06 -04:00
sbcrumb 035f2f6e02 Optimize TV processor performance with database-first episode lookup
Major performance improvement for manual scans:
- Check NFOGuard database before making Sonarr API calls
- Only query Sonarr history for episodes missing from database
- Filter Sonarr episode processing to only needed episodes
- Add detailed logging for cache hits vs API calls

Expected improvement: 172 API calls -> 0-10 API calls for typical scans
2025-10-10 15:30:06 -04:00
sbcrumb d6c1b73959 Fix rename webhook targeting using episodeId lookup
Found that rename events contain episodeId field which can be used to fetch specific episode details. Replaced complex episode data extraction with direct API call to /api/v3/episode/{episodeId} to get season/episode numbers for targeted processing.

This should resolve rename webhooks processing entire series instead of single episodes.
2025-10-10 14:17:05 -04:00
sbcrumb e03249bb36 Add comprehensive rename event debugging
Local Docker Build (Dev) / build-dev (pull_request) Successful in 4s
Enhanced debugging for Sonarr rename events to understand the actual structure of episodeFileRenamed history records. Added checks for episode data in multiple possible locations (episode, episodeFile, data objects) to identify why season/episode information is missing.

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-10-10 14:11:07 -04:00
sbcrumb a5eb23e886 fix: Improve Sonarr history API query for rename events
- Remove invalid eventType parameter that was causing 400 error
- Fetch recent history and filter client-side for episodeFileRenamed events
- Add better datetime parsing for event filtering
- Increase page size to 50 to catch more recent events
2025-10-10 14:03:40 -04:00
sbcrumb 4dff85c5c9 fix: Use environment variable directly for Sonarr API key
Local Docker Build (Dev) / build-dev (pull_request) Successful in 4s
- Changed from config.sonarr_api_key to os.environ.get('SONARR_API_KEY', '')
- Matches pattern used in tv_processor.py for Sonarr API access
2025-10-10 11:17:02 -04:00
sbcrumb 0e24f74dcb fix: Correct config attribute name for Sonarr URL in rename webhook handler
Local Docker Build (Dev) / build-dev (pull_request) Successful in 4s
- Changed config.sonarr_base_url to config.sonarr_url to match actual config object
- Fixes AttributeError that was preventing rename webhook targeting from working
2025-10-10 11:02:53 -04:00
sbcrumb 3d0dae995a fix: Add targeted mode for rename webhooks using Sonarr history API
- Rename webhooks don't include episodeFile data from Sonarr
- Added fallback to query recent episodeFileRenamed events from history
- Uses 1-hour window to find most recent rename for targeted processing
- Prevents full series processing on single episode renames
2025-10-10 10:40:16 -04:00
sbcrumb 5cc7281f06 bump: Version 2.0.13 for rename webhook debug logging
Local Docker Build (Dev) / build-dev (pull_request) Successful in 3s
2025-10-10 10:30:31 -04:00
sbcrumb 3787ca2d23 Fix all Sonarr webhooks: Force targeted processing for single episodes
Local Docker Build (Dev) / build-dev (pull_request) Successful in 3s
- Extend episodeFile extraction to ALL webhook types (Download, Rename, Upgrade)
- Force targeted mode when episodes_data has ≤3 episodes to prevent full series processing
- Add debug logging to track episode extraction and processing mode decisions
- Prevents processing 177 episodes when only 1-3 episodes are involved
- Applies to imports, renames, and upgrades - not just renames
- Version bump to 2.0.12

This ensures that single episode operations (most common) only process the specific
episode(s) involved instead of scanning the entire series.
2025-10-09 18:11:47 -04:00
sbcrumb e897656396 Fix TV rename webhooks: Implement targeted episode processing
- Extract episode info from episodeFile when webhook.episodes is empty for rename events
- Create proper episode data structure for process_webhook_episodes method
- Prevents full series processing (177 episodes) for single episode renames
- Dramatically improves performance for rename operations
- Version bump to 2.0.11

Resolves issue where rename webhooks were falling back to full series processing instead of targeted mode.
2025-10-09 18:10:11 -04:00
sbcrumb ed78a81a8e Fix TV webhook processing: Add missing process_webhook_episodes method
- Add process_webhook_episodes method to TVProcessor class for targeted episode processing
- Implement helper methods: _parse_episode_from_filename, _get_sonarr_series_metadata, _get_episode_metadata, _extract_title_from_filename, _get_webhook_episode_date
- Enables webhook-based episode processing with title extraction and metadata handling
- Resolves 'TVProcessor' object has no attribute 'process_webhook_episodes' error
- Version bump to 2.0.10
2025-10-09 18:04:19 -04:00
sbcrumb 5ade28c118 fix: Only fallback to airdate when Sonarr has no import date
Local Docker Build (Dev) / build-dev (pull_request) Successful in 23s
- Modified fallback logic to only use airdate as dateadded when source is NOT 'sonarr:history.import'
- This prevents using airdate fallback when Sonarr has valid import dates available
- Ensures Sonarr import dates are prioritized over airdate fallbacks
- Addresses issue where episodes with valid Sonarr import dates were still falling back to airdates
2025-10-05 10:42:35 -04:00
sbcrumb 191e6f5f3f fix: Use Sonarr import history for TV episode date detection
- Modified _get_sonarr_episodes to call get_episode_import_history() for each episode
- This retrieves actual import dates from Sonarr's history API instead of just episodeFile.dateAdded
- Added fallback to episodeFile.dateAdded if history lookup fails
- Updated source tracking to use 'sonarr:history.import' for better debugging
- Added debug logging to show which method found the import date
- Should resolve issue where episodes fall back to aired dates despite valid Sonarr imports
2025-10-05 10:29:13 -04:00
sbcrumb 0980ba0761 Fix TV processing issues: correct method names and add missing episode air date method
Local Docker Build (Dev) / build-dev (pull_request) Successful in 24s
- Fix SonarrClient method call from get_series_by_imdb to series_by_imdb
- Fix SonarrClient method call from get_episodes to episodes_for_series
- Add missing get_episode_air_date method to ExternalClientManager
- Method uses TMDB and OMDb APIs to fetch episode air dates
- Version bump to 2.0.7
2025-10-04 11:41:35 -04:00
sbcrumb acf741e6bb Add missing psutil dependency to complete requirements
Local Docker Build (Dev) / build-dev (pull_request) Successful in 34s
- Add psutil==5.9.6 for monitoring metrics functionality
- Container confirmed: manage_nfo=True (NFO creation enabled)
- All external dependencies now included in requirements.txt
- Version bump to 2.0.6 for complete dependency resolution
2025-10-04 11:12:23 -04:00
sbcrumb 17aec56952 Add missing aiohttp dependency to requirements.txt
Local Docker Build (Dev) / build-dev (pull_request) Successful in 24s
- Add aiohttp==3.8.6 to fix ModuleNotFoundError in runtime_validator
- Container now shows config: manage_nfo=True (confirms NFO creation enabled)
- Version bump to 2.0.5
2025-10-04 11:08:58 -04:00
sbcrumb d0e4182d38 Fix missing Tuple import in async_nfo_manager.py
Local Docker Build (Dev) / build-dev (pull_request) Successful in 24s
- Add Tuple to typing imports to resolve NameError
- Fixes container startup failure after modular refactoring
- Version bump to 2.0.4
2025-10-04 11:06:07 -04:00
sbcrumb 08ff77760b Resolve VERSION conflict: keep 2.0.3 for Docker fixes
Local Docker Build (Dev) / build-dev (pull_request) Successful in 23s
2025-10-04 11:04:27 -04:00
sbcrumb 4c2ebae4dc Fix Docker entrypoint to use modular main.py instead of monolithic nfoguard.py
Local Docker Build (Dev) / build-dev (pull_request) Successful in 24s
- Update Dockerfile to exec main.py instead of deleted nfoguard.py
- Fixes container startup failure after monolithic code removal
- Version bump to 2.0.3 for Docker compatibility fix
2025-10-04 11:01:56 -04:00