Skip to content

fix(jellycompat): Wholphin (jellyfin-sdk-kotlin) playback & genre compatibility - #100

Merged
Quick104 merged 4 commits into
Silo-Server:mainfrom
d3v1l1989:fix/jellyfin-compat-wholphin
Jun 9, 2026
Merged

Quick104 merged 4 commits into
Silo-Server:mainfrom
d3v1l1989:fix/jellyfin-compat-wholphin

Conversation

@d3v1l1989

@d3v1l1989 d3v1l1989 commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Three independent fixes to the Jellyfin-compatibility API, each addressing a case where the Wholphin Android TV client (jellyfin-sdk-kotlin / Media3 ExoPlayer) fails against Silo but works against upstream Jellyfin. All three were diagnosed from live request logs + client logcat and verified against a populated server.

1. Match MediaSourceId across UUID formats (compact vs dashed)

PlaybackInfo and the stream/route resolvers compared a client-supplied MediaSourceId to the canonical source id with raw string equality. Silo emits the dashed compat UUID (03000000-0000-0000-0000-00000019e8c2); Wholphin echoes it back in the compact 32-char form (0300000000000000000000000019e8c2). Same UUID, different bytes → 404 Media source not found.

Fix: a mediaSourceIDsEqual helper (exact match fast-path, else compare uuid.Parse'd values) used at all four match sites (HandlePlaybackInfo, audioSelectionChanged, setSelectedAudioStream, findMediaSource). The decoder already accepted both forms — only the comparisons were wrong.

2. Honor ImageTypes=Backdrop as a filter on /Items

ImageTypes was parsed nowhere, so /Items?imageTypes=Backdrop&limit=1&sortBy=Random (Wholphin genre cards) could return items with BackdropImageTags: null, which the client assumes are present. The filter is pushed down to the catalog browse SQL (BrowseFilters.RequireBackdrop → NULLIF(BTRIM(mi.backdrop_path), '') IS NOT NULL) so random/limited selections only ever consider backdrop-having items; an empty genre correctly returns []. (Filtering after the LIMIT would wrongly return empty pages.)

3. Case-insensitive PlaySessionId (and api_key) in stream auth

Wholphin's jellyfin-sdk-kotlin builds its own direct-play URL — /Videos/{id}/stream?static=true&playSessionId=…&mediaSourceId=… — with a lowercase playSessionId, no api_key, and no auth header (ExoPlayer's data source doesn't forward it). PlaybackSessionAuth resolved PlaySessionId/PlaySessionID case-sensitively (Go's url.Values.Get), so the playback-session fallback never matched → 401 on every direct-play request → the client was forced into a needless transcode fallback. Resolved via the existing case-insensitive query helper; ExtractToken's api_key lookup is made case-insensitive too for the same class of issue. (Silo's own HLS segment URLs use capital PlaySessionId, so those always worked — which masked the bug.)

Testing

  • New unit tests: TestMediaSourceIDsEqual, TestParseItemsQuery_ImageTypesBackdropFilter, TestPlaybackSessionAuth_CaseInsensitivePlaySessionId (incl. the exact lowercase-playSessionId repro), TestExtractToken_CaseInsensitiveAPIKey.
  • go vet + go build clean; go test ./internal/jellycompat/ passes.
  • Verified live: Wholphin PlaybackInfo, genre cards, and direct-play all work after the fixes.

Notes

Each fix is in its own commit. No new DB migrations. The backdrop predicate is parameterless and operates on already-filtered rows.

Summary by CodeRabbit

  • New Features

    • Option to filter browse results to items that have backdrop images.
    • Backdrop-specific image requests supported via image-type query.
  • Improvements

    • Authentication now reads API keys and playback session parameters case-insensitively.
    • Media-source ID matching improved to handle differing identifier formats consistently.
    • Season counts included in series/item responses and season listing pagination corrected.
  • Tests

    • Added tests covering case-insensitive auth, backdrop filtering, media-source ID matching, and season handling.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 59a79a63-3e9d-4106-8415-ae8ae16863e1

📥 Commits

Reviewing files that changed from the base of the PR and between 7486c635a39b9e343f69fd1c77e950753da9f4e9 and 277766e.

📒 Files selected for processing (17)
  • internal/catalog/browse.go
  • internal/catalog/browse_backdrop_test.go
  • internal/jellycompat/auth.go
  • internal/jellycompat/auth_test.go
  • internal/jellycompat/content_direct.go
  • internal/jellycompat/dto.go
  • internal/jellycompat/handlers_items.go
  • internal/jellycompat/handlers_items_test.go
  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/idcodec.go
  • internal/jellycompat/idcodec_mediasource_test.go
  • internal/jellycompat/mapping.go
  • internal/jellycompat/mapping_sort_test.go
  • internal/jellycompat/playback_sessions.go
  • internal/jellycompat/query.go
  • internal/jellycompat/query_imagetypes_test.go
  • internal/jellycompat/streams.go

📝 Walkthrough

Walkthrough

This PR adds backdrop filtering to browse requests, makes Jellyfin-compatible query parameter lookups case-insensitive for auth and playback session IDs, and compares media-source IDs by UUID equivalence to tolerate format variations.

Changes

Jellyfin Compatibility Improvements

Layer / File(s) Summary
Backdrop filter support
internal/catalog/browse.go, internal/catalog/browse_backdrop_test.go, internal/jellycompat/query.go, internal/jellycompat/content_direct.go, internal/jellycompat/query_imagetypes_test.go
Adds BrowseFilters.RequireBackdrop; parse ImageTypes=Backdrop into require_backdrop; propagate through buildBrowseParams and browse calls; catalog buildBrowsePlan emits a WHERE predicate requiring a non-empty backdrop_path. Tests verify parsing and SQL predicate presence.
Case-insensitive query parameter handling
internal/jellycompat/auth.go, internal/jellycompat/auth_test.go, internal/jellycompat/streams.go
ExtractToken and playback-session lookups now use case-insensitive query extraction for api_key / PlaySessionId. Streaming handlers also read PlaySessionId case-insensitively. Tests cover varied casing for API key and play session id.
UUID-normalized media-source ID matching
internal/jellycompat/idcodec.go, internal/jellycompat/idcodec_mediasource_test.go, internal/jellycompat/streams.go, internal/jellycompat/handlers_playback.go, internal/jellycompat/playback_sessions.go
Adds mediaSourceIDsEqual() comparing parsed UUIDs (with exact-string fast path) and replaces direct string equality checks in playback/stream selection and session route lookup. Tests validate dashed/compact/hex and non-UUID fallback behaviors.
Season listing, DTO counts, and handlers
internal/jellycompat/dto.go, internal/jellycompat/handlers_items.go, internal/jellycompat/handlers_items_test.go, internal/jellycompat/mapping.go, internal/jellycompat/mapping_sort_test.go
Adds SeasonCount to DTOs and mappings, routes season-child queries to a dedicated handler with pagination, updates response TotalRecordCount/StartIndex semantics, and adds tests for season paging and mapped season counts.

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main changes: fixing Jellyfin-compatibility issues for the Wholphin (jellyfin-sdk-kotlin) client. It directly relates to the substantive changes across multiple files addressing playback and genre compatibility.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

d3v1l1989 added 3 commits June 8, 2026 16:35
Wholphin genre cards request /Items?imageTypes=Backdrop&limit=1&sortBy=Random
and assume every returned item has a backdrop. Silo ignored ImageTypes, so a
random pick could lack a backdrop (BackdropImageTags: null), crashing Wholphin.

Push the filter down to the catalog browse SQL
(NULLIF(BTRIM(backdrop_path),'') IS NOT NULL) so random/limited selections only
ever consider backdrop-having items; empty genres correctly return [].
…auth

Wholphin's jellyfin-sdk-kotlin builds its own direct-play URL
(/Videos/{id}/stream?static=true&playSessionId=...&mediaSourceId=...) with a
lowercase 'playSessionId', no api_key, and no auth header (ExoPlayer's data
source drops it). PlaybackSessionAuth read 'PlaySessionId'/'PlaySessionID'
case-sensitively, so the fallback never matched -> 401 on every direct-play
stream -> forced (often failing) transcode fallback. Resolve PlaySessionId via
newCaseInsensitiveQuery, and likewise accept case-variant api_key in
ExtractToken.
@d3v1l1989
d3v1l1989 force-pushed the fix/jellyfin-compat-wholphin branch from 7486c63 to a5cdd06 Compare June 8, 2026 23:37
@Quick104
Quick104 merged commit 6a69584 into Silo-Server:main Jun 9, 2026
1 check was pending
Quick104 added a commit that referenced this pull request Jun 11, 2026
…patibility (#100)

* fix(jellycompat): match MediaSourceId across UUID formats (compact vs dashed)

* fix(jellycompat): honor ImageTypes=Backdrop as a filter on /Items

Wholphin genre cards request /Items?imageTypes=Backdrop&limit=1&sortBy=Random
and assume every returned item has a backdrop. Silo ignored ImageTypes, so a
random pick could lack a backdrop (BackdropImageTags: null), crashing Wholphin.

Push the filter down to the catalog browse SQL
(NULLIF(BTRIM(backdrop_path),'') IS NOT NULL) so random/limited selections only
ever consider backdrop-having items; empty genres correctly return [].

* fix(jellycompat): case-insensitive PlaySessionId + api_key in stream auth

Wholphin's jellyfin-sdk-kotlin builds its own direct-play URL
(/Videos/{id}/stream?static=true&playSessionId=...&mediaSourceId=...) with a
lowercase 'playSessionId', no api_key, and no auth header (ExoPlayer's data
source drops it). PlaybackSessionAuth read 'PlaySessionId'/'PlaySessionID'
case-sensitively, so the fallback never matched -> 401 on every direct-play
stream -> forced (often failing) transcode fallback. Resolve PlaySessionId via
newCaseInsensitiveQuery, and likewise accept case-variant api_key in
ExtractToken.

* fix(jellycompat): support Wholphin season item queries

---------

Co-authored-by: Quick <[email protected]>
Quick104 added a commit that referenced this pull request Jun 17, 2026
…patibility (#100)

* fix(jellycompat): match MediaSourceId across UUID formats (compact vs dashed)

* fix(jellycompat): honor ImageTypes=Backdrop as a filter on /Items

Wholphin genre cards request /Items?imageTypes=Backdrop&limit=1&sortBy=Random
and assume every returned item has a backdrop. Silo ignored ImageTypes, so a
random pick could lack a backdrop (BackdropImageTags: null), crashing Wholphin.

Push the filter down to the catalog browse SQL
(NULLIF(BTRIM(backdrop_path),'') IS NOT NULL) so random/limited selections only
ever consider backdrop-having items; empty genres correctly return [].

* fix(jellycompat): case-insensitive PlaySessionId + api_key in stream auth

Wholphin's jellyfin-sdk-kotlin builds its own direct-play URL
(/Videos/{id}/stream?static=true&playSessionId=...&mediaSourceId=...) with a
lowercase 'playSessionId', no api_key, and no auth header (ExoPlayer's data
source drops it). PlaybackSessionAuth read 'PlaySessionId'/'PlaySessionID'
case-sensitively, so the fallback never matched -> 401 on every direct-play
stream -> forced (often failing) transcode fallback. Resolve PlaySessionId via
newCaseInsensitiveQuery, and likewise accept case-variant api_key in
ExtractToken.

* fix(jellycompat): support Wholphin season item queries

---------

Co-authored-by: Quick <[email protected]>
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.

2 participants