Commit Graph

84 Commits

Author SHA1 Message Date
sbcrumb 6c353dcaf8 db: debug
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-18 09:32:42 -04:00
sbcrumb cb18c358c6 db: more sb improvments
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-18 09:27:15 -04:00
sbcrumb 762031d3f3 db: update
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-18 09:07:45 -04:00
sbcrumb 95945f7189 db improvments
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-17 21:18:37 -04:00
sbcrumb d552d97440 db: insert tables
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-17 21:09:42 -04:00
sbcrumb 5630022f6e fix: db creation
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-17 21:07:22 -04:00
sbcrumb e89cbca125 feat:update to postgress over sqllite
Local Docker Build (Dev) / build-dev (push) Successful in 3s
2025-10-17 20:47:25 -04:00
sbcrumb 87930efb79 fix: tier levels not working as well as an option to ignore the .nfo file and query
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-17 10:16:12 -04:00
sbcrumb 9f05e4cb92 web: performance improvments
Local Docker Build (Dev) / build-dev (push) Successful in 4s
2025-10-15 10:42:38 -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 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 c8fde41dfb fix: Ensure NFOGuard metadata appears at bottom of movie NFO files
Local Docker Build (Dev) / build-dev (push) Successful in 4s
- Improve element removal logic to only remove clearly NFOGuard-managed elements
- Use batch element addition to ensure NFOGuard metadata appears as contiguous block at bottom
- Better preserve existing non-NFOGuard metadata fields
- Fix issue where lockdata/dateadded appeared scattered throughout NFO instead of grouped at bottom

🤖 Generated with [Claude Code](https://claude.ai/code)
2025-10-12 12:56:10 -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 348f83d547 feat: Add comprehensive IMDb detection for TV shows
Local Docker Build (Dev) / build-dev (pull_request) Successful in 4s
- Add find_series_imdb_id method to check directory, filenames, and tvshow.nfo
- Add TV show batch validation in webhook batcher (like movies)
- Ensures TV webhooks process correct series by validating IMDb match
- Prevents mismatched processing like Girls (2012) -> Gachiakuta (2025)
- Comprehensive detection checks: folder name, file names, NFO content
2025-10-12 10:46:43 -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 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 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 82eb29fd63 feat: implement comprehensive async I/O capabilities
Local Docker Build (Dev) / build-dev (pull_request) Successful in 20s
- Add utils/async_file_utils.py with aiofiles-based operations
- Create core/async_nfo_manager.py for concurrent NFO processing
- Add async methods to TVProcessor for concurrent episode handling
- Implement async_find_episodes_on_disk() for faster scanning
- Add async_batch_create_episode_nfos() for concurrent NFO creation
- Support async_process_multiple_series() for parallel processing
- Optimize I/O performance for large media libraries
- Enable controlled concurrency with semaphores and rate limiting

Performance improvements:
- Concurrent file operations reduce I/O wait times
- Batch processing minimizes individual file access overhead
- Configurable concurrency limits prevent system overload
- Async directory scanning for faster episode discovery
2025-09-27 13:17:54 -04:00
sbcrumb fc80c08041 tuple update
Local Docker Build (Dev) / build-dev (push) Successful in 23s
2025-09-26 15:21:45 -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 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 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 a8f8e0a7bd Fix movie webhook processing and organize NFOGuard fields
Local Docker Build (Dev) / build-dev (push) Successful in 34s
- Fix WebhookBatcher missing nfo_manager attribute that caused movie processing errors
- Move NFOGuard comment from top to bottom of episode NFOs with other NFOGuard fields
- All NFOGuard additions now grouped together at bottom for better organization

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-25 13:11:23 -04:00
sbcrumb 6a20337181 fix: Improve title detection logic to prevent duplicates
Local Docker Build (Dev) / build-dev (push) Successful in 26s
- Fix flawed title detection that caused duplicates when migrating NFOs
- Add robust title validation (check for non-empty, non-whitespace text)
- Improve debugging output to show title detection process
- Properly handle existing valid titles vs missing/empty titles
- Remove invalid title elements before adding filename-extracted titles

Resolves duplicate <title> elements in NFO files during migration.
2025-09-25 10:33:03 -04:00
sbcrumb f1420cac58 fix: Add title extraction directly to create_episode_nfo method
Local Docker Build (Dev) / build-dev (push) Successful in 19s
- Add _extract_title_from_filename method to NFOManager class
- Integrate title extraction fallback in create_episode_nfo method
- Extract titles when NFO lacks title element or has empty title
- Support both .mkv and .mp4 files with comprehensive logging
- Fix applied to actual NFO creation method being used by episodes

Resolves title extraction by working in the correct code path
rather than relying on metadata processing that wasn't being called.
2025-09-25 09:40:26 -04:00
sbcrumb a1921936f7 fix: Add title enhancement for existing NFO files
- Modify extract_nfoguard_dates_from_episode_nfo() to detect missing titles
- Add enhance_existing_episode_nfo_with_title() method to update NFOs with titles
- Enhance Tier 1 processing to check for missing titles in existing NFO files
- Extract titles from filenames and update existing NFOs that lack title elements
- Fix NFO filename case to match S01E01.nfo format
- Preserves all existing NFO content while adding missing title elements

Addresses issue where existing NFO files with NFOGuard metadata were
skipping title extraction due to Tier 1 optimization caching.
2025-09-25 09:01:04 -04:00
sbcrumb 27430a7ead fix: nfo
Local Docker Build (Dev) / build-dev (pull_request) Successful in 23s
2025-09-24 19:35:39 -04:00
sbcrumb 210af8ac4b tv-nfo (#4)
Local Docker Build (Dev) / build-dev (push) Successful in 23s
Reviewed-on: #4
Co-authored-by: SBCrumb <sbcrumb@kickthetree.com>
Co-committed-by: SBCrumb <sbcrumb@kickthetree.com>
2025-09-24 18:53:48 -04:00
sbcrumb 830c1d9ae4 fix: Use tolerant XML parser for TMDB ID detection in NFO files
Local Docker Build (Dev) / build-dev (push) Successful in 20s
- Replace ET.parse() with _parse_nfo_with_tolerance() in parse_imdb_from_nfo
- Handles NFO files with URLs appended after </movie> tag
- Should resolve For the One (2024) TMDB ID detection issue
- NFO had TMDB ID 1339758 but trailing URLs prevented XML parsing
2025-09-24 13:53:52 -04:00
sbcrumb bfdf02ebd1 fix: Improve TMDB fallback detection and logging for movies without IMDb IDs
Local Docker Build (Dev) / build-dev (push) Successful in 21s
- Update find_movie_imdb_id to properly log TMDB vs IMDb ID detection
- Fix error message to indicate search for both IMDb AND TMDB IDs
- Add critical workflow reminder to SUMMARY.md for code-only development
- Should resolve For the One (2024) processing with TMDB ID 1339758
2025-09-24 13:49:54 -04:00
sbcrumb 994f430d45 feat: Implement comprehensive three-tier optimization system for movies and TV episodes
Local Docker Build (Dev) / build-dev (push) Successful in 24s
- Add NFO file extraction for TV episodes with dateadded detection
- Extend three-tier optimization (NFO cache, DB cache, full processing) to TV episodes
- Add TMDB ID fallback support for movies without IMDb IDs
- Implement Tier 1.5 processing for TMDB-only movies using premiered dates
- Update documentation with complete TV episode optimization details
- Add database rebuild capabilities for both movies and TV content
- Performance improvements eliminate 90%+ of processing time on warm systems
2025-09-24 13:37:01 -04:00
sbcrumb ea661bcd45 feat: Add TMDB ID detection for movies without IMDb IDs
Local Docker Build (Dev) / build-dev (push) Successful in 23s
Added fallback detection for movies that only have TMDB IDs in NFO files.
When no IMDb ID is found, the system now:

- Detects TMDB ID from <uniqueid type="tmdb"> elements
- Logs a helpful warning with the TMDB ID for manual lookup
- Provides clear guidance that manual IMDb lookup may be needed

This helps identify movies like "For the One (2024)" that have TMDB data
but are missing IMDb identifiers, allowing users to manually add IMDb IDs
to directory names or filenames when available.

Future enhancement: Could implement TMDB->IMDb API conversion.
2025-09-24 12:36:16 -04:00
sbcrumb d6d24e8840 feat: Add three-tier optimization for TV episodes
Local Docker Build (Dev) / build-dev (push) Successful in 24s
Extended the revolutionary three-tier performance system to TV episodes:

TIER 1 (Fastest): Episode NFO File Check
- Detects existing NFOGuard data in episode NFO files (dateadded + lockdata)
- Skips all database queries AND Sonarr API calls
- Perfect for database rebuilds from existing episode NFO files

TIER 2 (Fast): Episode Database Check
- Uses complete episode database entries when available
- Skips expensive Sonarr API calls for series/episode metadata
- Creates NFO from cached data only

TIER 3 (Normal): Full Episode Processing
- Only when neither NFO nor database have data
- Queries Sonarr APIs, processes dates, enhanced metadata

TV shows now benefit from same performance improvements as movies:
- Database rebuilds from existing NFO files (instant)
- Subsequent scans 90%+ faster for processed episodes
- Large TV libraries process efficiently with intelligent caching

This completes the performance optimization system across all media types.
2025-09-24 11:29:20 -04:00
sbcrumb 3889d3a31c feat: Add three-tier optimization for maximum performance
Local Docker Build (Dev) / build-dev (push) Successful in 19s
Implemented smart caching system that dramatically reduces processing time:

TIER 1 (Fastest): NFO File Check
- If NFO already has NFOGuard dateadded + lockdata, use it directly
- Skips both database queries AND API calls
- Perfect for movies already processed by NFOGuard

TIER 2 (Fast): Database Check
- If database has complete dateadded data, use it
- Skips expensive API calls to TMDB/OMDB/Radarr
- Creates NFO from cached data

TIER 3 (Slowest): Full Processing
- Only when neither NFO nor database have data
- Queries all APIs, processes dates, saves to database

This should dramatically improve full scan performance, especially
on subsequent runs where most movies already have NFOGuard data.

Expected speedup: 90%+ reduction in processing time for warm scans.
2025-09-24 11:21:38 -04:00
sbcrumb 172a364e6e debug: Add IMDb ID detection logging and database-first optimization
Local Docker Build (Dev) / build-dev (push) Successful in 18s
Added comprehensive debugging for IMDb ID detection to identify issues
with directories that don't have IMDb IDs in folder names but do have
them in filenames (like Adulthood (2025) [tt26657977]).

Also added database-first optimization that skips expensive API calls
when we already have complete data in the database. This should:
- Speed up full rescans significantly
- Reduce unnecessary API calls to TMDB/OMDB/Radarr
- Keep database size appropriate by not re-querying known movies

This should resolve both the small database size issue and improve
performance for movies that already have valid dateadded entries.
2025-09-24 11:16:56 -04:00
sbcrumb ed03f23272 fix: Move NFOGuard comment to bottom with other fields
Local Docker Build (Dev) / build-dev (push) Successful in 24s
Moved the NFOGuard source comment from the top of the XML file to
just before our field additions at the bottom. This creates a clear
separation showing where NFOGuard's modifications begin.

Expected structure:
[existing rich metadata]
<!-- NFOGuard - Source: tmdb:digital -->
<uniqueid type="imdb" default="true">tt123</uniqueid>
<premiered>2024-08-20</premiered>
<dateadded>2024-08-20T00:00:00+00:00</dateadded>
<lockdata>true</lockdata>
2025-09-24 10:08:10 -04:00
sbcrumb fc3c190c1b fix: Ensure NFOGuard fields are appended at bottom of NFO files
Local Docker Build (Dev) / build-dev (push) Successful in 24s
Changed from ET.SubElement() to ET.Element() + explicit append() to
guarantee that NFOGuard-managed fields appear at the very bottom of
NFO files after all existing content.

This is critical because:
- Emby plugin specifically looks for dateadded field
- All NFOGuard fields should be grouped together at the bottom
- Preserves existing rich metadata while clearly marking our additions

Added debug logging for dateadded field to confirm it's being written.
2025-09-24 10:06:29 -04:00
sbcrumb 17914ff8f4 debug: Add NFO creation debugging for Inside Out 2 issue
Local Docker Build (Dev) / build-dev (push) Successful in 22s
Added debug logging to understand why rich existing NFO metadata
isn't being preserved when NFOGuard updates files.

This will show:
- Parameters passed to create_movie_nfo
- Whether existing premiered dates are being preserved
- Why NFOGuard fields aren't being added to the bottom

This should help diagnose why Inside Out 2 NFO isn't getting
NFOGuard's dateadded and lockdata fields appended.
2025-09-24 10:02:52 -04:00
sbcrumb c04fe8d083 debug optional 2025-09-22 12:18:40 -04:00
sbcrumb 3e5c80279f fix: nfo logic long vs shortname 2025-09-22 11:02:12 -04:00
sbcrumb de3896b8c3 fix: add debug for .nfo ussues 2025-09-22 10:54:22 -04:00
sbcrumb a74feeb67e udpates to flow and nfo manager for TV 2025-09-22 10:03:59 -04:00
sbcrumb f563c67405 update sonarr .nfo flow 2025-09-22 09:25:03 -04:00
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 532ea02a5b update to docker 2025-09-17 15:23:29 -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 1dae7df3d2 updates to paths again 2025-09-14 14:23:25 -04:00