Compact request activity into a live summary and modal history

This commit is contained in:
2026-09-06 22:20:33 +12:00
parent 009bb35032
commit 74c49fad5b
10 changed files with 223 additions and 71 deletions
+9 -9
View File
@@ -117,7 +117,7 @@ def _operation_result_message(
if "/queue" in normalized_path and normalized_method == "GET":
return _queue_result_message(service, result)
if "/command" in normalized_path and normalized_method == "POST":
return f"{service} accepted the {_command_name(payload)} and queued it for processing."
return f"{service} accepted the {_command_name(payload)} and put it in line to run. This does not mean a download has started."
if "/release" in normalized_path:
if normalized_method == "GET":
count = len(_result_items(result, "records", "items"))
@@ -129,10 +129,10 @@ def _operation_result_message(
return f"{service} accepted the selected release and sent it to the download client."
if "/qualityprofile" in normalized_path and normalized_method == "GET":
count = len(_result_items(result))
return f"{service} returned {_count_message(count, 'available quality profile')}."
return f"{service} returned {_count_message(count, 'download quality setting')}."
if "/rootfolder" in normalized_path and normalized_method == "GET":
count = len(_result_items(result))
return f"{service} returned {_count_message(count, 'configured library location')}."
return f"{service} returned {_count_message(count, 'library folder')}."
if "/indexer" in normalized_path and normalized_method == "GET":
count = len(_result_items(result))
return f"{service} reports {_count_message(count, 'configured search source')}."
@@ -174,7 +174,7 @@ def _operation_result_message(
if "/health" in normalized_path:
issues = _result_items(result)
if not issues:
return "Prowlarr reports that all configured indexers are healthy."
return "The download search sources are working normally."
first = next((item for item in issues if isinstance(item, dict)), {})
detail = str(first.get("message") or first.get("source") or "").strip()
suffix = f" First issue: {detail}" if detail else ""
@@ -182,9 +182,9 @@ def _operation_result_message(
if "/search" in normalized_path:
results = _result_items(result, "results", "records")
return (
f"Prowlarr found {_count_message(len(results), 'possible release')}."
f"Prowlarr found {_count_message(len(results), 'possible download')}."
if results
else "Prowlarr did not find any possible releases."
else "Prowlarr did not find any possible downloads."
)
if service == "Bazarr" and normalized_method == "PATCH" and "/subtitles" in normalized_path:
@@ -193,9 +193,9 @@ def _operation_result_message(
return f"Bazarr accepted a fresh {language} subtitle search for the {target}."
if normalized_method == "GET":
return f"{service} completed the check successfully."
return f"{service} finished this check without reporting a problem."
if normalized_method == "POST":
return f"{service} accepted the request and started processing it."
return f"{service} received the request. Its result will be checked separately."
if normalized_method == "PUT":
return f"{service} saved the requested changes."
if normalized_method == "DELETE":
@@ -247,7 +247,7 @@ def _operation_messages(service: str, method: str, path: str) -> tuple[str, str]
if service == "Bazarr" and "/subtitles" in normalized_path and normalized_method == "PATCH":
return "Asking Bazarr for fresh subtitles…", "Bazarr started the subtitle search"
if service == "Prowlarr" and "/health" in normalized_path:
return "Checking Prowlarr indexer health", "Prowlarr returned its indexer health"
return "Checking whether the download search sources are working", "Prowlarr returned its indexer health"
return f"Contacting {service}", f"{service} responded"
+2 -2
View File
@@ -15,9 +15,9 @@ def _availability_message(result: Any) -> str:
or (isinstance(items, list) and len(items) > 0)
)
return (
"The title is available to watch in Jellyfin."
"Grizzlyflix returned possible matches. Magent still needs to check the exact title and file."
if available
else "The title is not currently available in Jellyfin."
else "Grizzlyflix did not find this title in its library search."
)
+15 -9
View File
@@ -8,20 +8,26 @@ from ..services.operation_progress import finish_remote_call, start_remote_call
def _torrent_state_text(state: Any) -> str:
normalized = str(state or "").strip().lower()
if "pause" in normalized:
if normalized in {"uploading", "stalledup", "forcedup", "queuedup", "pausedup", "stoppedup", "completed"}:
return "finished"
if "pause" in normalized or normalized == "stoppeddl":
return "paused"
if "stall" in normalized:
return "stalled"
return "waiting for data"
if normalized.startswith("queued"):
return "waiting in the queue"
if "downloading" in normalized or normalized in {"forcedl", "metadl", "checkingdl"}:
if normalized == "metadl":
return "getting the download details"
if normalized in {"checkingdl", "checkingup", "checkingresumedata"}:
return "checking the downloaded files"
if "downloading" in normalized or normalized in {"forcedl", "forceddl"}:
return "downloading"
if "upload" in normalized or normalized in {"stalledup", "forcedup"}:
return "finished and seeding"
if "upload" in normalized:
return "downloaded and sharing with others"
if normalized in {"completed", "missingfiles"}:
return "finished" if normalized == "completed" else "missing files"
if "error" in normalized:
return "in an error state"
return "unable to continue"
return "present"
@@ -31,14 +37,14 @@ def _torrent_result_message(result: Any) -> str:
return "qBittorrent found no matching downloads."
first = next((item for item in torrents if isinstance(item, dict)), {})
if len(torrents) == 1:
name = str(first.get("name") or "the matching download").strip()
progress = first.get("progress")
progress_text = (
f" and {max(0, min(100, round(progress * 100)))}% complete"
f" {max(0, min(100, round(progress * 100)))}% complete"
if isinstance(progress, (int, float))
else ""
)
return f'qBittorrent found "{name}"; it is {_torrent_state_text(first.get("state"))}{progress_text}.'
state_text = _torrent_state_text(first.get("state"))
return f'{"Downloading" if state_text == "downloading" else "The download is " + state_text}{progress_text}.'
active = sum(
1
for item in torrents