From 87930efb7955ede900f8e6942b5350cd4af8dbf8 Mon Sep 17 00:00:00 2001 From: sbcrumb Date: Fri, 17 Oct 2025 10:16:12 -0400 Subject: [PATCH] fix: tier levels not working as well as an option to ignore the .nfo file and query --- .env.template | 5 +++++ VERSION | 2 +- config/settings.py | 6 +++++- core/nfo_manager.py | 5 ++++- processors/movie_processor.py | 18 ++++++++++++++++-- 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/.env.template b/.env.template index 1a449f0..189dc67 100644 --- a/.env.template +++ b/.env.template @@ -93,6 +93,11 @@ UPDATE_MODE=always # File modification time behavior (update, leave_alone) MTIME_BEHAVIOR=update +# Manual scan priority: use existing NFO dates for speed vs check APIs for accuracy +# false (default) = Check external APIs first, use NFO as fallback (slower but accurate) +# true = Use NFO dates immediately without API checks (faster but may use wrong dates) +MANUAL_SCAN_PRIORITIZE_NFO=false + # =========================================== # PERFORMANCE & BATCHING # =========================================== diff --git a/VERSION b/VERSION index 2f09892..8389c48 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2.23 +2.2.24 diff --git a/config/settings.py b/config/settings.py index 34b6eb5..6a0798b 100644 --- a/config/settings.py +++ b/config/settings.py @@ -129,6 +129,9 @@ class NFOGuardConfig: self.prefer_release_dates_over_file_dates = _bool_env("PREFER_RELEASE_DATES_OVER_FILE_DATES", True) self.allow_file_date_fallback = _bool_env("ALLOW_FILE_DATE_FALLBACK", False) + # Manual scan behavior + self.manual_scan_prioritize_nfo = _bool_env("MANUAL_SCAN_PRIORITIZE_NFO", False) + # Release date settings release_priority_env = os.environ.get("RELEASE_DATE_PRIORITY", "digital,physical,theatrical") self.release_date_priority = [p.strip() for p in release_priority_env.split(",") if p.strip()] @@ -238,7 +241,8 @@ class NFOGuardConfig: "manage_nfo": self.manage_nfo, "fix_dir_mtimes": self.fix_dir_mtimes, "lock_metadata": self.lock_metadata, - "debug": self.debug + "debug": self.debug, + "manual_scan_prioritize_nfo": self.manual_scan_prioritize_nfo } } diff --git a/core/nfo_manager.py b/core/nfo_manager.py index 0951d1e..868cd5b 100644 --- a/core/nfo_manager.py +++ b/core/nfo_manager.py @@ -743,8 +743,11 @@ class NFOManager: dt = datetime.fromisoformat(iso_timestamp.replace('Z', '+00:00')) elif '+' in iso_timestamp or 'T' in iso_timestamp: dt = datetime.fromisoformat(iso_timestamp) + elif ' ' in iso_timestamp: + # Handle space-separated datetime format (e.g., "2025-10-16 20:31:22") + dt = datetime.fromisoformat(iso_timestamp.replace(' ', 'T')) else: - # Assume it's already a simple date + # Assume it's a simple date (e.g., "2025-10-16") dt = datetime.fromisoformat(iso_timestamp + 'T00:00:00') # Convert to timestamp diff --git a/processors/movie_processor.py b/processors/movie_processor.py index 3e82907..91c49d4 100644 --- a/processors/movie_processor.py +++ b/processors/movie_processor.py @@ -172,9 +172,11 @@ class MovieProcessor: return # TIER 2.5: Check for any existing valid date data in NFO (even without lockdata marker) + # Only use NFO dates if prioritize_nfo is enabled, otherwise check external APIs first existing_nfo_data = self._extract_any_valid_dates_from_nfo(nfo_path) - if existing_nfo_data: + if existing_nfo_data and config.manual_scan_prioritize_nfo: _log("INFO", f"🔍 TIER 2.5 - Found existing date data in NFO (no lockdata): {existing_nfo_data['dateadded']} (source: {existing_nfo_data['source']})") + _log("INFO", f"⚡ MANUAL_SCAN_PRIORITIZE_NFO=True - Using NFO date for speed") dateadded = existing_nfo_data["dateadded"] source = existing_nfo_data["source"] released = existing_nfo_data.get("released") @@ -197,6 +199,11 @@ class MovieProcessor: _log("INFO", f"Completed processing movie: {movie_path.name} (source: {source}) [existing-nfo-enhanced]") return + elif existing_nfo_data: + _log("INFO", f"🔍 TIER 2.5 - Found existing date data in NFO (no lockdata): {existing_nfo_data['dateadded']} (source: {existing_nfo_data['source']})") + _log("INFO", f"🎯 MANUAL_SCAN_PRIORITIZE_NFO=False - Will verify against external APIs first") + # Store NFO data as fallback but continue to TIER 3 to check external APIs + nfo_fallback_data = existing_nfo_data # TIER 1.5: Special handling for TMDB-only movies - extract dates from existing NFO if is_tmdb_fallback: @@ -235,7 +242,9 @@ class MovieProcessor: _log("DEBUG", f"Movie {imdb_id}: should_query={should_query}, poll_mode={config.movie_poll_mode}") # Use existing movie date decision logic - dateadded, source, released = self._decide_movie_dates(imdb_id, movie_path, should_query, None) + # Pass NFO fallback data if available for cases where external APIs don't have import history + nfo_fallback = locals().get('nfo_fallback_data', None) + dateadded, source, released = self._decide_movie_dates(imdb_id, movie_path, should_query, nfo_fallback) # Webhook fallback: if ALL date sources fail, use current timestamp if webhook_mode and dateadded is None: @@ -465,6 +474,11 @@ class MovieProcessor: local_import_date = convert_utc_to_local(import_date) return local_import_date, import_source, released + # Last resort: check if we have NFO fallback data (when external APIs don't have import history) + if existing and existing.get('dateadded'): + _log("INFO", f"✅ Movie {imdb_id}: External APIs don't have import history, using NFO fallback date: {existing['dateadded']} (source: {existing['source']})") + return existing["dateadded"], f"nfo_fallback:{existing['source']}", existing.get("released") + # Last resort: file mtime (if allowed) if config.allow_file_date_fallback: return self._get_file_mtime_date(movie_path)