Skip to content

refactor(server): share Jellyfin/Emby API implementations via ServerDialect#895

Open
MathiasDevelopes wants to merge 1 commit into
Moonfin-Client:mainfrom
MathiasDevelopes:refactor/server-api-dedupe
Open

refactor(server): share Jellyfin/Emby API implementations via ServerDialect#895
MathiasDevelopes wants to merge 1 commit into
Moonfin-Client:mainfrom
MathiasDevelopes:refactor/server-api-dedupe

Conversation

@MathiasDevelopes

@MathiasDevelopes MathiasDevelopes commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

The Jellyfin and Emby API implementations were ~90% copy-pasted (~1,900 duplicated lines across 24 files). Both servers speak the same API with small, enumerable differences.

Behavior unifications (previously drifted copies):

  • 5-min caches for user views and display preferences now apply to Jellyfin too (Emby already had them).
  • Ancestors and special-features lookups fail gracefully on both.
  • Jellyfin image/playback URLs resolve baseUrl lazily, fixing stale URLs after a server URL change.
  • Image query params are URL-encoded on both servers.
  • Emby now logs network requests/responses/errors like Jellyfin already did (shared attachServerInterceptors).

Tests: twin playback/live_tv test pairs merged into server_core, plus a new dialect test pinning per-server paths and capability gates.

Pull Request

Summary

This PR deduplicates Jellyfin/Emby API logic, by consolidating common logic and storing the differences in a ServerDialect class.

AI Assistance

Refactor plan and implementation were generated by Kimi K3 (Moonshot AI).
I spot-checked key files rather than reviewing the full diff line-by-line,
and tested the build against a Jellyfin and Emby server (see Test Steps).

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • UI/UX update
  • Documentation update
  • Build/CI change
  • Other (describe):

Changes Made

  • Add ServerDialect capturing auth scheme, user-scoped vs user-less endpoint paths, capability flags (QuickConnect, lyrics, media segments, remote subtitle search), api_key image auth and the per-server display-preferences client name.
  • Move the 12 duplicated API implementations into server_core as dialect-parameterized Server*Api classes.
  • Extract shared interceptor wiring (auth header, redirects, network logging) into attachServerInterceptors.
  • Both media server clients are now thin wiring shells; package names and client classes unchanged, so app code is untouched.

Platform

  • Android
  • iOS
  • tvOS
  • Web
  • macOS
  • Windows
  • Linux
  • All / Shared code

Testing

Describe how this change was tested.

  • Tested on emulator / simulator
  • Tested on physical device
  • Manual testing completed
  • Not tested (explain why):

Test Steps

Tested Linux build against Jellyfin and Emby server, verified that login, library browsing, playback, favorites, and resume working.

Checklist

  • Code builds successfully
  • Code follows project style and conventions
  • No unnecessary commented-out code
  • No new warnings introduced

@MathiasDevelopes MathiasDevelopes changed the title refactor(server): share Jellyfin/Emby API implementations via ServerD… refactor(server): share Jellyfin/Emby API implementations via ServerDialect Jul 21, 2026
@MathiasDevelopes
MathiasDevelopes marked this pull request as ready for review July 22, 2026 01:11
Copilot AI review requested due to automatic review settings July 22, 2026 01:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…ialect

The Jellyfin and Emby API implementations were ~90% copy-pasted
(~1,900 duplicated lines across 24 files). Both servers speak the
same API with small, enumerable differences.

- Add ServerDialect capturing auth scheme, user-scoped vs user-less
  endpoint paths, capability flags (QuickConnect, lyrics, media
  segments, remote subtitle search), api_key image auth and the
  per-server display-preferences client name.
- Move the 12 duplicated API implementations into server_core as
  dialect-parameterized Server*Api classes.
- Extract shared interceptor wiring (auth header, redirects, network
  logging) into attachServerInterceptors.
- Both media server clients are now thin wiring shells; package
  names and client classes unchanged, so app code is untouched.

Behavior unifications (previously drifted copies):
- 5-min caches for user views and display preferences now apply to
  Jellyfin too (Emby already had them).
- Ancestors and special-features lookups fail gracefully on both.
- Jellyfin image/playback URLs resolve baseUrl lazily, fixing stale
  URLs after a server URL change.
- Image query params are URL-encoded on both servers.

Tests: twin playback/live_tv test pairs merged into server_core, plus
a new dialect test pinning per-server paths and capability gates.
@MathiasDevelopes
MathiasDevelopes force-pushed the refactor/server-api-dedupe branch from 211a57a to 0f32624 Compare July 22, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants