Skip to content

fix(jellyfin): off-media instant registration + native-webhook multi-version#272

Merged
stevezau merged 1 commit into
devfrom
fix/multiversion-webhook-and-offmedia-reg
Jun 29, 2026
Merged

fix(jellyfin): off-media instant registration + native-webhook multi-version#272
stevezau merged 1 commit into
devfrom
fix/multiversion-webhook-and-offmedia-reg

Conversation

@stevezau

Copy link
Copy Markdown
Owner

Closes the two remaining multi-version / off-media edges flagged after #269/#271. Both Jellyfin-specific; live-verified on Jellyfin 10.11.11.

1. Off-media instant trickplay registration (was silently 404'ing)

The app POSTed /MediaPreviewBridge/Trickplay/{id} without saveWithMedia, so the plugin defaulted to true and asked Jellyfin for the media-adjacent tile dir — which an off-media publish never writes — and returned 404. Registration then fell back to the next scheduled metadata refresh instead of appearing immediately. This affected all off-media items (single- and multi-version).

Fix: _trigger_item_refresh now sends saveWithMedia matching the adapter's mode. App-only — no plugin release needed.

Live A/B (alternate version, off-media): POST without the param → 404; with saveWithMedia=false204 registered. The real trigger path now logs Registered trickplay via Media Preview Bridge plugin for every version.

2. Native Jellyfin webhook → every version

A native Jellyfin webhook resolving an item id previewed only the primary version of a merged item (alternates live in MediaSources). Added resolve_item_to_remote_paths(item_id) -> [(version_id, path)]:

  • base: the single resolve_item_to_remote_path result.
  • Jellyfin/Emby: every MediaSource (each tagged with its per-version GUID for off-media); Emby yields one (versions are separate item ids → no fan-out, matches the scan).
  • Plex: every media[*].parts[*].file by bare ratingKey — brings the universal /incoming router to parity with /webhook, which already fanned out.

webhook_router resolves to a list and fans out one Job per version. Single-version and all Sonarr/Radarr path webhooks return the byte-identical one-job response; multi-version returns {"status":"queued","version_count":N,"jobs":[...]}. server_id_filter is threaded into every version's Job.

Live: resolve_item_to_remote_paths returns both versions with distinct GUIDs against real Jellyfin.

Tests

saveWithMedia matrix (media-adjacent / off-media / default); per-version resolvers (Plex parts, Jellyfin MediaSources, failure → []); router fan-out (Plex + Jellyfin) with per-version hint assertions; per-server URL pins every version; Emby item-id does not fan out. Full suite green (the only failures are the known flaky xdist worker-crash pollution — all pass in isolation). Architecture Review run; no HIGH, the MED + 2 LOW (test-matrix gaps) closed before commit.

🤖 Generated with Claude Code

…ook multi-version

Two remaining multi-version/off-media gaps, both Jellyfin-specific.

1) Off-media instant registration was silently broken (HTTP 404 -> slow
   fallback) for ALL off-media items. The app POSTed
   /MediaPreviewBridge/Trickplay/{id} without `saveWithMedia`, so the plugin
   defaulted to true and looked in the media-adjacent tile dir an off-media
   publish never wrote -> 404 -> registration deferred to the next scheduled
   scan instead of appearing immediately. Fix: `_trigger_item_refresh` sends
   `saveWithMedia` matching the adapter's mode. Verified live: alternate
   version POST returns 404 without the param, 204 with it; the real trigger
   path now logs "Registered trickplay via Media Preview Bridge plugin".
   App-only; no plugin release needed.

2) A native Jellyfin webhook resolving an item id previewed only the primary
   version of a merged multi-version item. Added
   `resolve_item_to_remote_paths(item_id) -> [(version_id, path)]` (base:
   single; Jellyfin/Emby: every MediaSource, Emby yields one since versions are
   separate item ids; Plex: every media[*].parts[*].file by bare ratingKey).
   webhook_router resolves to a LIST and fans out one Job per version.
   Single-version (and all Sonarr/Radarr path webhooks) keep the byte-identical
   one-job response; multi-version returns {"status":"queued",
   "version_count":N,"jobs":[...]}. server_id_filter is threaded into every
   version's Job. Verified live against Jellyfin 10.11.11.

Tests: saveWithMedia param matrix; per-version resolvers + failure->[]; router
fan-out (Plex + Jellyfin) with per-version hints; per-server URL pins every
version; Emby item-id does not fan out.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YC1Z1JFBVJ5xKi5YAqYKfc
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.45614% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.00%. Comparing base (984c7b9) to head (2a88764).

Files with missing lines Patch % Lines
media_preview_generator/web/webhook_router.py 81.81% 6 Missing ⚠️
media_preview_generator/servers/base.py 33.33% 2 Missing ⚠️
media_preview_generator/servers/plex.py 85.71% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #272      +/-   ##
==========================================
+ Coverage   83.97%   84.00%   +0.03%     
==========================================
  Files          89       89              
  Lines       19599    19632      +33     
==========================================
+ Hits        16458    16492      +34     
+ Misses       3141     3140       -1     
Files with missing lines Coverage Δ
media_preview_generator/servers/_embyish.py 84.55% <100.00%> (+0.15%) ⬆️
media_preview_generator/servers/jellyfin.py 83.08% <100.00%> (+0.02%) ⬆️
media_preview_generator/servers/base.py 82.92% <33.33%> (-0.74%) ⬇️
media_preview_generator/servers/plex.py 81.16% <85.71%> (+0.09%) ⬆️
media_preview_generator/web/webhook_router.py 80.61% <81.81%> (+0.93%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stevezau stevezau merged commit f6a5e80 into dev Jun 29, 2026
14 checks passed
@stevezau stevezau deleted the fix/multiversion-webhook-and-offmedia-reg branch June 29, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant