feat(remote): send the client's services.<TAG>.preferences to the server in every licensing mode

This commit is contained in:
imSp4rky
2026-12-04 14:27:48 -07:00
parent 6d04d19239
commit 89b3e77d18
11 changed files with 286 additions and 19 deletions
+7
View File
@@ -68,6 +68,13 @@ unshackle dl EX 20914 # via an ALIAS
placeholders while the secrets that fill them stay out of it. Both halves
read back through the same `self.config[...]`.
!!! tip "User choices go under `preferences`"
Put each choice a user makes (a metadata language, a subtitle format) under
`preferences` in `config.yaml`, and read it from `self.config["preferences"]`.
Over `--remote`, the client's own `services.<TAG>.preferences` values reach
that block on the server with no extra code. See
[Your preferences](rest-api/remote-sessions.md#your-preferences).
!!! warning "Split across files? Use relative imports"
If your service grows beyond a single `__init__.py`, import your own
modules **relatively**:
+24 -2
View File
@@ -376,7 +376,7 @@ licence at all: each content key comes from the server vault or the client's own
and a content key that no vault holds stops the download with an error that names its KID,
when the client knows it. The create response sets `server_device` to `true` for such a
remote session. The service then uses the server's own config: the client's identity
values do not apply. The client reads the
values do not apply, but its preferences do (see [Your preferences](#your-preferences)). The client reads the
server vault only when the API key has the `server_vault` grant (or `server_cdm`); without
it, the client reads only its own vaults. The login tokens of such a remote session hold the
server's device identity, so the server keeps them: `DELETE` returns no cache files, and the
@@ -388,6 +388,27 @@ HTTP session headers and `track.data` lose their secret-looking keys, as for a s
vault first. A track that no server vault holds goes back to your device. See
[`server_vault`](../../reference/configuration/services.md).
### Your preferences
The `preferences` block of a service is the place for user choices, such as a metadata
language or a subtitle format. It is not an identity, so it crosses `--remote` in every
licensing mode, whatever CDM the client has, and no service declares anything for it:
- The client sends each entry of its own `services: <TAG>: preferences:` block in
`unshackle.yaml` that is a string, a number or a boolean. It leaves out other entries and
logs one debug line for each.
- The server merges the entries key by key over its own `preferences` block for that
service. An entry that the client sends replaces the server's value, and a config key that
the client does not send keeps the server's value. The entries never count as an identity,
and they stay when the service builds the remote session on the server's device.
- The server refuses a `preferences` value that is not an object of strings, numbers and
booleans with `INVALID_INPUT`.
A service reads its preferences from `self.config["preferences"]`, locally and over
`--remote` alike. Keep a value that changes the server's account (a profile, an account
type) out of `preferences` unless every client of the server may choose it: a server
account is shared, and the service can store the choice in its cache.
---
## Remote session lifecycle and expiry
@@ -497,7 +518,8 @@ session when the new one is stored, and the server answers the ID of another API
`no_proxy`, `profile`, `cache` (a map of `filename → base64(zlib(bytes))`),
`client_region`, `server_cdm` (`false` when the user picked the local CDM), `cdm_type`, `cdm_security_level`, `cdm_relay` (`true` when the client
answers CDM calls; a plugin `cdm_type` gets no relay), `cdm_system_id` and `cdm_device_type` (Widevine only), `service_config`
(the identity config keys the service lists in `client_config`), `plugins` (the version of each DRM plugin of the
(the identity config keys the service lists in `client_config`, and the client's
[preferences](#your-preferences)), `plugins` (the version of each DRM plugin of the
client and the values of the plugin device attributes that the plugin names in `device_facts`; see
[endpoints](endpoints.md#post-apisessioncreate)), `client` (a freeform identity
object the dashboard shows as sent), and the track-selection hints `range_`, `vcodec`,
+4 -1
View File
@@ -31,7 +31,10 @@ other values in the same section stay.
Over `--remote`, the server builds the service from its own config. The client sends only the
config keys that the service lists for a client identity, see
[your own device identity](../../dev/rest-api/remote-sessions.md#your-own-device-identity).
[your own device identity](../../dev/rest-api/remote-sessions.md#your-own-device-identity),
and the strings, numbers and booleans of its `preferences` block. Each preference that you set
replaces the server's value for that config key, in every licensing mode, see
[your preferences](../../dev/rest-api/remote-sessions.md#your-preferences).
For every other setting, the value in the server's config applies.
User- or device-specific values (API keys, account IDs, device attributes) belong in this block