radarr date troubshooting
This commit is contained in:
+106
-2
@@ -836,8 +836,14 @@ async def debug_movie_import_date(imdb_id: str):
|
|||||||
|
|
||||||
_log("INFO", f"Found movie: {movie_title} (Radarr ID: {movie_id})")
|
_log("INFO", f"Found movie: {movie_title} (Radarr ID: {movie_id})")
|
||||||
|
|
||||||
# Get import date with detailed logging
|
# Get import date with detailed logging - use the optimized method
|
||||||
import_date, source = radarr_client.get_movie_import_date(movie_id)
|
import_date = radarr_client.earliest_import_event_optimized(movie_id)
|
||||||
|
if import_date:
|
||||||
|
source = "radarr:history.import.optimized"
|
||||||
|
else:
|
||||||
|
# Fallback to file dateAdded
|
||||||
|
import_date = radarr_client.earliest_file_dateadded(movie_id)
|
||||||
|
source = "radarr:file.dateAdded" if import_date else "no_date_found"
|
||||||
|
|
||||||
# Get movie files
|
# Get movie files
|
||||||
movie_files = radarr_client.movie_files(movie_id)
|
movie_files = radarr_client.movie_files(movie_id)
|
||||||
@@ -876,6 +882,104 @@ async def debug_movie_import_date(imdb_id: str):
|
|||||||
"success": False
|
"success": False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@app.get("/debug/movie/{imdb_id}/history")
|
||||||
|
async def debug_movie_history(imdb_id: str):
|
||||||
|
"""Detailed history analysis for a movie"""
|
||||||
|
try:
|
||||||
|
if not imdb_id.startswith("tt"):
|
||||||
|
imdb_id = f"tt{imdb_id}"
|
||||||
|
|
||||||
|
_log("INFO", f"=== DETAILED HISTORY ANALYSIS: {imdb_id} ===")
|
||||||
|
|
||||||
|
if not (os.environ.get("RADARR_URL") and os.environ.get("RADARR_API_KEY")):
|
||||||
|
return {"error": "Radarr not configured"}
|
||||||
|
|
||||||
|
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 for {imdb_id}"}
|
||||||
|
|
||||||
|
movie_id = movie_obj.get("id")
|
||||||
|
movie_title = movie_obj.get("title")
|
||||||
|
|
||||||
|
# Get ALL history pages
|
||||||
|
all_history = []
|
||||||
|
page = 1
|
||||||
|
|
||||||
|
while page <= 10: # Safety limit
|
||||||
|
data = radarr_client._get("/api/v3/history", {
|
||||||
|
"movieId": movie_id,
|
||||||
|
"page": page,
|
||||||
|
"pageSize": 50,
|
||||||
|
"sortKey": "date",
|
||||||
|
"sortDirection": "ascending"
|
||||||
|
})
|
||||||
|
|
||||||
|
if not data:
|
||||||
|
break
|
||||||
|
|
||||||
|
records = data if isinstance(data, list) else data.get("records", [])
|
||||||
|
if not records:
|
||||||
|
break
|
||||||
|
|
||||||
|
all_history.extend(records)
|
||||||
|
|
||||||
|
if len(records) < 50:
|
||||||
|
break
|
||||||
|
|
||||||
|
page += 1
|
||||||
|
|
||||||
|
# Analyze each event
|
||||||
|
analyzed_events = []
|
||||||
|
for event in all_history:
|
||||||
|
event_type = event.get("eventType", "")
|
||||||
|
date_str = event.get("date", "")
|
||||||
|
event_data = event.get("data", {})
|
||||||
|
|
||||||
|
# Get source path info
|
||||||
|
source_path = (
|
||||||
|
event_data.get('droppedPath', '') or
|
||||||
|
event_data.get('sourcePath', '') or
|
||||||
|
event_data.get('path', '') or
|
||||||
|
event_data.get('sourceTitle', '')
|
||||||
|
)
|
||||||
|
|
||||||
|
# Analyze if this is a real import
|
||||||
|
is_real, reason, date_iso = radarr_client._analyze_event_for_import(event)
|
||||||
|
|
||||||
|
analyzed_events.append({
|
||||||
|
"event_type": event_type,
|
||||||
|
"date": date_str,
|
||||||
|
"source_path": source_path,
|
||||||
|
"is_real_import": is_real,
|
||||||
|
"analysis_reason": reason,
|
||||||
|
"parsed_date": date_iso,
|
||||||
|
"full_data": event_data
|
||||||
|
})
|
||||||
|
|
||||||
|
# Find what our algorithm would pick
|
||||||
|
picked_date = radarr_client.earliest_import_event_optimized(movie_id)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"imdb_id": imdb_id,
|
||||||
|
"movie_title": movie_title,
|
||||||
|
"movie_id": movie_id,
|
||||||
|
"total_history_events": len(all_history),
|
||||||
|
"our_algorithm_picked": picked_date,
|
||||||
|
"all_events": analyzed_events,
|
||||||
|
"expected_july_date": "2025-07-07" in (picked_date or "")
|
||||||
|
}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
_log("ERROR", f"History debug error for {imdb_id}: {e}")
|
||||||
|
return {"error": str(e)}
|
||||||
|
|
||||||
@app.post("/manual/scan")
|
@app.post("/manual/scan")
|
||||||
async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = None, scan_type: str = "both"):
|
async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = None, scan_type: str = "both"):
|
||||||
"""Manual scan endpoint"""
|
"""Manual scan endpoint"""
|
||||||
|
|||||||
Reference in New Issue
Block a user