use date earliest
This commit is contained in:
+21
-13
@@ -235,12 +235,13 @@ class RadarrClient:
|
||||
total_processed = 0
|
||||
|
||||
while page <= 20: # Safety limit
|
||||
# Get history in chronological order
|
||||
data = self._get("/api/v3/history", {
|
||||
"movieId": str(movie_id), # Ensure it's a string
|
||||
"page": page,
|
||||
"movieId": str(movie_id),
|
||||
"page": page,
|
||||
"pageSize": page_size,
|
||||
"sortKey": "date",
|
||||
"sortDirection": "ascending" # Start from oldest
|
||||
"sortKey": "date",
|
||||
"sortDirection": "ascending"
|
||||
})
|
||||
|
||||
if not data:
|
||||
@@ -272,18 +273,22 @@ class RadarrClient:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Only process import events (type 3)
|
||||
if event_type != self.EVENT_TYPE_IMPORTED:
|
||||
# Track the first grab event we find
|
||||
if event_type == self.EVENT_TYPE_GRABBED and not first_grab:
|
||||
if event.get("date"):
|
||||
try:
|
||||
first_grab = datetime.fromisoformat(event["date"].replace("Z", "+00:00")).astimezone(timezone.utc).isoformat(timespec="seconds")
|
||||
_log("DEBUG", f"Found first grab event at {first_grab}")
|
||||
except Exception:
|
||||
pass
|
||||
continue
|
||||
imported_path = None
|
||||
|
||||
# Only process import events
|
||||
try:
|
||||
data = json.loads(event.get("data", "{}"))
|
||||
imported_path = data.get("importedPath", "").lower()
|
||||
except (json.JSONDecodeError, AttributeError):
|
||||
pass
|
||||
|
||||
if not imported_path:
|
||||
continue
|
||||
if not imported_path:
|
||||
continue
|
||||
|
||||
movie_imdb = (movie_info.get("imdbId", "") or "").lower()
|
||||
movie_title = (movie_info.get("title", "") or "").lower()
|
||||
@@ -405,7 +410,10 @@ class RadarrClient:
|
||||
Returns:
|
||||
(date_iso, source_description)
|
||||
"""
|
||||
# Try history first
|
||||
# Try history first - we want the earliest event regardless of type
|
||||
import_date = self.earliest_import_event_optimized(movie_id)
|
||||
|
||||
# Try history second
|
||||
import_date = self.earliest_import_event_optimized(movie_id)
|
||||
if import_date:
|
||||
return import_date, "radarr:history.import"
|
||||
|
||||
Reference in New Issue
Block a user