Commit Graph

188 Commits

Author SHA1 Message Date
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
sbcrumb 72614af928 Remove monolithic nfoguard.py and add comprehensive debug logging
- Remove 2467-line monolithic nfoguard.py file to prevent confusion
- Add debug prints to identify why NFO metadata isn't being added
- Track config.manage_nfo values and function calls
- Debug dateadded parameter passing through all tiers
- Update version to 2.0.2
- This will help identify if manage_nfo is disabled or function not called
2025-10-04 11:00:21 -04:00
sbcrumb 863019f42a Remove monolithic nfoguard.py and add comprehensive debug logging
Local Docker Build (Dev) / build-dev (pull_request) Successful in 24s
- Remove 2467-line monolithic nfoguard.py file to prevent confusion
- Add debug prints to identify why NFO metadata isn't being added
- Track config.manage_nfo values and function calls
- Debug dateadded parameter passing through all tiers
- This will help identify if manage_nfo is disabled or function not called

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-10-04 10:57:50 -04:00
sbcrumb 9f86b02665 fix: fixing webhook processing
Local Docker Build (Dev) / build-dev (pull_request) Successful in 19s
2025-10-02 16:31:07 -04:00
sbcrumb 09612aeb4e version: Update to 2.0.0 for major architecture and code quality improvements
Local Docker Build (Dev) / build-dev (push) Successful in 17s
- Bump version to 2.0.0 to reflect major changes
- Represents completion of modular architecture transformation
- Includes comprehensive code quality improvements (Phase 3)
- All new utility modules and error handling systems
- Breaking changes: modular structure, new import paths
2025-09-27 13:09:46 -04:00
sbcrumb ce1a599fd9 stop tvshow.nfo and show.nfo
Local Docker Build (Dev) / build-dev (push) Successful in 28s
Local Docker Build (Main) / build (pull_request) Successful in 24s
Local Docker Build (Main) / deploy (pull_request) Has been skipped
2025-09-26 17:07:12 -04:00
sbcrumb 3826895275 title search
Local Docker Build (Dev) / build-dev (push) Successful in 28s
2025-09-26 16:59:12 -04:00
sbcrumb d2ad048f61 tv update again
Local Docker Build (Dev) / build-dev (push) Successful in 28s
2025-09-26 16:49:57 -04:00
sbcrumb 3d7460ad76 verixon update
Local Docker Build (Dev) / build-dev (push) Successful in 33s
2025-09-26 16:25:08 -04:00
sbcrumb 806370bd5f airdate fallback
Local Docker Build (Dev) / build-dev (push) Successful in 29s
2025-09-26 15:56:40 -04:00
sbcrumb 2c4dd274ff retry for the AI
Local Docker Build (Dev) / build-dev (push) Successful in 16s
2025-09-26 15:19:37 -04:00
sbcrumb b9e3ae3a5e debug: Add extensive logging for episode detection
Local Docker Build (Dev) / build-dev (push) Successful in 29s
Added detailed debug logging to diagnose why High Potential shows "0 episodes" despite having video files:

- Log season directory detection and pattern matching
- Log video file scanning and episode filename parsing
- Log season number extraction and matching logic
- Log final episode count and processing decisions

This will help identify where the episode detection is failing in the pipeline.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 14:37:41 -04:00
sbcrumb 4d30ea840f fix: Add Sonarr direct lookup fallback for reliable series detection
Local Docker Build (Dev) / build-dev (push) Successful in 19s
The /series/lookup endpoint sometimes fails to find series that exist in Sonarr. Added fallback to series_by_imdb_direct() method which scans all series directly.

Changes:
- Try Sonarr lookup endpoint first (fast)
- Fall back to direct series scan if lookup fails (slower but more reliable)
- Apply same logic to both episode dates and metadata methods
- Version bump to 2.0.5-sonarr-direct-lookup

This should find High Potential, Breaking Bad, and other series that exist in Sonarr but weren't found via the lookup endpoint.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 14:14:40 -04:00
sbcrumb 27677e49f8 fix: External API fallback flow and conditional NFO creation
Local Docker Build (Dev) / build-dev (push) Successful in 23s
Fixed two critical issues:
1. External API fallback was never reached because early returns when series/episodes not found in Sonarr
2. tvshow.nfo and season.nfo were always created even if they already existed

Changes:
- Restructured Sonarr lookup to fall through to external APIs when series/episodes not found
- Made tvshow.nfo and season.nfo creation conditional (only if files don't exist)
- Added debug logging for skipped NFO creation
- Version bump to 2.0.4-fallback-fix

Now series like High Potential should properly fall back to TMDB/OMDb for episode airdates.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 14:12:18 -04:00
sbcrumb 2e6d8a35e7 feat: Add external API fallback for TV episode airdates
Local Docker Build (Dev) / build-dev (push) Successful in 19s
When Sonarr lookup fails to find a series or episode data, the system now falls back to external APIs (TMDB, OMDb) to get episode air dates. This ensures episodes still get proper dateadded values even when not found in Sonarr.

Changes:
- Add ExternalClientManager integration to TVSeriesProcessor
- Implement _get_episode_airdate_from_external_apis method
- Support TMDB TV episode lookups with IMDb->TMDB ID conversion
- Support OMDb episode season lookups with date parsing
- Version bump to 2.0.3-external-fallback

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-26 13:56:57 -04:00
sbcrumb 12767d7350 fix: Remove invalid webhook_secret parameter from SonarrClient
Local Docker Build (Dev) / build-dev (push) Successful in 23s
SonarrClient constructor only accepts base_url and api_key parameters.
Version bump to 2.0.2-clean
2025-09-26 13:47:11 -04:00
sbcrumb 4411804725 fix: Sonarr client initialization error
Local Docker Build (Dev) / build-dev (push) Successful in 24s
Fix AttributeError for missing sonarr_url config attributes.
Use environment variables directly like the original code.
Version bump to 2.0.1-clean
2025-09-26 13:45:16 -04:00
sbcrumb b431107abd feat: Complete clean TV NFO processing implementation v2.0.0
Local Docker Build (Dev) / build-dev (push) Successful in 17s
- New EpisodeNFOManager class with video filename matching
- NFO files now match video filenames instead of S01E01.nfo format
- Clean TVSeriesProcessor with proper Sonarr API integration
- Proper date lookup: database -> Sonarr import history -> airdate fallback
- Updated manual scan endpoint to use new clean processor
- Removed all migration logic and nfo_migration_required sources

This is a complete rewrite of TV episode processing with focus on:
1. NFO filenames matching video files
2. Proper dateadded field population from Sonarr
3. Clean separation of concerns
4. Robust fallback logic
2025-09-26 13:39:41 -04:00
sbcrumb 9b0da8b6ed fix: Remove nfo_migration_required source and ensure proper date lookup
Local Docker Build (Dev) / build-dev (push) Successful in 49s
- Remove bogus 'nfo_migration_required' source that bypassed proper date lookup
- Ensure episodes with existing NFOs still get processed through Sonarr API
- Episodes should get proper dateadded from Sonarr import history or airdate fallback
- Version bump to 1.9.3-longnames
2025-09-26 10:11:52 -04:00
sbcrumb 9bc8955ad4 fix: Preserve and convert NFO filenames to match video files
Local Docker Build (Dev) / build-dev (push) Successful in 23s
- Preserve existing long-named NFO files instead of migrating to short names
- Convert existing short NFO names (S01E01.nfo) to match video filenames
- Create new NFOs with long names based on matching video files
- Only fallback to short names if no matching video file exists
2025-09-26 09:56:23 -04:00
sbcrumb f515d70241 version: Update version to 1.9.1 o push to github
Local Docker Build (Dev) / build-dev (push) Successful in 24s
Local Docker Build (Main) / build (pull_request) Successful in 1m1s
Local Docker Build (Main) / deploy (pull_request) Has been skipped
2025-09-25 14:38:17 -04:00
sbcrumb 2b6fd27913 Fix movie webhook comprehensive IMDb detection and batch processing
Local Docker Build (Dev) / build-dev (push) Successful in 28s
Local Docker Build (Main) / build (pull_request) Successful in 24s
Local Docker Build (Main) / deploy (pull_request) Has been skipped
- Fix movie webhook to use comprehensive IMDb detection (dir, filename, movie.nfo) instead of simple string search
- Fix batch processing NameError: use path_obj instead of undefined path variable
- Version bump to 1.8.3

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 13:31:27 -04:00
sbcrumb b4fe0cb7fe bump: Version 1.8.2 with title extraction functionality
Local Docker Build (Dev) / build-dev (push) Successful in 28s
2025-09-25 09:26:09 -04:00
sbcrumb c9567ce70b update: update version number 2025-09-25 09:15:07 -04:00
sbcrumb 0bd7c3f883 bump: Update VERSION to 1.8.0 for major release
Local Docker Build (Dev) / build-dev (push) Successful in 28s
Comprehensive three-tier optimization system with international fallback support
2025-09-24 14:18:21 -04:00
sbcrumb 99ffc08c9b feat: Add version-specific dev tags for easier identification
Local Docker Build (Dev) / build-dev (push) Successful in 24s
- Bump version to 1.7.0 for NFO release date fix
- Add version-dev-gitea tag format (e.g. 1.7.0-dev-gitea)
- Push version tag to Gitea registry alongside dev tag
- Update build output to show clear pull command

This makes it easy to identify which dev build you're running
and ensures you get the latest Gitea dev build with the NFO fixes.
2025-09-24 08:38:22 -04:00
sbcrumb c04fe8d083 debug optional 2025-09-22 12:18:40 -04:00