Skip to content

Alt-backend hook so another server can answer Client calls - #827

Open
tiper wants to merge 1 commit into
GLinnik21:mainfrom
tiper:alt-backend-hook
Open

tiper wants to merge 1 commit into
GLinnik21:mainfrom
tiper:alt-backend-hook

Conversation

@tiper

@tiper tiper commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Before: plx_plex::plex::Client can only talk to a Plex server, so an app that wants to reuse PlxNative's screens, player and stores against another kind of media server has to fork the data layer.

After: behind a new alt-backend cargo feature (off in every PlxNative build, so nothing here is compiled into PlxNative), an application can install a plex::backend::Backend at boot, and the data, playback and live-update methods of Client hand their call to it and return its answer in the same model types. Without the feature, the alt! hook at the top of each method expands to nothing.

How: Backend is a trait whose every method defaults to "nothing here" (None, false, an empty path), so a Plex-only feature such as Discover or agent subtitle search simply disappears for a server without one. While a backend is installed:

  • plex.tv and the Discover provider are never contacted (calls go to a closed local port, the existing offline path), and the account's audio and subtitle preferences are read from and saved to the backend.
  • grant::PlaintextAsk::settle_vouched lets the backend's own sign-in mint a plaintext grant, under the same origin rule as mint (a numeric private-network literal, current generations, no refusal since). servers queues an endpoint re-proof (grant::strand) for a plaintext origin registered without a grant, since there is no plex.tv discovery to do it.
  • the backend can name the app (identity::app_name, used by whatever shows a name to the viewer; PRODUCT stays what a Plex server is sent) and list its own credential spellings, so http::carries_credential treats them like X-Plex-Token.
  • has_plex_home, rows_resolve_by_key, fixed_hls_available and versions give the app side the few answers that differ from Plex's.

Nothing changes for PlxNative builds.

Behind the alt-backend feature (off in every PlxNative build), the data,
playback and live-update methods of plex::Client hand their call to an
installed plex::backend::Backend and return its answer; without the
feature the alt! hook expands to nothing and the code is what ships today.

While a backend is installed, plex.tv is never contacted, the account's
audio and subtitle preferences are read from and saved to the backend, a
sign-in the backend vouches for may use a plaintext private-network
origin, and the backend may name the app and its own credential
spellings so the plaintext policy sees them.

This change was drafted with an AI assistant (Claude Code).

Signed-off-by: Tiago Pereira <1698241+tiper@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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