This commit is contained in:
@@ -164,7 +164,52 @@ class RadarrDbClient:
|
||||
_log("ERROR", f"Database query error for IMDb {imdb_id}: {e}")
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def get_all_movies(self) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
Get all movies from Radarr database
|
||||
|
||||
Returns:
|
||||
List of dictionaries with movie info
|
||||
"""
|
||||
query = """
|
||||
SELECT
|
||||
m."Id" as id,
|
||||
m."Path" as path,
|
||||
m."Added" as added,
|
||||
mm."ImdbId" as imdb_id,
|
||||
mm."Title" as title,
|
||||
mm."Year" as year,
|
||||
mm."DigitalRelease" as digital_release,
|
||||
mm."PhysicalRelease" as physical_release,
|
||||
mm."InCinemas" as in_cinemas
|
||||
FROM "Movies" m
|
||||
JOIN "MovieMetadata" mm ON m."MovieMetadataId" = mm."Id"
|
||||
ORDER BY mm."Title"
|
||||
"""
|
||||
|
||||
if self.db_type == "sqlite":
|
||||
# SQLite uses ? placeholders but this query has none
|
||||
pass
|
||||
|
||||
try:
|
||||
with self._get_connection() as conn:
|
||||
if self.db_type == "postgresql":
|
||||
cursor = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
|
||||
else:
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute(query)
|
||||
rows = cursor.fetchall()
|
||||
|
||||
if rows:
|
||||
return [dict(row) if self.db_type == "sqlite" else row for row in rows]
|
||||
return []
|
||||
|
||||
except Exception as e:
|
||||
_log("ERROR", f"Database query error getting all movies: {e}")
|
||||
return []
|
||||
|
||||
def get_earliest_import_date(self, movie_id: int) -> Tuple[Optional[str], str]:
|
||||
"""
|
||||
Get earliest import date from History table, accounting for upgrade scenarios
|
||||
|
||||
Reference in New Issue
Block a user