Notify completed downloads and finish watchlist entries
This commit is contained in:
+25
-1
@@ -1037,6 +1037,7 @@ class DownloadQueue:
|
||||
finalize_error = None
|
||||
moved_files = []
|
||||
watchlist_sync_error = None
|
||||
synced_watchlist_item = None
|
||||
cleanup_staging = False
|
||||
if exit_code == 0 and not job.get("cancel_requested"):
|
||||
try:
|
||||
@@ -1046,7 +1047,7 @@ class DownloadQueue:
|
||||
else:
|
||||
if self.watchlist_sync_fn is not None:
|
||||
try:
|
||||
self.watchlist_sync_fn(job)
|
||||
synced_watchlist_item = self.watchlist_sync_fn(job)
|
||||
except Exception as exc:
|
||||
watchlist_sync_error = exc
|
||||
|
||||
@@ -1083,5 +1084,28 @@ class DownloadQueue:
|
||||
self._save_job_locked(job)
|
||||
if cleanup_staging:
|
||||
self._cleanup_staging_dir(job)
|
||||
elif exit_code == 0 and not finalize_error and not canceled:
|
||||
download_title = (
|
||||
str((synced_watchlist_item or {}).get("title") or "").strip()
|
||||
or str(job.get("title") or "").strip()
|
||||
or str(job.get("query") or "").strip()
|
||||
or "Unknown anime"
|
||||
)
|
||||
try:
|
||||
send_discord_webhook_event(
|
||||
self.config_getter() or {},
|
||||
"download_completed",
|
||||
{
|
||||
"show_id": (synced_watchlist_item or {}).get("show_id") or job.get("show_id"),
|
||||
"title": download_title,
|
||||
"mode": job.get("mode"),
|
||||
"episodes": job.get("episodes"),
|
||||
"category": (synced_watchlist_item or {}).get("category") or "finished",
|
||||
"thumbnail_path": (synced_watchlist_item or {}).get("thumbnail_path"),
|
||||
"moved_files": moved_files,
|
||||
},
|
||||
)
|
||||
except Exception as exc:
|
||||
debug_log("discord_webhook.download_completed_failed", title=download_title, error=exc)
|
||||
except Exception as exc:
|
||||
self._fail_job_runtime(job, exc, process=process)
|
||||
|
||||
Reference in New Issue
Block a user