From 106bd16de8062ea8a25773a526f6ab965caba21f Mon Sep 17 00:00:00 2001 From: Barely Removable Date: Sat, 5 Sep 2026 09:55:02 -0700 Subject: [PATCH] Show who requested each show on Admin rows Sonarr has no concept of a requester, so this cross-references Ombi's TV request list by title to attribute the show to whoever's request triggered the grab, falling back to "Requester unknown" for anything added straight in Sonarr or when Ombi can't be reached. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01LPJxtE9tPURsaWDZ6rC4Dt --- app.py | 22 +++++++++++++++++++++- templates/system.html | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 7006d01..9874dc1 100644 --- a/app.py +++ b/app.py @@ -801,7 +801,9 @@ def get_admin_unwatched_shows(limit=10, months=ADMIN_UNWATCHED_MONTHS): dashboard uses) because a recency-limited window could mismark a show that genuinely was watched — just a while ago — as never-watched, which matters a lot more here than elsewhere given what's attached to - the wrong answer. + the wrong answer. Each show also carries whoever's Ombi request + triggered it, best-effort by title match — a show added straight in + Sonarr rather than requested has no requester to find. """ try: series_list = sonarr_series_cached() @@ -851,8 +853,26 @@ def get_admin_unwatched_shows(limit=10, months=ADMIN_UNWATCHED_MONTHS): never.sort(key=lambda x: x["size"], reverse=True) top = never[:limit] + + # Sonarr doesn't know who asked for a show — Ombi does, via whoever's + # request triggered the grab. Best-effort only: a show added straight + # in Sonarr, without an Ombi request, has no requester to find, and an + # unreachable Ombi shouldn't take down the rest of the section. + requested_by = {} + try: + for show in ombi_get("Request/tv"): + for child in show.get("childRequests", []): + user = child.get("requestedUser", {}) + alias = (user.get("alias") or user.get("userAlias") + or user.get("userName") or "").split("@")[0] + if alias: + requested_by.setdefault(show.get("title", "").lower(), alias) + except Exception: + pass + for show in top: show["size_display"] = _fmt_bytes(show["size"]) + show["requested_by"] = requested_by.get(show["title"].lower(), "") total_bytes = sum(show["size"] for show in top) return { diff --git a/templates/system.html b/templates/system.html index 3d34b5f..d25cb65 100644 --- a/templates/system.html +++ b/templates/system.html @@ -186,7 +186,7 @@ {{ show.ep_count }} EP {{ show.title }} - {% if show.year %}{{ show.year }} · {% endif %}Downloaded {{ show.added[:10] if show.added else 'unknown' }} · Never watched + {% if show.year %}{{ show.year }} · {% endif %}Downloaded {{ show.added[:10] if show.added else 'unknown' }} · {% if show.requested_by %}Requested by {{ show.requested_by }}{% else %}Requester unknown{% endif %} · Never watched {{ show.size_display }}