fix: not using airdate when rename is first event in sonarr
Local Docker Build (Dev) / build-dev (push) Successful in 5s

This commit is contained in:
2025-10-25 12:27:52 -04:00
parent 47311864cf
commit 2811d30352
+6 -4
View File
@@ -222,7 +222,7 @@ class SonarrClient:
import_date = earliest_import["date"]
_log("INFO", f"Found import date: {import_date} for episode {episode_id}")
# Check if this looks like an upgrade by comparing to renames
# Check if this import is likely a recent re-download/upgrade
if rename_events:
earliest_rename = min(rename_events, key=lambda x: x["date"])
rename_date = earliest_rename["date"]
@@ -232,10 +232,12 @@ class SonarrClient:
rename_dt = datetime.fromisoformat(rename_date.replace("Z", "+00:00"))
days_diff = (import_dt - rename_dt).days
# If import is significantly after rename, prefer rename date
# If import is significantly after rename, this is likely a re-download
# The original import likely happened much earlier (possibly lost from history)
# Return None to trigger aired date fallback instead of using rename date
if days_diff > 30:
_log("WARNING", f"Import {import_date} is {days_diff} days after rename {rename_date} - using rename date")
return rename_date
_log("WARNING", f"Import {import_date} is {days_diff} days after rename {rename_date} - this looks like a re-download, using aired date fallback")
return None # Trigger aired date fallback
except Exception as e:
_log("DEBUG", f"Error comparing dates: {e}")