update to skiped files
Local Docker Build (Dev) / build-dev (push) Successful in 5s

This commit is contained in:
2025-11-03 16:37:42 -05:00
parent c9b099a218
commit 7932b9cfba
6 changed files with 209 additions and 54 deletions
+92 -1
View File
@@ -133,6 +133,29 @@ class NFOGuardDatabase:
END IF;
END $$;
""")
# Add skipped and skip_reason columns if they don't exist (migration for skip tracking)
cursor.execute("""
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
WHERE table_name='movies' AND column_name='skipped') THEN
ALTER TABLE movies ADD COLUMN skipped BOOLEAN DEFAULT FALSE;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
WHERE table_name='movies' AND column_name='skip_reason') THEN
ALTER TABLE movies ADD COLUMN skip_reason TEXT;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
WHERE table_name='episodes' AND column_name='skipped') THEN
ALTER TABLE episodes ADD COLUMN skipped BOOLEAN DEFAULT FALSE;
END IF;
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
WHERE table_name='episodes' AND column_name='skip_reason') THEN
ALTER TABLE episodes ADD COLUMN skip_reason TEXT;
END IF;
END $$;
""")
# Processing history table
cursor.execute("""
@@ -301,7 +324,75 @@ class NFOGuardDatabase:
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 mark_movie_skipped(self, imdb_id: str, title: str, year: int, path: str, reason: str):
"""Mark a movie as skipped with reason"""
with self.get_connection() as conn:
cursor = conn.cursor()
timestamp = datetime.utcnow()
cursor.execute("""
INSERT INTO movies (imdb_id, title, year, path, skipped, skip_reason, has_video_file, last_updated)
VALUES (%s, %s, %s, %s, TRUE, %s, FALSE, %s)
ON CONFLICT (imdb_id) DO UPDATE SET
title = EXCLUDED.title,
year = EXCLUDED.year,
path = EXCLUDED.path,
skipped = TRUE,
skip_reason = EXCLUDED.skip_reason,
last_updated = EXCLUDED.last_updated
""", (imdb_id, title, year, path, reason, timestamp))
def mark_episode_skipped(self, imdb_id: str, season: int, episode: int, reason: str):
"""Mark an episode as skipped with reason"""
with self.get_connection() as conn:
cursor = conn.cursor()
timestamp = datetime.utcnow()
cursor.execute("""
INSERT INTO episodes (imdb_id, season, episode, skipped, skip_reason, has_video_file, last_updated)
VALUES (%s, %s, %s, TRUE, %s, FALSE, %s)
ON CONFLICT (imdb_id, season, episode) DO UPDATE SET
skipped = TRUE,
skip_reason = EXCLUDED.skip_reason,
last_updated = EXCLUDED.last_updated
""", (imdb_id, season, episode, reason, timestamp))
def clear_movie_skipped(self, imdb_id: str):
"""Clear skipped flag for a movie"""
with self.get_connection() as conn:
cursor = conn.cursor()
cursor.execute("""
UPDATE movies SET skipped = FALSE, skip_reason = NULL
WHERE imdb_id = %s
""", (imdb_id,))
def clear_episode_skipped(self, imdb_id: str, season: int, episode: int):
"""Clear skipped flag for an episode"""
with self.get_connection() as conn:
cursor = conn.cursor()
cursor.execute("""
UPDATE episodes SET skipped = FALSE, skip_reason = NULL
WHERE imdb_id = %s AND season = %s AND episode = %s
""", (imdb_id, season, episode))
def get_skipped_counts(self) -> Dict:
"""Get counts of skipped movies and episodes"""
with self.get_connection() as conn:
cursor = conn.cursor()
# Count skipped movies
cursor.execute("SELECT COUNT(*) as count FROM movies WHERE skipped = TRUE")
skipped_movies = cursor.fetchone()['count']
# Count skipped episodes
cursor.execute("SELECT COUNT(*) as count FROM episodes WHERE skipped = TRUE")
skipped_episodes = cursor.fetchone()['count']
return {
'movies': skipped_movies,
'episodes': skipped_episodes,
'total': skipped_movies + skipped_episodes
}
def get_series_episodes(self, imdb_id: str, has_video_file_only: bool = False) -> List[Dict]:
"""Get all episodes for a series"""
with self.get_connection() as conn: