Add plex collection: health check and poster repair

Plex on odin had 101 of 283 TV shows showing grey placeholder posters. The
cause was not missing images: for every affected show the poster was still
downloaded in the item's metadata bundle, but no candidate was marked
`selected` in the database, so the thumb URL resolved to a 404. Working shows
had exactly one selected candidate; all 101 affected had zero.

Two details make this easy to misdiagnose, so both are captured in the docs:
only 6 items lacked a `thumb` field outright, while 95 advertised a
well-formed thumb URL that 404s on fetch — a metadata-only audit reports the
library as healthy. And a bulk metadata refresh, the obvious suspect, does not
correlate with the damage.

Adds three scripts against the Plex HTTP API (no SSH to odin needed):

  plex-health    read-only report — server, updates, libraries, unmatched
                 media, Butler tasks, active streams; exit 0/1/2
  poster-audit   read-only; fetches every thumb to find the 404s
  poster-repair  re-selects the locally-cached poster; --dry-run, idempotent,
                 skips items whose poster already works so manually-chosen
                 artwork is never replaced

All 283 TV Shows posters now resolve. The health check also surfaced one
unmatched movie, Battlestar Galactica the Mini Series.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lucas Berger
2026-08-15 21:15:06 -04:00
co-authored by Claude Opus 5
parent 28e0fdb631
commit 3df1cca91c
9 changed files with 942 additions and 1 deletions
+33
View File
@@ -0,0 +1,33 @@
# Copy to .env and fill in. Never commit the filled-in .env.
# The repo .gitignore ignores `.env` and `**/.env` everywhere — verify with:
# git check-ignore -v plex/.env
# ── Plex HTTP API (required) ─────────────────────────────────────────────────
# Base URL of the Plex Media Server. Resolves to odin (192.168.90.103) and routes
# over the tailnet subnet route. Use https:// — plain http 302-redirects.
# TLS verifies cleanly from `dev` here, unlike odin's myunraid.net vhost.
PLEX_URL=https://plex.bergerhouse.net
# X-Plex-Token for an admin account on this server.
# Plex Web -> any library item -> ... -> Get Info -> View XML, then copy the
# X-Plex-Token query parameter out of the URL that opens.
PLEX_TOKEN=replace-me
# Set to 1 to skip TLS verification (not needed for PLEX_URL above; here in case
# the collection is pointed at odin's myunraid.net vhost instead).
PLEX_INSECURE=0
# ── odin filesystem access (optional — only for the deeper "under the hood" checks) ──
# Needed to read Plex's logs, Preferences.xml, and the metadata/media appdata
# dirs directly. Leave blank until an SSH key for this box is authorized on odin.
ODIN_SSH_HOST=100.101.253.105
ODIN_SSH_USER=root
ODIN_SSH_KEY=
# Path to the Plex appdata dir on odin, as seen from the Unraid host (not the
# container). Confirm before use — not yet verified.
ODIN_PLEX_APPDATA=
# ── Unraid GraphQL API (optional — host-level health only) ───────────────────
# See ../docs/odin-access.md. Base URL WITHOUT the /graphql suffix.
UNRAID_HOST=https://192-168-90-103.87c90a69c53e7197560c778a63f483e675130f2a.myunraid.net:8443
UNRAID_API_KEY=