Commit Graph

310 Commits

Author SHA1 Message Date
sbcrumb e502c3625b fix: Resolve isinstance() TypeError and undefined variable errors
Local Docker Build (Dev) / build-dev (push) Successful in 29s
Fixed two critical bugs in NFO processing:

1. isinstance() TypeError: Fixed XML comment detection in update_episode_nfo_preserving_name
   - ET.Comment is not a proper type for isinstance()
   - Added safer comment detection using type checking and string matching

2. Undefined variable: Fixed episode_filename reference in create_episode_nfo
   - Variable only defined in fallback case but referenced in all cases
   - Changed to use nfo_path.name which is always available

These fixes resolve the errors preventing NFO file updates for existing
long-named NFO files.
2025-09-26 08:52:26 -04:00
sbcrumb 5810877489 feat: Complete elimination of short NFO names - always match video filenames
Local Docker Build (Dev) / build-dev (push) Successful in 33s
- Added logic to actively delete existing S01E01.nfo short-name files
- Modified fallback creation to always match video file names
- Added find_video_file_for_episode() to locate matching video files
- NFO files will now ALWAYS have the same name as their video files
- No more S01E01.nfo format ever created, addressing Emby compatibility issues

This ensures complete consistency between NFO and video file naming,
which should resolve Emby metadata reading issues.
2025-09-26 08:35:54 -04:00
sbcrumb b63c188813 chore: Bump version to 1.9.3 with NFO preservation fix
Local Docker Build (Dev) / build-dev (push) Successful in 24s
2025-09-26 08:28:48 -04:00
sbcrumb 16bcf89ddd fix: Replace NFO migration logic with preservation logic in create_episode_nfo
The core issue was that create_episode_nfo() method was still using the old
migration logic that renamed long NFO files to S01E01.nfo format.

Changes:
- Modified create_episode_nfo() to check for video-matching NFO files first
- Update existing NFO files in-place while preserving original filenames
- Removed old migration and cleanup logic that deleted original files
- Added clear logging to distinguish preservation vs standard creation

This ensures TV episode NFO files keep their original long names that
match the video files exactly, while still getting NFOGuard metadata.
2025-09-26 08:28:39 -04:00
sbcrumb 0b17ee54fd chore: Bump version to 1.9.2 to verify new NFO preservation code deployment
Local Docker Build (Dev) / build-dev (push) Successful in 24s
2025-09-26 08:23:44 -04:00
sbcrumb 4980d1ae04 feat: Preserve TV episode NFO filenames matching video files
Local Docker Build (Dev) / build-dev (push) Successful in 29s
Instead of migrating long NFO names to standardized S01E01.nfo format,
now preserves original filenames that match video files while still
populating NFOGuard metadata (dateadded, aired, season, episode).

Changes:
- Added update_episode_nfo_preserving_name() method to NFOManager
- Added find_episode_nfo_matching_video() to locate NFO files by video name pattern
- Modified TVProcessor to update existing NFOs in-place rather than migrate names
- Episodes with existing NFOs now get "nfo_update_required" source for special handling

This maintains the user's preferred naming convention where NFO files
match their corresponding video files exactly.
2025-09-26 08:16:42 -04:00
sbcrumb 24d94306c1 fix: remove file lock
Local Docker Build (Dev) / build-dev (push) Successful in 18s
2025-09-25 19:12:37 -04:00
sbcrumb 94590ac070 feat:add file cache system
Local Docker Build (Dev) / build-dev (push) Successful in 15s
2025-09-25 18:58:31 -04:00
sbcrumb 714fceec98 another update
Local Docker Build (Dev) / build-dev (push) Successful in 28s
2025-09-25 18:51:21 -04:00
sbcrumb 70302837a7 huge: update
Local Docker Build (Dev) / build-dev (push) Successful in 28s
2025-09-25 18:41:37 -04:00
sbcrumb 740f912b57 state2
Local Docker Build (Dev) / build-dev (push) Successful in 23s
2025-09-25 18:04:15 -04:00
sbcrumb bcf428fbc0 update: add api routes
Local Docker Build (Dev) / build-dev (push) Successful in 27s
2025-09-25 15:47:50 -04:00
sbcrumb 5adc596077 refactor: Extract models, config, and main app setup
Local Docker Build (Dev) / build-dev (push) Successful in 33s
- Create modular directory structure
  - Extract Pydantic models to api/models.py
  - Move configuration to config/settings.py
  - Create clean main.py with FastAPI app setup

  WIP: Routes and processor classes still need extraction
2025-09-25 15:32:51 -04:00
sbcrumb a4c333aa85 Merge pull request 'version: Update version to 1.9.1 o push to github' (#13) from dev into main
Local Docker Build (Main) / build (push) Successful in 19s
Local Docker Build (Main) / deploy (push) Successful in 0s
Local Docker Build (Dev) / build-dev (push) Successful in 20s
Reviewed-on: #13
2025-09-25 14:39:07 -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 ade771f661 Merge branch 'dev'
Local Docker Build (Main) / build (push) Successful in 39s
Local Docker Build (Dev) / build-dev (push) Successful in 34s
Local Docker Build (Main) / deploy (push) Successful in 0s
2025-09-25 14:26:31 -04:00
sbcrumb 3e8ea79cbb update emby dll
Local Docker Build (Dev) / build-dev (push) Successful in 23s
Local Docker Build (Main) / build (pull_request) Successful in 24s
Local Docker Build (Main) / deploy (pull_request) Has been skipped
2025-09-25 14:23:28 -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 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 5e3d4845b0 fix: Use comprehensive IMDb detection for movie batch validation
Local Docker Build (Dev) / build-dev (push) Successful in 33s
- Replace simple string search with find_movie_imdb_id() method
- Check directory name, filenames, and NFO file content for IMDb ID
- Handle both full IMDb IDs (tt26394837) and number formats
- Add detailed logging for detected vs expected IMDb matching
- Fix validation failures when IMDb ID is in filename/NFO but not directory name

Resolves movie webhook processing failures when directory lacks IMDb ID
but files contain proper identification.
2025-09-25 10:38:27 -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 39c1e54922 debug: Add INFO log to track if _get_episode_metadata is called
Local Docker Build (Dev) / build-dev (push) Successful in 23s
2025-09-25 09:36:08 -04:00
sbcrumb e870474f07 debug: Change DEBUG logs to INFO to trace title extraction
Local Docker Build (Dev) / build-dev (push) Successful in 18s
2025-09-25 09:32:58 -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 fef99b9bfd Merge pull request 'titlename-fix' (#10) from titlename-fix into dev
Local Docker Build (Dev) / build-dev (push) Successful in 25s
Reviewed-on: #10
2025-09-25 09:15:07 -04:00
sbcrumb c9567ce70b update: update version number 2025-09-25 09:15:07 -04:00
sbcrumb ba488cdbea Merge pull request 'titlename-fix' (#9) from titlename-fix into dev
Local Docker Build (Dev) / build-dev (push) Successful in 33s
Reviewed-on: #9
2025-09-25 09:08:50 -04:00
sbcrumb c33a26460d debug: Add comprehensive debugging for title extraction
- Add detailed debug logging to _extract_title_from_filename() method
- Log file search, regex pattern matching, and title cleanup process
- Fix Tier 2 processing to call _get_episode_metadata() for title extraction
- Add debug logging to _get_episode_metadata() to trace execution flow
- Include both .mkv and .mp4 file checking with detailed logs

This should help identify why title extraction isn't working for
recreated NFO files and provide visibility into the extraction process.
2025-09-25 09:08:50 -04:00
sbcrumb 91031ba321 Merge pull request 'fix: Add title enhancement for existing NFO files' (#8) from titlename-fix into dev
Local Docker Build (Dev) / build-dev (push) Successful in 33s
Reviewed-on: #8
2025-09-25 09:01:04 -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 7131aa211c Merge pull request 'fix: Add filename-based title extraction for TV episodes' (#7) from titlename-fix into dev
Local Docker Build (Dev) / build-dev (push) Successful in 22s
Reviewed-on: #7
2025-09-25 08:54:51 -04:00
sbcrumb 16d9956202 fix: Add filename-based title extraction for TV episodes
Local Docker Build (Dev) / build-dev (pull_request) Successful in 18s
- Add _extract_title_from_filename() method to extract episode titles from video filenames
- Enhance _get_episode_metadata() to use filename fallback when Sonarr API doesn't provide titles
- Update all _get_episode_metadata() calls to pass season directory for filename extraction
- Extract titles from patterns like: Series-S01E01-Episode Title[WEBDL-1080p][AAC2.0][h264].mkv
- Preserves existing Sonarr API behavior while providing fallback for missing titles
- Fixes episodes with missing <title> elements in NFO files when Sonarr data is incomplete

Resolves issue where episodes processed via sonarr:history.import had empty NFO titles
despite clear title information being available in the video filenames.
2025-09-25 08:53:56 -04:00
sbcrumb edaa92ef9a dev (#6)
Local Docker Build (Main) / build (push) Successful in 33s
Local Docker Build (Main) / deploy (push) Successful in 0s
Reviewed-on: #6
2025-09-24 20:06:45 -04:00
sbcrumb c21a0df9c1 Merge pull request 'fix: nfo' (#5) from nfofix into dev
Local Docker Build (Dev) / build-dev (push) Successful in 28s
Local Docker Build (Main) / build (pull_request) Successful in 23s
Local Docker Build (Main) / deploy (pull_request) Has been skipped
Reviewed-on: #5
2025-09-24 19:36:18 -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 ca2e77f4c7 remove .local
Local Docker Build (Dev) / build-dev (push) Successful in 17s
2025-09-24 15:14:40 -04:00
sbcrumb 70cc716cb8 remove .local
Local Docker Build (Main) / build (push) Successful in 24s
Local Docker Build (Main) / deploy (push) Successful in 0s
2025-09-24 15:14:18 -04:00
sbcrumb 18b6dad7ce Merge branch 'dev'
Local Docker Build (Main) / build (push) Successful in 23s
Local Docker Build (Main) / deploy (push) Successful in 0s
2025-09-24 15:11:24 -04:00
sbcrumb bd9ce8f48d feat: NFOGuard v1.8.0 - Comprehensive three-tier optimization system with international fallback
Local Docker Build (Main) / build (push) Successful in 19s
Local Docker Build (Main) / deploy (push) Successful in 0s
Major features and improvements:

🚀 THREE-TIER PERFORMANCE OPTIMIZATION:
- Tier 1: NFO file caching (99% faster, instant recovery)
- Tier 2: Database caching (90% faster, skip API calls)
- Tier 3: Full API processing (normal speed, only when needed)
- Extended to both movies AND TV episodes for complete coverage

🌍 INTERNATIONAL RELEASE DATE SUPPORT:
- Smart fallback hierarchy: US → English-speaking countries → any country
- Handles movies without US release dates (e.g., The Fabric of Christmas 2023)
- Prioritizes culturally relevant dates while ensuring comprehensive coverage

🎬 TMDB ID FALLBACK SYSTEM:
- Support for movies with TMDB IDs but no IMDb IDs (e.g., For the One 2024)
- Tolerant XML parsing handles NFO files with trailing URLs
- Extracts premiered dates from existing NFO files as fallback source

📊 ENHANCED DEBUGGING & MONITORING:
- Failed movies logged to logs/failed_movies.log for troubleshooting
- Comprehensive logging shows which optimization tier is used
- Enhanced IMDb/TMDB ID detection with detailed status messages

🔧 DATABASE REBUILD CAPABILITIES:
- Instant recovery from existing NFO files without API calls
- Perfect for migrations, disaster recovery, and system rebuilds
- Maintains performance even with thousands of movies/episodes

💾 SMART CACHING & NFO MANAGEMENT:
- NFOGuard fields properly positioned at bottom for Emby plugin compatibility
- Database-first optimization eliminates redundant API calls
- Intelligent should_query logic prevents unnecessary processing

Technical improvements include tolerant XML parsing, three-tier optimization for TV episodes, English-speaking country prioritization, TMDB fallback processing, failed movies debug logging, comprehensive database rebuild support, and performance optimizations eliminating 90%+ processing time on warm systems.
2025-09-24 14:19:31 -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 bd7538abbd feat: Add dedicated failed movies debug log
Local Docker Build (Dev) / build-dev (push) Successful in 24s
Local Docker Build (Main) / build (pull_request) Successful in 20s
Local Docker Build (Main) / deploy (pull_request) Has been skipped
- Create logs/failed_movies.log for movies with no_valid_date_source
- Logs movie name, IMDb ID, failure reason, and timestamp
- Helps users identify problematic movies needing manual attention
- Useful for debugging API issues and monitoring system health
- Documented in SUMMARY.md action items for troubleshooting workflow
2025-09-24 14:10:02 -04:00
sbcrumb aa9f9d9194 feat: Prioritize English-speaking countries in release date fallback
Local Docker Build (Dev) / build-dev (push) Successful in 26s
- Add two-tier international fallback: English-speaking first, then any country
- English-speaking countries: GB, CA, AU, NZ, IE
- For The Fabric of Christmas (2023): will try AU, CA before BE
- Maintains cultural relevance while ensuring comprehensive coverage
- Clear logging shows which tier is used for transparency
2025-09-24 14:06:11 -04:00
sbcrumb fc3bd67138 feat: Add international release date fallback for movies without US dates
Local Docker Build (Dev) / build-dev (push) Successful in 28s
- Add fallback logic to use any available country when US release dates unavailable
- Maintains same release type priority (Digital, Physical, Theatrical)
- Should resolve The Fabric of Christmas (2023) no_valid_date_source issue
- Logs which country is used as fallback for transparency
- Available countries for this movie: AU, BE, CA
2025-09-24 14:05:10 -04:00
sbcrumb f49b1632fd fix: Add missing ElementTree import and use tolerant XML parser
Local Docker Build (Dev) / build-dev (push) Successful in 24s
- Add missing xml.etree.ElementTree import to nfoguard.py
- Fix _extract_dates_from_tmdb_nfo to use tolerant XML parser
- Resolves 'name ET is not defined' error in TMDB fallback processing
- For the One (2024) should now process successfully with premiered date
2025-09-24 13:58:00 -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