This commit is contained in:
+62
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user