From c1240964ee11e79dd8ed842ce9ccf813293094de Mon Sep 17 00:00:00 2001 From: sbcrumb Date: Mon, 20 Oct 2025 14:15:14 -0400 Subject: [PATCH] fix: turn off hard coded debug --- VERSION | 2 +- core/database.py | 13 ++++++++++--- core/nfo_manager.py | 12 ++++++++---- processors/movie_processor.py | 15 ++++++++++++--- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/VERSION b/VERSION index 338a5b5..e261122 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.6.6 +2.6.7 diff --git a/core/database.py b/core/database.py index f8dc57c..13238cb 100644 --- a/core/database.py +++ b/core/database.py @@ -29,6 +29,7 @@ class NFOGuardDatabase: self.db_name = config.db_name self.db_user = config.db_user self.db_password = config.db_password + self.db_type = "postgresql" # NFOGuard uses PostgreSQL self._local = threading.local() self._init_database() @@ -167,7 +168,9 @@ class NFOGuardDatabase: has_video_file = EXCLUDED.has_video_file, last_updated = EXCLUDED.last_updated """, (imdb_id, season, episode, aired, dateadded, source, has_video_file, timestamp)) - print(f"🔍 DEBUG: PostgreSQL upsert executed for {imdb_id} S{season:02d}E{episode:02d}, rows affected: {cursor.rowcount}") + import os + if os.environ.get("DEBUG", "false").lower() == "true": + print(f"🔍 DEBUG: PostgreSQL upsert executed for {imdb_id} S{season:02d}E{episode:02d}, rows affected: {cursor.rowcount}") def upsert_movie(self, imdb_id: str, path: str): """Insert or update movie record""" @@ -186,7 +189,9 @@ class NFOGuardDatabase: def upsert_movie_dates(self, imdb_id: str, released: Optional[str], dateadded: Optional[str], source: str, has_video_file: bool = False): """Insert or update movie date record""" - print(f"🔍 DATABASE UPSERT: imdb_id={imdb_id}, dateadded={dateadded}, source={source}") + import os + if os.environ.get("DEBUG", "false").lower() == "true": + print(f"🔍 DATABASE UPSERT: imdb_id={imdb_id}, dateadded={dateadded}, source={source}") with self.get_connection() as conn: cursor = conn.cursor() timestamp = datetime.utcnow() @@ -205,7 +210,9 @@ class NFOGuardDatabase: # Debug: Check what was actually saved cursor.execute("SELECT dateadded, source FROM movies WHERE imdb_id = %s", (imdb_id,)) result = cursor.fetchone() - print(f"🔍 DATABASE VERIFY: After upsert, found dateadded={result['dateadded'] if result else 'NOT_FOUND'}, source={result['source'] if result else 'NOT_FOUND'}") + import os + if os.environ.get("DEBUG", "false").lower() == "true": + print(f"🔍 DATABASE VERIFY: After upsert, found dateadded={result['dateadded'] if result else 'NOT_FOUND'}, source={result['source'] if result else 'NOT_FOUND'}") def get_series_episodes(self, imdb_id: str, has_video_file_only: bool = False) -> List[Dict]: """Get all episodes for a series""" diff --git a/core/nfo_manager.py b/core/nfo_manager.py index 462c805..b03507e 100644 --- a/core/nfo_manager.py +++ b/core/nfo_manager.py @@ -272,9 +272,12 @@ class NFOManager: """Create or update movie.nfo file preserving existing content""" nfo_path = movie_dir / "movie.nfo" - print(f"🔍 create_movie_nfo called: imdb_id={imdb_id}, dateadded={dateadded}, released={released}, source={source}") - print(f"🔍 NFO path: {nfo_path}") - print(f"🔍 NFO exists: {nfo_path.exists()}") + # Debug output only if DEBUG=true in environment + import os + if os.environ.get("DEBUG", "false").lower() == "true": + print(f"🔍 create_movie_nfo called: imdb_id={imdb_id}, dateadded={dateadded}, released={released}, source={source}") + print(f"🔍 NFO path: {nfo_path}") + print(f"🔍 NFO exists: {nfo_path.exists()}") try: # Try to load existing NFO file @@ -365,7 +368,8 @@ class NFOManager: pass # Skip year if we can't extract it # Add dateadded - THIS IS CRITICAL FOR EMBY PLUGIN - print(f"🔍 About to add dateadded: {dateadded} (type: {type(dateadded)})") + if os.environ.get("DEBUG", "false").lower() == "true": + print(f"🔍 About to add dateadded: {dateadded} (type: {type(dateadded)})") if dateadded: dateadded_elem = ET.Element("dateadded") dateadded_elem.text = dateadded diff --git a/processors/movie_processor.py b/processors/movie_processor.py index df4a00c..692acac 100644 --- a/processors/movie_processor.py +++ b/processors/movie_processor.py @@ -213,6 +213,12 @@ class MovieProcessor: _log("INFO", f"✅ TIER 1 - Using complete database data for {imdb_id}: {existing['dateadded']} (source: {existing['source']})") dateadded, source, released = existing["dateadded"], existing["source"], existing.get("released") + # Convert datetime objects to strings for NFO manager + if hasattr(dateadded, 'isoformat'): + dateadded = dateadded.isoformat() + if released and hasattr(released, 'isoformat'): + released = released.isoformat() + # Create NFO with existing data and update files if config.manage_nfo: self.nfo_manager.create_movie_nfo( @@ -351,14 +357,17 @@ class MovieProcessor: _log("INFO", f"Using release date as dateadded: {final_dateadded} (source: {final_source})") # Create NFO regardless of date availability (preserves existing metadata) - print(f"🔍 TIER3 - config.manage_nfo: {config.manage_nfo}") + if config.debug: + print(f"🔍 TIER3 - config.manage_nfo: {config.manage_nfo}") if config.manage_nfo: - print(f"🔍 TIER3 - Calling create_movie_nfo with final_dateadded: {final_dateadded}") + if config.debug: + print(f"🔍 TIER3 - Calling create_movie_nfo with final_dateadded: {final_dateadded}") self.nfo_manager.create_movie_nfo( movie_path, imdb_id, final_dateadded, released, final_source, config.lock_metadata ) else: - print(f"❌ TIER3 - manage_nfo is disabled, skipping NFO creation") + if config.debug: + print(f"❌ TIER3 - manage_nfo is disabled, skipping NFO creation") # Skip remaining processing if no valid date found and file dates disabled if final_dateadded is None: