Skip to content

Fix first-load track selection and media request rendering#1

Open
EclipseKnight wants to merge 3 commits intoj4ckgrey:mainfrom
EclipseKnight:fix/cavea-track-and-requests-modal
Open

Fix first-load track selection and media request rendering#1
EclipseKnight wants to merge 3 commits intoj4ckgrey:mainfrom
EclipseKnight:fix/cavea-track-and-requests-modal

Conversation

@EclipseKnight
Copy link
Collaborator

@EclipseKnight EclipseKnight commented Mar 1, 2026

I tracked a few Cavea issues that were all related to first-load behavior and request rendering.

Main problems:

  • opening a movie/episode the first time could leave audio/subtitle controls empty until refresh
  • preferred language wasn't always used for initial audio/subtitle selection
  • "based on previous item" track behavior wasn't being respected in Cavea's initial selection
  • requests were fetched but sometimes didn't show in Movie/Series rows
  • request posters sometimes didn't render in the requests modal

What I changed:

  • Api/StreamController.cs

    • resolve current user from request context and pass that user into GetPlaybackMediaSources
    • retry once when first pass comes back with no track metadata
    • return typed audio/sub entries with selected set
    • pick initial audio/sub based on user language preference with fallback behavior
    • if user has remember track selections enabled, prefer Jellyfin-provided stream indices (AudioStreamIndex / SubtitleStreamIndex and defaults) so previous-item behavior is respected
    • keep HTTP probe fallback if metadata is still empty
  • Files/wwwroot/select-to-cards.js

    • added camelCase/PascalCase-safe field reads
    • re-capture item id on SPA navigation before stream fetch
    • keep existing track UI until new data returns (avoids blank first-load controls)
    • retry stream fetch once if first response has no usable tracks
    • respect backend selected flags when building dropdown options
  • Files/wwwroot/requests.js

    • normalize status and itemType consistently
    • use tmdbMediaType as fallback for type routing
    • avoid dropping requests because of casing/type mismatch
    • normalize request image values (url(...), quotes, &) and append api_key for same-origin /Items/... poster urls

Manual checks:

  • first-open track controls now populate without refresh
  • preferred/default track selection behaves correctly on first open
  • with remember track selection enabled, next episodes respect previous audio/sub choice
  • requests modal now shows pending requests in the correct row
  • request posters render correctly

Resolve stream metadata requests in a stricter fallback order to avoid false 404s when switching versions:\n- resolve by itemId first\n- fallback to mediaSourceId as item id\n- fallback to Gelato guid in ExternalId on gelato-stream rows\n\nThis keeps version/audio/subtitle dropdown population stable when the request carries a stale/virtual item id.
@EclipseKnight
Copy link
Collaborator Author

I pushed one additional fix commit to this same branch:

dc6064a fix(streams): make metadata stream lookup resilient on version switch

Why:
During version switching, Cavea could call api/cavea/metadata/streams with an itemId that didn’t resolve to a real BaseItems.Id, which caused intermittent 404 Item not found and empty audio/subtitle dropdowns.

What changed:

Resolve by itemId first (normal path)
If not found, fallback to mediaSourceId as item id
If still not found, fallback by matching Gelato stream guid from ExternalId on gelato-stream items
Result:
Version switching now consistently returns stream metadata, and track selectors populate correctly instead of failing on first switch.

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