From 3ccf062267bebd259b4fbc1229ac742ff5744ebc Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Tue, 4 Nov 2025 09:23:06 -0500 Subject: [PATCH] update to skip files --- VERSION | 2 +- core/database.py | 63 +++++++++++++++++++++++++++++++++++++- core/database_populator.py | 18 +++++++++-- 3 files changed, 78 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index e3278e3..053246b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.10.0-skipped-imdb-edit-v4 +2.10.0-skipped-imdb-edit-v5 diff --git a/core/database.py b/core/database.py index ea3cd64..5c41862 100644 --- a/core/database.py +++ b/core/database.py @@ -717,7 +717,68 @@ class NFOGuardDatabase: conn.commit() return deleted_count > 0 - + + def update_movie_file_info(self, imdb_id: str, path: str, has_video_file: bool = True) -> bool: + """ + Update path and video file status for an existing movie + Used when population finds a video file for a manually-added movie + + Args: + imdb_id: Movie IMDb ID + path: File path to the video file + has_video_file: Whether a video file exists (default True) + + Returns: + True if movie was updated, False if not found + """ + with self.get_connection() as conn: + cursor = conn.cursor() + + cursor.execute(""" + UPDATE movies + SET path = %s, + has_video_file = %s, + last_updated = %s + WHERE imdb_id = %s + """, (path, has_video_file, datetime.utcnow(), imdb_id)) + + updated_count = cursor.rowcount + conn.commit() + + return updated_count > 0 + + def update_episode_file_info(self, imdb_id: str, season: int, episode: int, + path: str, has_video_file: bool = True) -> bool: + """ + Update path and video file status for an existing episode + Used when population finds a video file for a manually-added episode + + Args: + imdb_id: Series IMDb ID + season: Season number + episode: Episode number + path: File path to the video file + has_video_file: Whether a video file exists (default True) + + Returns: + True if episode was updated, False if not found + """ + with self.get_connection() as conn: + cursor = conn.cursor() + + cursor.execute(""" + UPDATE episodes + SET path = %s, + has_video_file = %s, + last_updated = %s + WHERE imdb_id = %s AND season = %s AND episode = %s + """, (path, has_video_file, datetime.utcnow(), imdb_id, season, episode)) + + updated_count = cursor.rowcount + conn.commit() + + return updated_count > 0 + def delete_orphaned_movies(self) -> List[Dict]: """ Find and delete movies that don't have corresponding video files on disk diff --git a/core/database_populator.py b/core/database_populator.py index 9bc13e3..fa7abf0 100644 --- a/core/database_populator.py +++ b/core/database_populator.py @@ -111,8 +111,14 @@ class DatabasePopulator: # Check if movie already exists in database existing = self.db.get_movie_dates(imdb_id) if existing and existing.get('dateadded'): - # Already in database - skip silently (not an error) - _log("DEBUG", f"Movie {imdb_id} already in database, skipping") + # Already in database - update file path and video status if needed + existing_path = existing.get('path') + if not existing_path or existing_path == 'unknown' or existing_path != path: + _log("INFO", f"Movie {imdb_id} exists but updating file info: {path}") + self.db.update_movie_file_info(imdb_id, path, has_video_file=True) + stats['updated'] += 1 + else: + _log("DEBUG", f"Movie {imdb_id} already in database with correct path, skipping") continue # Get release date @@ -308,7 +314,13 @@ class DatabasePopulator: # Check if episode already exists existing = self.db.get_episode_date(imdb_id, season_num, episode_num) if existing and existing.get('dateadded'): - # Already in database - skip silently (not an error) + # Already in database - update file path and video status if needed + existing_path = existing.get('path') + episode_path = episode.get('path', 'unknown') + if not existing_path or existing_path == 'unknown' or existing_path != episode_path: + _log("INFO", f"Episode {imdb_id} S{season_num:02d}E{episode_num:02d} exists but updating file info: {episode_path}") + self.db.update_episode_file_info(imdb_id, season_num, episode_num, episode_path, has_video_file=True) + stats['updated'] += 1 continue # Only process episodes that have video files