docs: sweep docs to zero ste_lint findings and one remote session name

This commit is contained in:
imSp4rky
2026-12-04 18:50:27 -07:00
parent 34c8fabe6f
commit 87b58190ea
34 changed files with 134 additions and 214 deletions
+6 -6
View File
@@ -82,10 +82,10 @@ Under the integrated server, an API key can do DRM licensing only through a CDM
| `playready_devices` | PlayReady `.prd` devices, by name |
!!! warning "PlayReady access is opt-in per user"
If a user entry omits `playready_devices`, the server gives that API key **no** PlayReady access, and logs a warning at startup. You must name the PlayReady devices explicitly for any API key that needs them. Widevine and PlayReady device files themselves are auto-loaded from your WVDs and PRDs directories.
If a user entry omits `playready_devices`, the server gives that API key **no** PlayReady access, and logs a warning at startup. You must name the PlayReady devices explicitly for any API key that needs them. unshackle loads the WVD and PRD files themselves from your WVDs and PRDs directories.
!!! note "Grants decide whether the server returns content keys"
The devices on an API key decide which CDM the server can use. Two grants in the same user entry decide whether the server returns content keys (`KID:KEY`) for a remote session. `server_cdm` lets the server license with those devices. `server_vault` lets a remote session that the client's own device licenses read the server vault, and the server then makes no live licence. Without either grant, the server can only proxy CDM challenges, so the client must operate its own CDM. See [`serve`](../../reference/configuration/services.md) for both grants.
!!! note "The licensing mode decides whether the server returns content keys"
The devices on an API key decide which CDM the server can use. Two config keys in the same user entry decide the [licensing modes](remote-sessions.md#licensing-modes) of its remote sessions. `server_cdm` lets the server license with those devices. `server_vault` lets a remote session that the client's own device licenses read the server vault, and the server then makes no live licence. Without either one, the server can only proxy CDM challenges, so the client must operate its own CDM. See [`serve`](../../reference/configuration/services.md) for both config keys.
### Disabling authentication
@@ -150,7 +150,7 @@ The value must match one of the configured API keys exactly (`api_secret`, or on
```
!!! tip "The reference client sets it for you"
unshackle's own [remote download](../../guide/downloading.md) client (`RemoteService`) sends `X-Secret-Key` automatically, reading the API key from your `remote_services` config. It also sends a `User-Agent` of `unshackle/<version>`. You only deal with the header directly when writing your own client.
unshackle's own [remote session](../../guide/remote-sessions.md) client (`RemoteService`) sends `X-Secret-Key` automatically, reading the API key from your `remote_services` config. It also sends a `User-Agent` of `unshackle/<version>`. You only deal with the header directly when writing your own client.
### The health check needs an API key too
@@ -303,7 +303,7 @@ See [Downloads](endpoints.md) for how the download endpoint uses these fields.
### Session IP binding (remote sessions)
The remote-download session endpoints (`/api/session/*`) add an extra check on top of the API key. When the server creates a remote session, it records the client's IP address. Any later request for that remote session must come from the **same** IP, or the server rejects it with `403 Forbidden`. Thus the server binds a remote session both to the API key that created it and to the address it came from.
The remote session endpoints (`/api/session/*`) add an extra check on top of the API key. When the server creates a remote session, it records the client's IP address. Any later request for that remote session must come from the **same** IP, or the server rejects it with `403 Forbidden`. Thus the server binds a remote session both to the API key that created it and to the address it came from.
## Transport security (HTTPS)
@@ -322,7 +322,7 @@ With `--caddy`, unshackle also starts `caddy run` using the `Caddyfile` located
| Auth header | `X-Secret-Key` |
| Query-parameter alternative | `?secret_key=` on `GET /api/download/jobs/{job_id}/events` only |
| Default bind address | `127.0.0.1:8786` |
| Failure status | `401 Unauthorized`, or `429 Too Many Requests` for a key over its rate limit |
| Failure status | `401 Unauthorized`, or `429 Too Many Requests` for an API key over its rate limit |
| Missing-header body | `{"status": 401, "message": "Secret Key is Empty."}` |
| Invalid-key body | `{"status": 401, "message": "Secret Key is Invalid."}` |
| Over-limit body | `{"status": 429, "message": "Rate limit exceeded."}`, plus a `Retry-After` header |
+1 -1
View File
@@ -1,4 +1,4 @@
# Developer Dashboard
# Server Dashboard
The dashboard endpoints show the operator of a `serve` instance what the server is doing:
version and uptime, request counts, live remote sessions, download jobs, and the recent
+5 -7
View File
@@ -129,7 +129,7 @@ Field notes:
| `needs_auth` | Whether the service overrides `authenticate()`. |
| `has_search` | Whether the service supports `POST /api/search`. |
| `anonymous_search` | Whether `POST /api/search` operates with no login for this service. The server then ignores `credentials` and `cookies` on a search. |
| `has_drm` | Whether the service overrides a Widevine or PlayReady license hook. |
| `has_drm` | Whether the service overrides a Widevine or PlayReady licence hook. |
| `pending_update` | Set to `true` while a service repository refresh waits for this service's jobs to finish before it swaps in the new code. Absent otherwise. |
| `server_accounts` | Present when the server lends its own accounts for this service: `{regions: ["ca", "gb"], global: bool}`, the regions those accounts cover. A client sends no credentials, cookies, or cache for such a service. |
| `auth_methods` | Declared or inferred auth methods, e.g. `["cookies"]`, `["credentials"]`. |
@@ -231,9 +231,7 @@ them in that mode.
`credentials` (`{username, password, extra?}`) and `cookies` (base64 of a
zlib-compressed Netscape cookie file) are the same as on
[`POST /api/session/create`](remote-sessions.md#post-apisessioncreate). `cache` is a map of cache
files in the same form: each cache key is the file path relative to the service cache
directory, with `/` separators and no `.json` suffix, and each value is base64
of the zlib-compressed file. The server writes these files into the request
files in the form that [Cache files](remote-sessions.md#cache-files) gives. The server writes these files into the request
cache directory before the service authenticates.
When you send `credentials`, `cookies` or `cache`, a successful response also
@@ -273,13 +271,13 @@ server, uses the server's own cache and returns no `cache` field.
}
```
Each serialized title carries `type` (`"episode"`, `"movie"`, `"song"`, or `"other"`), `name`, `id`, `language`, `description`, `date`, and `cover_url`. Episodes and movies add `year`. Episodes also add `series_title`, `season`, and `number`.
Each serialised title carries `type` (`"episode"`, `"movie"`, `"song"`, or `"other"`), `name`, `id`, `language`, `description`, `date`, and `cover_url`. Episodes and movies add `year`. Episodes also add `series_title`, `season`, and `number`.
!!! info "The number that `wanted` takes for a song"
A song adds `year` and its music fields, such as `artist`, `album`, `disc`, `track` and
`position`. `wanted` takes `position` when it is not `null`, else `disc` and `track` as in `"2x3"`.
These keys are sent only when the title carries them, so a title without them serializes exactly as before:
These keys are sent only when the title carries them:
| Key | Type | On | Meaning |
| --- | --- | --- | --- |
@@ -1010,7 +1008,7 @@ The server serialises every structured error raised inside a handler to the same
The [error code catalogue](errors.md#error-code-catalogue) gives the default HTTP status of each error code.
When a generic (uncategorized) exception reaches a handler, unshackle inspects its message and type to pick a code. For example, messages mentioning "connection" or "timeout" become `NETWORK_ERROR` (424, retryable), "rate limit" or "429" become `RATE_LIMITED` (429, retryable), and anything unrecognized collapses to `INTERNAL_ERROR` (422).
When a generic (uncategorised) exception reaches a handler, unshackle inspects its message and type to pick a code. For example, messages mentioning "connection" or "timeout" become `NETWORK_ERROR` (424, retryable), "rate limit" or "429" become `RATE_LIMITED` (429, retryable), and anything unrecognised collapses to `INTERNAL_ERROR` (422).
---
+4 -4
View File
@@ -8,7 +8,7 @@ matching **HTTP status**. This page documents that format and catalogues every e
code the server can send.
If you write a client against the API, read this page alongside the endpoint
reference. Each endpoint lists the specific codes it raises, and this page gives the
reference. The section of each endpoint names the specific codes it raises, and this page gives the
meanings of those codes.
!!! note "Where this comes from"
@@ -64,7 +64,7 @@ Error ref 7f3a2c: SERVICE_ERROR 422 POST /api/session/<id>/license service=EXAMP
```
Search the server log for `Error ref <ref>`. The handler's traceback, when there is one,
is directly above that line. The [developer dashboard](dashboard.md) log view also shows it.
is directly above that line. The [server dashboard](dashboard.md) log view also shows it.
### The `details` object
@@ -129,7 +129,7 @@ while the server restarts.
| `CONFLICT` | 409 | The target resource is in a state that disallows the action (retrying a running job, prioritising a non-queued job, clearing cache during an active download). |
| `SERVER_DRAINING` | 409 | The server is about to restart or stops, and starts no new remote session, remote login or download job. Open work continues. Retryable after the restart. A `dl --remote` client waits for the restart and opens a new remote session. |
| `SERVICE_ERROR` | 422 | The streaming service's API returned an error, or the service does not support the requested operation, or the service code exited (`sys.exit`). |
| `DRM_ERROR` | 422 | DRM or license acquisition failed. |
| `DRM_ERROR` | 422 | DRM or licence acquisition failed. |
| `RATE_LIMITED` | 429 | The streaming service is rate-limiting requests. Retryable. |
!!! warning "Not every `429` is `RATE_LIMITED`"
@@ -294,7 +294,7 @@ For anyone writing a consumer of the API, a durable strategy is:
HTTP status.
!!! note "Reference consumer"
unshackle's own remote-download client treats any status of `400` or above as
unshackle's own remote session client treats any status of `400` or above as
fatal, and a `200` body with `"status": "error"` and an `error_code` too: it logs
`Server error [<error_code>]: <message>` and exits. It retries a request once,
after one second, only when a `502`, `503` or `504` arrives with a body that is
+3 -4
View File
@@ -66,7 +66,7 @@ The `serve` command accepts the following flags:
| `--no-widevine` | off | Disable the Widevine CDM endpoints. Cannot be combined with `--api-only`. |
| `--no-playready` | off | Disable the PlayReady CDM endpoints. Cannot be combined with `--api-only`. |
| `--no-key` | off | Disable API-key authentication entirely; every request is allowed. |
| `--remote-only` | off | Expose only the remote-session subset of routes. Implies `--api-only`. |
| `--remote-only` | off | Expose only the [remote session routes](remote-sessions.md#routes). Implies `--api-only`. |
| `--debug-api` | off | Include tracebacks and worker stderr in error responses. |
| `--debug` | off | Enable debug-level logging. |
| `--caddy` | off | Also launch [Caddy](https://caddyserver.com/) as a reverse proxy, using the `Caddyfile` in your user-config directory. |
@@ -97,8 +97,7 @@ The routes the server mounts depend on how you start the server:
=== "`--remote-only`"
The server mounts only the remote-session subset of routes (health, services, search,
and everything under `/api/session/*`). This mode implies `--api-only`, and the
The server mounts only the [remote session routes](remote-sessions.md#routes). This mode implies `--api-only`, and the
interactive Swagger UI is **not** mounted.
=== "`--cdm-only`"
@@ -227,7 +226,7 @@ the full model, including per-key service allowlists.
<div class="grid cards" markdown>
- **[Quick Start](quickstart.md)**: start the server, set an API key, and operate your
- **[REST API Quick Start](quickstart.md)**: start the server, set an API key, and operate your
first end-to-end download over the API.
- **[Authentication](authentication.md)**: the `X-Secret-Key` header, `--no-key`,
per-key service allowlists, and CORS.
+2 -2
View File
@@ -421,10 +421,10 @@ Each job carries a cancellation event. When you `DELETE` a live job:
[remote session](../../guide/remote-sessions.md#when-the-client-ends-a-remote-session), in at most 4
seconds, and runs no post-script after the cancel.
### Secret handling in serialized jobs
### Secret handling in serialised jobs
Job parameters may carry secrets: a raw `user:pass` credential, or a proxy URL with
embedded userinfo. Whenever the manager serializes a job (for an API response or the
embedded userinfo. Whenever the manager serialises a job (for an API response or the
history file), it masks the sensitive keys (`credential`, `credentials`, `password`,
`token`, `api_key`) and strips userinfo from proxy URLs. The manager also scrubs
free-text fields that a service might have leaked a secret into (`error_message`,
+4 -4
View File
@@ -4,7 +4,7 @@ Unshackle ships with a built-in REST API that exposes the same download engine y
The full loop runs end to end: start the server, authenticate, submit a download job, and poll it to completion. The `curl` commands here come directly from the API routes.
!!! note "Who this page is for"
!!! info "Who this page is for"
This is a **developer** guide. It assumes you are comfortable with HTTP, JSON, and a tool like `curl`. If you only want to download something, the [command line](../../index.md) is simpler. The REST API is meant for building tools, UIs, and automation on top of unshackle.
---
@@ -82,7 +82,7 @@ Common options:
| `--no-key` | off | Disable API-key authentication (allow all requests) |
| `--debug-api` | off | Include tracebacks and stderr in error responses |
| `--debug` | off | Enable DEBUG-level logging |
| `--remote-only` | off | Expose only the remote-session subset of routes |
| `--remote-only` | off | Expose only the remote session routes: `/api/health`, `/api/services`, `/api/search`, `/api/session/*`, `/api/tunnel` and `/api/tunnel/check`, and the dashboard routes when `serve.dashboard.key` is set |
| `--caddy` | off | Also launch Caddy as a reverse proxy (for HTTPS) |
Once it is up you will see the API mounted under `/api/` and, unless you started in remote-only mode, an interactive Swagger UI:
@@ -386,13 +386,13 @@ A retry reuses the original job's service, title, and parameters to enqueue a br
## Beyond a single download
The download loop above is the core of the API, but the same server exposes more:
The download flow above is the core of the API, but the same server exposes more:
- **Discovery**: `POST /api/search` finds titles by query, and `POST /api/list-titles` / `POST /api/list-tracks` inspect what a title offers before you commit to downloading it. See [titles and tracks](endpoints.md).
- **History**: `GET /api/history` reads a persisted log of jobs that reached a terminal state (newest first), and `DELETE /api/history/{job_id}` removes a single entry. See [history](endpoints.md).
- **Introspection**: `GET /api/profiles` lists configured credential profiles per service, `GET /api/config` returns a redacted view of the effective server config, and `GET /api/env/check` reports which external binaries the machine has.
- **Maintenance**: `POST /api/maintenance/clear-cache`, `.../clear-temp`, and `.../refresh-services` do housekeeping (the server blocks the cache and temp clears with `409` while a download is active).
- **Remote sessions**: the `/api/session/*` endpoints drive the thin-client "remote download" flow, where the server authenticates and licenses on behalf of a local client. See [remote sessions](remote-sessions.md).
- **Remote sessions**: the routes that carry the remote sessions of `dl --remote`, where the server authenticates and licenses on behalf of a local client. See [remote sessions](remote-sessions.md).
The interactive **Swagger UI at `/api/docs/`** documents every route and lets you try them in the browser (send your `X-Secret-Key` there too).
+2 -2
View File
@@ -1,4 +1,4 @@
# Remote session protocol
# Remote Session Protocol
The remote session protocol is the one record of the routes, login states, error codes and message
shapes that a `--remote` client and the server share. A remote session keeps an authenticated
@@ -13,7 +13,7 @@ in the wire form of `unshackle/core/wire.py`. To set up `dl --remote`, read
## Routes
`unshackle serve` mounts these routes in every mode except `--cdm-only`, which keeps only
`/api/health`. `--remote-only` keeps only these routes (and the dashboard routes). Paths use the `session_id` of the create request.
`/api/health`. `--remote-only` keeps only these routes (and the dashboard routes when `serve.dashboard.key` is set). Paths use the `session_id` of the create request.
| Method | Path | Purpose |
|---|---|---|