From fbc3dd255261d7b9dd69f86694295028ed931913 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 13 Jan 2026 16:29:12 +0000 Subject: [PATCH] Fix: SABnzbd status polling (#439) --- .../prowlarr/clients/sabnzbd.py | 18 ++++++++++++++---- shelfmark/release_sources/prowlarr/handler.py | 6 +++++- shelfmark/release_sources/prowlarr/settings.py | 18 +++++++++--------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/shelfmark/release_sources/prowlarr/clients/sabnzbd.py b/shelfmark/release_sources/prowlarr/clients/sabnzbd.py index d0917aee..1a86a33e 100644 --- a/shelfmark/release_sources/prowlarr/clients/sabnzbd.py +++ b/shelfmark/release_sources/prowlarr/clients/sabnzbd.py @@ -251,16 +251,26 @@ class SABnzbdClient(DownloadClient): complete=True, file_path=storage, ) - else: - # Failed or other status - fail_message = slot.get("fail_message", status_text) + elif status_text == "FAILED": + fail_message = slot.get("fail_message", "Download failed") return DownloadStatus( progress=100, state="error", - message=f"Download failed: {fail_message}", + message=fail_message, complete=True, file_path=None, ) + else: + # Post-processing states: Queued, QuickCheck, Verifying, + # Repairing, Fetching, Extracting, Moving, Running + # Keep polling - not yet complete + return DownloadStatus( + progress=100, + state="processing", + message=status_text.title(), + complete=False, + file_path=None, + ) # Not found logger.warning(f"SABnzbd: download {download_id} not found in queue or history") diff --git a/shelfmark/release_sources/prowlarr/handler.py b/shelfmark/release_sources/prowlarr/handler.py index f0ef0655..a893b3d3 100644 --- a/shelfmark/release_sources/prowlarr/handler.py +++ b/shelfmark/release_sources/prowlarr/handler.py @@ -202,7 +202,11 @@ class ProwlarrHandler(DownloadHandler): # Build status message - use client message if provided, else build progress msg = status.message or self._build_progress_message(status) - status_callback("downloading", msg) + if status.state == DownloadState.PROCESSING: + # Post-processing (e.g., SABnzbd verifying/extracting) + status_callback("resolving", msg) + else: + status_callback("downloading", msg) # Wait for next poll (interruptible by cancel) if cancel_flag.wait(timeout=POLL_INTERVAL): diff --git a/shelfmark/release_sources/prowlarr/settings.py b/shelfmark/release_sources/prowlarr/settings.py index 5976bd52..f90bfee6 100644 --- a/shelfmark/release_sources/prowlarr/settings.py +++ b/shelfmark/release_sources/prowlarr/settings.py @@ -396,8 +396,8 @@ def prowlarr_clients_settings(): key="QBITTORRENT_CATEGORY", label="Book Category", description="Category to assign to book downloads in qBittorrent", - placeholder="cwabd", - default="cwabd", + placeholder="books", + default="books", show_when={"field": "PROWLARR_TORRENT_CLIENT", "value": "qbittorrent"}, ), TextField( @@ -441,8 +441,8 @@ def prowlarr_clients_settings(): key="TRANSMISSION_CATEGORY", label="Book Label", description="Label to assign to book downloads in Transmission", - placeholder="cwabd", - default="cwabd", + placeholder="books", + default="books", show_when={"field": "PROWLARR_TORRENT_CLIENT", "value": "transmission"}, ), TextField( @@ -495,8 +495,8 @@ def prowlarr_clients_settings(): key="DELUGE_CATEGORY", label="Book Label", description="Label to assign to book downloads in Deluge", - placeholder="cwabd", - default="cwabd", + placeholder="books", + default="books", show_when={"field": "PROWLARR_TORRENT_CLIENT", "value": "deluge"}, ), TextField( @@ -601,8 +601,8 @@ def prowlarr_clients_settings(): key="SABNZBD_CATEGORY", label="Book Category", description="Category to assign to book downloads in SABnzbd", - placeholder="cwabd", - default="cwabd", + placeholder="books", + default="books", show_when={"field": "PROWLARR_USENET_CLIENT", "value": "sabnzbd"}, ), TextField( @@ -617,7 +617,7 @@ def prowlarr_clients_settings(): # Note: Usenet client download path must be mounted identically in both containers. SelectField( key="PROWLARR_USENET_ACTION", - label="Completion Action", + label="NZB Completion Action", description="What to do with usenet files after download completes", options=[ {"value": "move", "label": "Move to ingest"},