db: updates for TV shows in interface
Local Docker Build (Dev) / build-dev (push) Successful in 4s

This commit is contained in:
2025-10-18 14:28:10 -04:00
parent 46fa6b3b75
commit 852c45bbb5
2 changed files with 75 additions and 9 deletions
+1 -1
View File
@@ -1 +1 @@
2.4.2 2.4.3
+74 -8
View File
@@ -11,6 +11,54 @@ from pathlib import Path
from api.models import * from api.models import *
def map_source_to_description(source: str) -> str:
"""Map technical source codes to user-friendly descriptions"""
if not source or source == "no_valid_date_source":
return "Unknown"
# Handle different source patterns
source_lower = source.lower()
# TMDB sources
if "tmdb:theatrical" in source_lower:
return "TMDB Theatrical"
elif "tmdb:digital" in source_lower:
return "TMDB Digital"
elif "tmdb:physical" in source_lower:
return "TMDB Physical/DVD"
elif "tmdb:" in source_lower:
return "TMDB Release"
# Radarr sources
elif "radarr:db.history.import" in source_lower:
return "Radarr Import History"
elif "radarr:db.file.dateadded" in source_lower:
return "Radarr File Date"
elif "radarr:nfo.premiered" in source_lower:
return "Radarr NFO"
elif "radarr:" in source_lower:
return "Radarr"
# OMDb sources
elif "omdb:dvd" in source_lower:
return "OMDb DVD"
elif "omdb:" in source_lower:
return "OMDb Release"
# Manual and other sources
elif "manual" in source_lower:
return "Manual Entry"
elif "digital_release" in source_lower:
return "Digital Release"
elif "nfo:" in source_lower:
return "NFO File"
elif "webhook:" in source_lower:
return "Webhook/API"
# Fallback for unknown patterns
return source.title()
# --------------------------- # ---------------------------
# Database Query Endpoints # Database Query Endpoints
# --------------------------- # ---------------------------
@@ -84,6 +132,8 @@ async def get_movies_list(dependencies: dict,
movie['title'] = Path(movie['path']).name if movie['path'] else movie['imdb_id'] movie['title'] = Path(movie['path']).name if movie['path'] else movie['imdb_id']
except: except:
movie['title'] = movie['imdb_id'] movie['title'] = movie['imdb_id']
# Map source to user-friendly description
movie['source_description'] = map_source_to_description(movie.get('source'))
movies.append(movie) movies.append(movie)
return { return {
@@ -305,7 +355,10 @@ async def get_series_episodes(dependencies: dict, imdb_id: str):
cursor = conn.cursor() cursor = conn.cursor()
# Get series info # Get series info
cursor.execute("SELECT * FROM series WHERE imdb_id = ?", (imdb_id,)) if db.db_type == "postgresql":
cursor.execute("SELECT * FROM series WHERE imdb_id = %s", (imdb_id,))
else:
cursor.execute("SELECT * FROM series WHERE imdb_id = ?", (imdb_id,))
series_row = cursor.fetchone() series_row = cursor.fetchone()
if not series_row: if not series_row:
raise HTTPException(status_code=404, detail="Series not found") raise HTTPException(status_code=404, detail="Series not found")
@@ -317,14 +370,27 @@ async def get_series_episodes(dependencies: dict, imdb_id: str):
series_info['title'] = imdb_id series_info['title'] = imdb_id
# Get episodes # Get episodes
cursor.execute(""" if db.db_type == "postgresql":
SELECT season, episode, aired, dateadded, source, has_video_file, last_updated cursor.execute("""
FROM episodes SELECT season, episode, aired, dateadded, source, has_video_file, last_updated
WHERE imdb_id = ? FROM episodes
ORDER BY season, episode WHERE imdb_id = %s
""", (imdb_id,)) ORDER BY season, episode
""", (imdb_id,))
else:
cursor.execute("""
SELECT season, episode, aired, dateadded, source, has_video_file, last_updated
FROM episodes
WHERE imdb_id = ?
ORDER BY season, episode
""", (imdb_id,))
episodes = [dict(row) for row in cursor.fetchall()] episodes = []
for row in cursor.fetchall():
episode = dict(row)
# Map source to user-friendly description
episode['source_description'] = map_source_to_description(episode.get('source'))
episodes.append(episode)
return { return {
"series": series_info, "series": series_info,