updates for debug scan

This commit is contained in:
2025-09-08 10:21:38 -04:00
parent 5537b3b158
commit 5cc237461c
3 changed files with 117 additions and 5 deletions
+83
View File
@@ -798,6 +798,84 @@ async def batch_status():
"""Get batch queue status"""
return batcher.get_status()
@app.get("/debug/movie/{imdb_id}")
async def debug_movie_import_date(imdb_id: str):
"""Debug endpoint to analyze movie import date detection"""
try:
if not imdb_id.startswith("tt"):
imdb_id = f"tt{imdb_id}"
_log("INFO", f"=== DEBUG MOVIE IMPORT DATE: {imdb_id} ===")
if not (os.environ.get("RADARR_URL") and os.environ.get("RADARR_API_KEY")):
return {
"error": "Radarr not configured",
"imdb_id": imdb_id,
"radarr_configured": False
}
# Create Radarr client
from clients.radarr_client import RadarrClient
radarr_client = RadarrClient(
os.environ.get("RADARR_URL"),
os.environ.get("RADARR_API_KEY")
)
# Look up movie
movie_obj = radarr_client.movie_by_imdb(imdb_id)
if not movie_obj:
return {
"error": f"Movie not found in Radarr for IMDb ID {imdb_id}",
"imdb_id": imdb_id,
"radarr_configured": True,
"movie_found": False
}
movie_id = movie_obj.get("id")
movie_title = movie_obj.get("title")
_log("INFO", f"Found movie: {movie_title} (Radarr ID: {movie_id})")
# Get import date with detailed logging
import_date, source = radarr_client.get_movie_import_date(movie_id)
# Get movie files
movie_files = radarr_client.movie_files(movie_id)
file_info = []
for f in movie_files:
file_info.append({
"id": f.get("id"),
"relativePath": f.get("relativePath"),
"dateAdded": f.get("dateAdded"),
"quality": f.get("quality", {}).get("quality", {}).get("name", "Unknown")
})
return {
"imdb_id": imdb_id,
"radarr_configured": True,
"movie_found": True,
"movie_title": movie_title,
"movie_id": movie_id,
"detected_import_date": import_date,
"import_source": source,
"movie_files": file_info,
"debug_info": {
"radarr_url": os.environ.get("RADARR_URL"),
"movie_digital_release": movie_obj.get("digitalRelease"),
"movie_in_cinemas": movie_obj.get("inCinemas"),
"movie_physical_release": movie_obj.get("physicalRelease"),
"movie_folder_path": movie_obj.get("folderPath")
}
}
except Exception as e:
_log("ERROR", f"Debug endpoint error for {imdb_id}: {e}")
return {
"error": str(e),
"imdb_id": imdb_id,
"success": False
}
@app.post("/manual/scan")
async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = None, scan_type: str = "both"):
"""Manual scan endpoint"""
@@ -827,12 +905,17 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
_log("ERROR", f"Failed processing TV series {item}: {e}")
if scan_type in ["both", "movies"] and scan_path in config.movie_paths:
_log("INFO", f"Scanning movies in: {scan_path}")
movie_count = 0
for item in scan_path.iterdir():
if item.is_dir() and nfo_manager.parse_imdb_from_path(item):
movie_count += 1
_log("INFO", f"Processing movie: {item.name}")
try:
movie_processor.process_movie(item)
except Exception as e:
_log("ERROR", f"Failed processing movie {item}: {e}")
_log("INFO", f"Completed movie scan: {movie_count} movies processed in {scan_path}")
background_tasks.add_task(run_scan)
return {"status": "started", "message": f"Manual {scan_type} scan started"}