mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-05 07:25:08 +00:00
docs: give each dl and serve flag and the error envelope one owner page and tighten the cli-reference test
This commit is contained in:
@@ -18,9 +18,7 @@ Start the server with [`unshackle serve`](../../guide/cli-reference.md). By defa
|
|||||||
- **Compression.** JSON responses of 256 bytes or more are gzip-compressed when the client sends `Accept-Encoding: gzip`. A [slow response](remote-sessions.md#slow-responses) is not compressed.
|
- **Compression.** JSON responses of 256 bytes or more are gzip-compressed when the client sends `Accept-Encoding: gzip`. A [slow response](remote-sessions.md#slow-responses) is not compressed.
|
||||||
- **Service allowlist.** The effective allowlist for your API key filters the service-facing endpoints (the intersection of the global `serve.services` list and your per-key list). The server treats services you cannot use as unknown.
|
- **Service allowlist.** The effective allowlist for your API key filters the service-facing endpoints (the intersection of the global `serve.services` list and your per-key list). The server treats services you cannot use as unknown.
|
||||||
- **Remote services.** A full-mode server can run a service through one of its own `remote_services` servers. See [Remote services relay](#remote-services-relay).
|
- **Remote services.** A full-mode server can run a service through one of its own `remote_services` servers. See [Remote services relay](#remote-services-relay).
|
||||||
|
- **Errors.** [Error Responses](errors.md) gives the [standard error shape](errors.md#the-standard-error-shape) and the [authentication error](errors.md#the-authentication-error-exception) of the API-key middleware.
|
||||||
!!! warning "Error responses have two shapes"
|
|
||||||
Structured application errors (raised inside a handler) return `{"status": "error", "error_code": "...", "message": "...", "timestamp": "..."}`. The authentication middleware, however, returns a **different** shape: `{"status": 401, "message": "..."}` with an integer `status` and no `error_code`. The same middleware answers `429` in that shape when an API key goes over its rate limit. Clients must accept both shapes. The [Error responses](#error-responses) section at the bottom of this page gives the full error model.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -439,7 +437,7 @@ Make a download job. It requires `service` and `title_id`. Every other field is
|
|||||||
|
|
||||||
<!-- download-fields -->
|
<!-- download-fields -->
|
||||||
|
|
||||||
**Validation.** Invalid values return `400 INVALID_PARAMETERS`. `vcodec`, `acodec` and `sub_format` take the same spellings as the CLI options of the same name (`unshackle dl --help` prints each list). The API and the CLI read one list, so they cannot disagree. `range` must be one of SDR/HDR10/HDR10P/VIVID/DV/HLG/HYBRID, and `HDR10+` and `HDR Vivid` are also valid. The bitrate, download worker, and download counts must be positive integers. You cannot combine `no_subs` with `subs_only`, or `no_audio` with `audio_only`. The server runs the same option checks as `unshackle dl`, so a request that `dl` would refuse returns `400` when you submit it, and the message names the `dl` option. The language fields (`lang`, `v_lang`, `a_lang`, `s_lang`, `forced_s_lang` and the `require_*` fields) must be arrays of strings: a single string such as `"en"` returns `400`. The server checks every other field with the type of its `dl` option. A `null` or an empty string gets the default from the table.
|
**Validation.** Invalid values return `400 INVALID_PARAMETERS`. `vcodec`, `acodec` and `sub_format` take the same spellings as the CLI options of the same name (`unshackle dl --help` prints each list). The API and the CLI read one list, so they cannot disagree. You cannot combine `no_subs` with `subs_only`, or `no_audio` with `audio_only`. The server runs the same option checks as `unshackle dl`, so a request that `dl` would refuse returns `400` when you submit it, and the message names the `dl` option. The language fields (`lang`, `v_lang`, `a_lang`, `s_lang`, `forced_s_lang` and the `require_*` fields) must be arrays of strings: a single string such as `"en"` returns `400`. The server checks every other field with the type of its `dl` option. A `null` or an empty string gets the default from the table.
|
||||||
|
|
||||||
**Service options.** A service's own CLI options travel in the same body. Send them in a nested
|
**Service options.** A service's own CLI options travel in the same body. Send them in a nested
|
||||||
`service_params` object, or as flat top-level keys. When the body has `service_params`, the server
|
`service_params` object, or as flat top-level keys. When the body has `service_params`, the server
|
||||||
@@ -981,37 +979,6 @@ Answer the prompt of a remote login. Body: `{ "response": "..." }` (required).
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Error responses
|
|
||||||
|
|
||||||
The server serialises every structured error raised inside a handler to the same JSON envelope:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"status": "error",
|
|
||||||
"error_code": "INVALID_PARAMETERS",
|
|
||||||
"message": "Invalid video codec: XYZ",
|
|
||||||
"timestamp": "2026-07-03T12:00:00+00:00",
|
|
||||||
"details": { "field": "vcodec" },
|
|
||||||
"retryable": true,
|
|
||||||
"debug_info": { "exception_type": "APIError", "traceback": "..." }
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
- `details` appears only when non-empty.
|
|
||||||
- `retryable` appears only when the error is retryable (e.g. network errors, rate limiting).
|
|
||||||
- `debug_info` appears only when you start the server with `--debug-api`.
|
|
||||||
|
|
||||||
!!! warning "Authentication errors differ"
|
|
||||||
Errors raised by the API-key middleware use a distinct shape (`{"status": 401, "message": "Secret Key is Empty."}`, `{"status": 401, "message": "Secret Key is Invalid."}`, or `{"status": 429, "message": "Rate limit exceeded."}` with a `Retry-After` header) with an integer `status` and no `error_code`, `timestamp`, or `details`. A `429` from the middleware therefore carries no `error_code`, unlike the `RATE_LIMITED` code below, which a handler raises for a rate limit the *service* imposed. A malformed JSON body on any POST, by contrast, returns the standard envelope with `error_code: "INVALID_INPUT"`.
|
|
||||||
|
|
||||||
### Error codes and default status
|
|
||||||
|
|
||||||
The [error code catalogue](errors.md#error-code-catalogue) gives the default HTTP status of each error code.
|
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [Server Overview](index.md). What the server is and when to use it.
|
- [Server Overview](index.md). What the server is and when to use it.
|
||||||
|
|||||||
@@ -55,21 +55,8 @@ pywidevine / pyplayready clients) in addition to the REST API.
|
|||||||
|
|
||||||
### Common options
|
### Common options
|
||||||
|
|
||||||
The `serve` command accepts the following flags:
|
The [`serve` options](../../guide/cli-reference.md#serve) in the CLI reference give each flag, its
|
||||||
|
default and the flags that you cannot use together.
|
||||||
| Option | Default | Effect |
|
|
||||||
|---|---|---|
|
|
||||||
| `-h`, `--host` | `127.0.0.1` | Address to bind to. Use `0.0.0.0` to accept connections from other machines. |
|
|
||||||
| `-p`, `--port` | `8786` | Port to bind to. |
|
|
||||||
| `--api-only` | off | Serve only the REST API, without the Widevine/PlayReady CDM HTTP endpoints. |
|
|
||||||
| `--cdm-only` | off | Serve only the Widevine/PlayReady CDM HTTP endpoints, plus `/api/health` and the dashboard. No REST API, no remote sessions, no Swagger UI. Cannot be combined with `--api-only` or `--remote-only`. |
|
|
||||||
| `--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 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. |
|
|
||||||
|
|
||||||
```shell title="Serve the REST API only, on all interfaces"
|
```shell title="Serve the REST API only, on all interfaces"
|
||||||
unshackle serve --api-only --host 0.0.0.0 --port 8786
|
unshackle serve --api-only --host 0.0.0.0 --port 8786
|
||||||
|
|||||||
@@ -72,18 +72,7 @@ unshackle serve --api-only
|
|||||||
|
|
||||||
By default the server binds to `127.0.0.1:8786`. The `--api-only` flag serves only the REST API and omits the Widevine/PlayReady CDM HTTP endpoints. Drop it when you also want those endpoints.
|
By default the server binds to `127.0.0.1:8786`. The `--api-only` flag serves only the REST API and omits the Widevine/PlayReady CDM HTTP endpoints. Drop it when you also want those endpoints.
|
||||||
|
|
||||||
Common options:
|
The [`serve` options](../../guide/cli-reference.md#serve) in the CLI reference give every flag.
|
||||||
|
|
||||||
| Option | Default | Effect |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| `-h, --host` | `127.0.0.1` | Address to bind to |
|
|
||||||
| `-p, --port` | `8786` | Port to bind to |
|
|
||||||
| `--api-only` | off | Serve only the REST API, no CDM endpoints |
|
|
||||||
| `--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 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:
|
Once it is up you will see the API mounted under `/api/` and, unless you started in remote-only mode, an interactive Swagger UI:
|
||||||
|
|
||||||
@@ -166,7 +155,7 @@ If the API key is missing or wrong, you get a `401` with a plain body:
|
|||||||
```
|
```
|
||||||
|
|
||||||
!!! warning "Two error shapes exist"
|
!!! warning "Two error shapes exist"
|
||||||
The authentication middleware returns the short `{"status": 401, "message": "..."}` shape shown above. Every **other** error the API produces uses the richer structured shape (`error_code`, `timestamp`, `details`, ...) described in [Error handling](#error-handling). Parse both shapes in your client.
|
The authentication middleware answers with the short shape above, and every other JSON error has the [standard error shape](errors.md#the-standard-error-shape). Parse both shapes in your client.
|
||||||
|
|
||||||
The `tag` value for the service you want is the identifier you pass as `service` in the calls below.
|
The `tag` value for the service you want is the identifier you pass as `service` in the calls below.
|
||||||
|
|
||||||
@@ -400,38 +389,7 @@ The interactive **Swagger UI at `/api/docs/`** documents every route and lets yo
|
|||||||
|
|
||||||
## Error handling
|
## Error handling
|
||||||
|
|
||||||
Apart from the auth middleware's short form, every error the API returns uses a single structured envelope:
|
Every JSON error has one of two shapes: the [standard error shape](errors.md#the-standard-error-shape),
|
||||||
|
or the [authentication error](errors.md#the-authentication-error-exception) of the API-key
|
||||||
```json
|
middleware. The [error code catalogue](errors.md#error-code-catalogue) gives the HTTP status of
|
||||||
{
|
each code, and [the `retryable` hint](errors.md#the-retryable-hint) marks the errors to retry.
|
||||||
"status": "error",
|
|
||||||
"error_code": "INVALID_PARAMETERS",
|
|
||||||
"message": "Human-readable description",
|
|
||||||
"timestamp": "2026-07-03T12:00:00Z",
|
|
||||||
"details": { }
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
`details` appears only when the server has more to add. `retryable: true` appears only for transient failures. The server includes a `debug_info` block (exception type and traceback) only when it runs with `--debug-api`.
|
|
||||||
|
|
||||||
The `error_code` maps to an HTTP status. The ones you will meet most often:
|
|
||||||
|
|
||||||
| Error code | HTTP | Typical cause |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| `INVALID_INPUT` | 400 | Malformed JSON body or missing required field |
|
|
||||||
| `INVALID_SERVICE` | 400 | Unknown or disallowed service tag |
|
|
||||||
| `INVALID_PARAMETERS` | 400 | A download field failed validation |
|
|
||||||
| `AUTH_FAILED` | 401 | Service login/credential failure |
|
|
||||||
| `FORBIDDEN` | 403 | A gated field was used without server opt-in |
|
|
||||||
| `NOT_FOUND` | 404 | Title or resource does not exist |
|
|
||||||
| `JOB_NOT_FOUND` | 404 | No job with that `job_id` |
|
|
||||||
| `CONFLICT` | 409 | Illegal state transition (e.g. retry a running job) |
|
|
||||||
| `SERVICE_ERROR` | 422 | The service raised an error |
|
|
||||||
| `RATE_LIMITED` | 429 | Upstream throttling (retryable) |
|
|
||||||
| `INTERNAL_ERROR` | 422 | Unexpected server-side failure |
|
|
||||||
| `NETWORK_ERROR` | 424 | Connection/timeout reaching the service (retryable) |
|
|
||||||
|
|
||||||
The [error code catalogue](errors.md#error-code-catalogue) lists every code.
|
|
||||||
|
|
||||||
!!! tip "Retry politely"
|
|
||||||
Codes marked retryable (`NETWORK_ERROR`, `RATE_LIMITED`, `SERVICE_UNAVAILABLE`) reflect transient conditions. Back off and retry rather than hammering the server.
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# Remote Session Protocol
|
# Remote Session Protocol
|
||||||
|
|
||||||
The remote session protocol is the one record of the routes, login states, error codes and message
|
This page lists the routes, login states, error codes and message shapes that a `--remote` client
|
||||||
shapes that a `--remote` client and the server share. A remote session keeps an authenticated
|
and the server share. A remote session keeps an authenticated service on the server between
|
||||||
service on the server between requests. The client logs in one time, then asks for titles, tracks,
|
requests. The client logs in one time, then asks for titles, tracks,
|
||||||
segments and licences in the same remote session. The client downloads, decrypts and muxes.
|
segments and licences in the same remote session. The client downloads, decrypts and muxes.
|
||||||
|
|
||||||
The record is `unshackle/core/remote_protocol.py`: both the client (`unshackle/core/remote_service.py`,
|
The record is `unshackle/core/remote_protocol.py`: both the client (`unshackle/core/remote_service.py`,
|
||||||
@@ -174,7 +174,7 @@ The server keeps remote sessions in memory. A restart loses them all.
|
|||||||
| Idle time | `serve.session_ttl`. Each request and each new remote session channel starts it again. A remote session does not reach it while a request works on it or while its remote session channel is open. |
|
| Idle time | `serve.session_ttl`. Each request and each new remote session channel starts it again. A remote session does not reach it while a request works on it or while its remote session channel is open. |
|
||||||
| Idle time during the login | The larger of `session_ttl` and 600 seconds, unless the client is gone. |
|
| Idle time during the login | The larger of `session_ttl` and 600 seconds, unless the client is gone. |
|
||||||
| Client presence | See [Client presence](#client-presence). |
|
| Client presence | See [Client presence](#client-presence). |
|
||||||
| Remote sessions at the same time | `serve.max_sessions`. A create at the limit ends the least recently used remote session of the API key that holds the most. A remote session that a request works on goes last. |
|
| Remote sessions at the same time | `serve.max_sessions`. A create at the limit ends one remote session: [`max_sessions`](../../reference/configuration/services.md#serve) gives which one. |
|
||||||
| Sweep | Every 5 seconds the server ends each expired remote session. |
|
| Sweep | Every 5 seconds the server ends each expired remote session. |
|
||||||
|
|
||||||
[`serve`](../../reference/configuration/services.md#serve) in the configuration reference gives
|
[`serve`](../../reference/configuration/services.md#serve) in the configuration reference gives
|
||||||
|
|||||||
@@ -99,10 +99,10 @@ The attributes table of [`Service`][unshackle.core.service.Service] lists each o
|
|||||||
[Request and HTTP session objects](#request-and-http-session-objects) explains the main ones.
|
[Request and HTTP session objects](#request-and-http-session-objects) explains the main ones.
|
||||||
|
|
||||||
The constructor also resolves proxies: it reads `--proxy`, which `dl` and `search` have already
|
The constructor also resolves proxies: it reads `--proxy`, which `dl` and `search` have already
|
||||||
resolved through the per-service `proxy_map`, and, if `GEOFENCE` is set and you did not give an explicit proxy, does a live
|
resolved through the per-service `proxy_map`. Without an explicit proxy, it does a live IP check
|
||||||
IP check and auto-fetches a proxy to `GEOFENCE[0]` when it detects a geoblock. A
|
and, when it detects a geoblock, fetches a proxy to the first `GEOFENCE` region that `GEOBLOCK`
|
||||||
`GEOBLOCK` hit with no `GEOFENCE` stops the run with a "not available in your region"
|
allows, as the attributes of [`Service`][unshackle.core.service.Service] give. When no such region
|
||||||
error, because there is no main region to fetch a proxy for; pass `--proxy` yourself.
|
is left, the run stops with a "not available in your region" error; pass `--proxy` yourself.
|
||||||
A proxy whose exit is in a `GEOBLOCK` region stops the run the same way. A proxy whose exit is
|
A proxy whose exit is in a `GEOBLOCK` region stops the run the same way. A proxy whose exit is
|
||||||
outside `GEOFENCE` logs a warning and the run continues.
|
outside `GEOFENCE` logs a warning and the run continues.
|
||||||
See [Proxies and VPN](../guide/proxies-and-vpn.md).
|
See [Proxies and VPN](../guide/proxies-and-vpn.md).
|
||||||
|
|||||||
@@ -189,16 +189,13 @@ tags the result.
|
|||||||
|
|
||||||
### Handy first flags
|
### Handy first flags
|
||||||
|
|
||||||
| Flag | Meaning |
|
These flags shape a first download. The CLI reference gives what each one does:
|
||||||
|---|---|
|
|
||||||
| `-q`, `--quality` | Target resolution(s), e.g. `-q 1080` or `-q 1080,720`. Defaults to best available. |
|
- [`-q`/`--quality`, `-v`/`--vcodec`, `-r`/`--range`](../guide/cli-reference.md#quality-codec-bitrate-range)
|
||||||
| `-l`, `--lang` | Language(s) for video and audio, e.g. `-l en` or `-l orig,en`. `orig` = the title's original language. Defaults to `orig`. |
|
- [`-l`/`--lang`, `-sl`/`--s-lang`](../guide/cli-reference.md#language-subtitles)
|
||||||
| `-sl`, `--s-lang` | Subtitle language(s); defaults to `all`. |
|
- [`-w`/`--wanted`](../guide/cli-reference.md#title-episode-selection)
|
||||||
| `-v`, `--vcodec` | Video codec, e.g. `-v H.265`. Defaults to any. |
|
- [`-o`/`--output`](../guide/cli-reference.md#output-muxing-files)
|
||||||
| `-r`, `--range` | Dynamic range, e.g. `-r HDR10` or `-r DV`. Defaults to `SDR`. |
|
- [`--list`](../guide/cli-reference.md#concurrency-caching-listing)
|
||||||
| `-w`, `--wanted` | Which episodes, e.g. `-w S01` or `-w S01E01-S01E03`. For music, which tracks, e.g. `-w 1-5` or `-w 2x3` for disc 2 track 3. |
|
|
||||||
| `-o`, `--output` | Override the output directory for this run. |
|
|
||||||
| `--list` | List every track of each title, then stop before track selection. |
|
|
||||||
|
|
||||||
!!! example "A few realistic variations"
|
!!! example "A few realistic variations"
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
+14
-11
@@ -156,16 +156,17 @@ unshackle honours the special language tokens `orig`, `all`, and `best` everywhe
|
|||||||
|
|
||||||
Keep only certain track types, or skip certain track types.
|
Keep only certain track types, or skip certain track types.
|
||||||
|
|
||||||
| Include-only | Skip |
|
|
||||||
|---|---|
|
|
||||||
| `-V`, `--video-only` | `-nv`, `--no-video` |
|
|
||||||
| `-A`, `--audio-only` | `-na`, `--no-audio` |
|
|
||||||
| `-S`, `--subs-only` | `-ns`, `--no-subs` |
|
|
||||||
| `-C`, `--chapters-only` | `-nc`, `--no-chapters` |
|
|
||||||
| | `-nt`, `--no-attachments` (cover art, subtitle fonts, and files the service attaches) |
|
|
||||||
|
|
||||||
| Flag | Description |
|
| Flag | Description |
|
||||||
|---|---|
|
|---|---|
|
||||||
|
| `-V`, `--video-only` | Keep only the video tracks. |
|
||||||
|
| `-A`, `--audio-only` | Keep only the audio tracks. |
|
||||||
|
| `-S`, `--subs-only` | Keep only the subtitle tracks. |
|
||||||
|
| `-C`, `--chapters-only` | Keep only the chapters. |
|
||||||
|
| `-nv`, `--no-video` | Skip the video tracks. |
|
||||||
|
| `-na`, `--no-audio` | Skip the audio tracks. |
|
||||||
|
| `-ns`, `--no-subs` | Skip the subtitle tracks. |
|
||||||
|
| `-nc`, `--no-chapters` | Skip the chapters. |
|
||||||
|
| `-nt`, `--no-attachments` | Skip the attachments: cover art, subtitle fonts, and files the service attaches. |
|
||||||
| `-ad`, `--audio-description` | Include descriptive (audio-description) tracks. Without it, unshackle drops them. |
|
| `-ad`, `--audio-description` | Include descriptive (audio-description) tracks. Without it, unshackle drops them. |
|
||||||
| `-ado`, `--audio-description-only` | Keep only descriptive (audio-description) tracks; drop the standard audio. Does not need `-ad`. |
|
| `-ado`, `--audio-description-only` | Keep only descriptive (audio-description) tracks; drop the standard audio. Does not need `-ad`. |
|
||||||
| `--skip-subtitle-errors` | Skip a failed subtitle instead of aborting the title. Video/audio failures remain fatal. |
|
| `--skip-subtitle-errors` | Skip a failed subtitle instead of aborting the title. Video/audio failures remain fatal. |
|
||||||
@@ -588,16 +589,18 @@ unshackle serve [OPTIONS]
|
|||||||
|
|
||||||
| Option | Default | Description |
|
| Option | Default | Description |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `-h`, `--host` | `127.0.0.1` | Host to serve from. |
|
| `-h`, `--host` | `127.0.0.1` | Host to serve from. `0.0.0.0` accepts connections from other machines. |
|
||||||
| `-p`, `--port` | `8786` | Port to serve from. |
|
| `-p`, `--port` | `8786` | Port to serve from. |
|
||||||
| `--caddy` | off | Also serve through Caddy (requires the `caddy` binary and a `Caddyfile`). |
|
| `--caddy` | off | Also serve through Caddy as a reverse proxy, with the `Caddyfile` in your user config directory. Needs the `caddy` binary. |
|
||||||
| `--api-only` | off | Serve only the REST API, not the CDM endpoints. Incompatible with `--no-widevine`/`--no-playready`. |
|
| `--api-only` | off | Serve only the REST API, not the CDM endpoints. Incompatible with `--no-widevine`/`--no-playready`. |
|
||||||
|
| `--cdm-only` | off | Serve only the Widevine/PlayReady CDM endpoints, plus `/api/health` and the dashboard: no REST API, no remote sessions and no Swagger UI. Incompatible with `--api-only` and `--remote-only`. |
|
||||||
| `--no-widevine` | off | Disable the Widevine CDM endpoints. |
|
| `--no-widevine` | off | Disable the Widevine CDM endpoints. |
|
||||||
| `--no-playready` | off | Disable the PlayReady CDM endpoints. |
|
| `--no-playready` | off | Disable the PlayReady CDM endpoints. |
|
||||||
| `--no-key` | off | Disable API-key authentication (allows all requests). |
|
| `--no-key` | off | Disable API-key authentication (allows all requests). |
|
||||||
| `--debug-api` | off | Include tracebacks/stderr in API error responses. |
|
| `--debug-api` | off | Include tracebacks/stderr in API error responses. |
|
||||||
| `--debug` | off | Enable debug logging for API operations. |
|
| `--debug` | off | Enable debug logging for API operations. |
|
||||||
| `--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. Implies `--api-only`. |
|
| `--remote-only` | off | Expose only the [remote session routes](../dev/rest-api/remote-sessions.md#routes) and the dashboard routes when `serve.dashboard.key` is set. Implies `--api-only`. |
|
||||||
|
| `-q`, `--quiet` | off | Headless mode: no banner and no Rich output, plain log lines on stderr. With `--debug`, also writes the log to a file in `directories.logs`. |
|
||||||
|
|
||||||
WVD files in the WVDs directory and PRD files in the PRDs directory are auto-loaded. The REST API lives under `http://<host>:<port>/api/`, with Swagger UI at `/api/docs/` and a health check at `/api/health`.
|
WVD files in the WVDs directory and PRD files in the PRDs directory are auto-loaded. The REST API lives under `http://<host>:<port>/api/`, with Swagger UI at `/api/docs/` and a health check at `/api/health`.
|
||||||
|
|
||||||
|
|||||||
@@ -25,13 +25,8 @@ When a download finishes, unshackle builds the final path from three pieces:
|
|||||||
```
|
```
|
||||||
The folder name comes from the `series` folder template and the file from the `series` output template.
|
The folder name comes from the `series` folder template and the file from the `series` output template.
|
||||||
|
|
||||||
Two command-line flags change this layout for a single run:
|
The [`-o`/`--output`, `--no-folder` and `--no-source` flags](cli-reference.md#output-muxing-files)
|
||||||
|
change this layout for a single run.
|
||||||
| Flag | Effect |
|
|
||||||
|---|---|
|
|
||||||
| `-o`, `--output` | Use this directory instead of `directories.downloads`. |
|
|
||||||
| `--no-folder` | Skip the per-title subfolder; write the file directly into the output directory. |
|
|
||||||
| `--no-source` | Omit the service source tag from both the filename and folder (the `{source}` variable resolves to empty). |
|
|
||||||
|
|
||||||
## Output templates
|
## Output templates
|
||||||
|
|
||||||
|
|||||||
@@ -21,15 +21,11 @@ a query to a real proxy URL: [basic static proxies](#basic-static-proxies),
|
|||||||
|
|
||||||
## The `--proxy` flag
|
## The `--proxy` flag
|
||||||
|
|
||||||
Five options on the `dl` command control proxying at download time:
|
Five options on the `dl` command control proxying at download time: `--proxy`, `--local-proxy`,
|
||||||
|
`--no-proxy`, `--no-proxy-download` and `--proxy-download`. The
|
||||||
| Option | Effect |
|
[network and proxy flags](cli-reference.md#network-proxy) give what each one does.
|
||||||
|---|---|
|
[Send the server's requests through your machine](#send-the-servers-requests-through-your-machine)
|
||||||
| `--proxy` | The proxy to use. Either an explicit URI, or a query that unshackle resolves against your configured providers. |
|
explains `--local-proxy`.
|
||||||
| `--local-proxy` | With `--remote`, send the server's service requests through your machine's own connection, or through a `--proxy` that your machine connects to. See [Send the server's requests through your machine](#send-the-servers-requests-through-your-machine). |
|
|
||||||
| `--no-proxy` | Force **all** proxy use off. No providers are initialised and no proxy query is resolved. |
|
|
||||||
| `--no-proxy-download` | Use the proxy for the manifest, licence, and authentication, but bypass it for the **downloads** themselves. |
|
|
||||||
| `--proxy-download` | Use `--proxy` for the manifest, licence, and authentication, and a different proxy for the **downloads**. Takes the same forms as `--proxy`. |
|
|
||||||
|
|
||||||
```shell title="Explicit proxy URI"
|
```shell title="Explicit proxy URI"
|
||||||
unshackle dl --proxy http://user:pass@1.2.3.4:8080 EXAMPLE 81234567
|
unshackle dl --proxy http://user:pass@1.2.3.4:8080 EXAMPLE 81234567
|
||||||
@@ -533,11 +529,8 @@ it next needs them.
|
|||||||
configuration. The resolver ID lets anyone who has it use that endpoint's proxy, so treat
|
configuration. The resolver ID lets anyone who has it use that endpoint's proxy, so treat
|
||||||
it as a secret: unshackle masks it in logs and in stored job parameters.
|
it as a secret: unshackle masks it in logs and in stored job parameters.
|
||||||
|
|
||||||
The server must run a version of unshackle that knows `controld://`. An older server
|
A bare region, such as `--proxy ca`, skips Control D with `--remote`, because the proxy it
|
||||||
rejects it with `INVALID_PROXY`: `Proxy provider 'controld' not found` when your API key
|
gives is on your machine. A service whose accounts the server manages does not accept a proxy from the
|
||||||
has `server_proxy`, else a message that asks for a full proxy URI. A bare region, such
|
|
||||||
as `--proxy ca`, skips Control D with `--remote`, because the proxy it gives is on your
|
|
||||||
machine. A service whose accounts the server manages does not accept a proxy from the
|
|
||||||
client, and that includes a Control D resolver.
|
client, and that includes a Control D resolver.
|
||||||
|
|
||||||
### Troubleshooting Control D
|
### Troubleshooting Control D
|
||||||
|
|||||||
+3
-14
@@ -79,20 +79,9 @@ You normally do not need to think about any of this. It gives a clean file.
|
|||||||
## Selecting and filtering subtitles
|
## Selecting and filtering subtitles
|
||||||
|
|
||||||
Subtitle selection happens through `dl` flags. The most important is language selection.
|
Subtitle selection happens through `dl` flags. The most important is language selection.
|
||||||
|
The [language and subtitle flags](cli-reference.md#language-subtitles) give the meaning and
|
||||||
| Flag | Purpose |
|
default of each one. `--subs-only`, `--no-subs` and `--skip-subtitle-errors` are with the
|
||||||
| --- | --- |
|
[track-type flags](cli-reference.md#track-type-inclusion-exclusion).
|
||||||
| `-sl`, `--s-lang` | Language(s) wanted for subtitles. Defaults to `all`. A `-` prefix excludes, e.g. `all,-es`. |
|
|
||||||
| `--require-subs` | Require these languages to exist. The title fails if one is missing. `--s-lang` still decides what to keep. |
|
|
||||||
| `-fs`, `--forced-subs` | Include forced subtitle tracks (excluded by default). |
|
|
||||||
| `-fso`, `--forced-subs-only` | Keep only forced subtitle tracks and drop the other subtitles; implies `-fs`. |
|
|
||||||
| `-fsl`, `--forced-s-lang` | Language(s) wanted for forced subtitles; implies `-fs`. A `-` prefix excludes. |
|
|
||||||
| `--exact-lang` | A tag without a region never falls back to another variant: `es` does not match `es-419`. |
|
|
||||||
| `-S`, `--subs-only` | Download only subtitle tracks. |
|
|
||||||
| `-ns`, `--no-subs` | Do not download subtitle tracks at all. |
|
|
||||||
| `--sub-format` | Output subtitle format / conversion target (see [conversion](#converting-subtitle-formats)). |
|
|
||||||
| `--sub-font` | Font for subtitles converted to ASS; implies `--sub-format ass` (see [custom font and style](#custom-font-and-style)). |
|
|
||||||
| `--skip-subtitle-errors` | Skip a subtitle that fails to download instead of aborting the whole title. |
|
|
||||||
|
|
||||||
### Choosing languages
|
### Choosing languages
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ Where the file lives, how unshackle discovers it, and how to edit it:
|
|||||||
| [Directories](directories.md) | `directories`, `filenames`, `services_repo_force` |
|
| [Directories](directories.md) | `directories`, `filenames`, `services_repo_force` |
|
||||||
| [Services & authentication](services.md) | `services`, `credentials`, `firefox_cookies`, `remote_services`, `serve` |
|
| [Services & authentication](services.md) | `services`, `credentials`, `firefox_cookies`, `remote_services`, `serve` |
|
||||||
| [Download & processing](download.md) | `dl`, `continue_downloads`, `merge_segments`, `subtitle`, `audio`, `muxing`, `language_tags`, `dual_multi_mode`, `generate_dv_mode`, `hdr10plus_probe` |
|
| [Download & processing](download.md) | `dl`, `continue_downloads`, `merge_segments`, `subtitle`, `audio`, `muxing`, `language_tags`, `dual_multi_mode`, `generate_dv_mode`, `hdr10plus_probe` |
|
||||||
| [Output & naming](output.md) | `output_template`, `tag`, `tag_rules`, `codec_names`, `tag_group_name`, `tag_imdb_tmdb`, `chapter_fallback_name`, `unicode_filenames`, `filename_replacements` |
|
| [Output & naming options](output.md) | `output_template`, `tag`, `tag_rules`, `codec_names`, `tag_group_name`, `tag_imdb_tmdb`, `chapter_fallback_name`, `unicode_filenames`, `filename_replacements` |
|
||||||
| [DRM & CDM](drm.md) | `cdm`, `remote_cdm`, `decryption`, `decrypt_segments` |
|
| [DRM & CDM](drm.md) | `cdm`, `remote_cdm`, `decryption`, `decrypt_segments` |
|
||||||
| [Network & proxy](network.md) | `network`, `headers`, `proxy_providers` |
|
| [Network & proxy](network.md) | `network`, `headers`, `proxy_providers` |
|
||||||
| [Key vaults](vaults.md) | `key_vaults`, `vault_timeout` |
|
| [Key vault options](vaults.md) | `key_vaults`, `vault_timeout` |
|
||||||
| [Post-scripts](post-scripts.md) | `post_scripts` |
|
| [Post-scripts](post-scripts.md) | `post_scripts` |
|
||||||
| [External API keys](misc.md#external-api-keys) | `omdb_api_key`, `tmdb_api_key`, `tvdb_api_key`, `tvdb_pin`, `tvdb_order`, `simkl_client_id`, `metadata_providers`, `anilist_title_language`, `disable_metadata`, `decrypt_labs_api_key`, `ipinfo_api_key` |
|
| [External API keys](misc.md#external-api-keys) | `omdb_api_key`, `tmdb_api_key`, `tvdb_api_key`, `tvdb_pin`, `tvdb_order`, `simkl_client_id`, `metadata_providers`, `anilist_title_language`, `disable_metadata`, `decrypt_labs_api_key`, `ipinfo_api_key` |
|
||||||
| [Caching & updates](misc.md#caching-updates) | `title_cache_enabled`, `title_cache_time`, `title_cache_max_retention`, `update_checks`, `update_check_interval` |
|
| [Caching & updates](misc.md#caching-updates) | `title_cache_enabled`, `title_cache_time`, `title_cache_max_retention`, `update_checks`, `update_check_interval` |
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
# Network & Proxy { #network-proxy }
|
# Network & Proxy { #network-proxy }
|
||||||
|
|
||||||
|
Keys that control the HTTP client, the headers that it sends and the proxy providers. For how
|
||||||
|
`--proxy` picks a proxy, see the [Proxies & VPN guide](../../guide/proxies-and-vpn.md).
|
||||||
|
|
||||||
## `network`
|
## `network`
|
||||||
|
|
||||||
- **Type:** `dict` · **Default:** `{}`
|
- **Type:** `dict` · **Default:** `{}`
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Output & Naming { #output-naming }
|
# Output & Naming Options { #output-naming }
|
||||||
|
|
||||||
Keys that control the output filename, the per-title subfolder, release-group tagging, and
|
Keys that control the output filename, the per-title subfolder, release-group tagging, and
|
||||||
filename character handling. For how unshackle builds a path, and for worked naming examples, see
|
filename character handling. For how unshackle builds a path, and for worked naming examples, see
|
||||||
|
|||||||
@@ -161,8 +161,7 @@ works.
|
|||||||
|
|
||||||
`timeout` is the time in seconds that the client waits for data from the server. The
|
`timeout` is the time in seconds that the client waits for data from the server. The
|
||||||
default is `120`. The server sends a heartbeat every 30 seconds while it gets titles, tracks
|
default is `120`. The server sends a heartbeat every 30 seconds while it gets titles, tracks
|
||||||
or licences, so a slow service does not cause a timeout. Increase `timeout` only when the
|
or licences, so a slow service does not cause a timeout. Give a number of seconds. With a
|
||||||
server runs an older version that sends no heartbeat. Give a number of seconds. With a
|
|
||||||
value below 30 the client can time out before the first heartbeat. `0` means the default.
|
value below 30 the client can time out before the first heartbeat. `0` means the default.
|
||||||
|
|
||||||
In `--remote` mode unshackle turns the server's service list into synthetic CLI
|
In `--remote` mode unshackle turns the server's service list into synthetic CLI
|
||||||
@@ -190,7 +189,7 @@ is the [Server](../../dev/rest-api/index.md) section of the user guide. These ar
|
|||||||
| `remote_only` | bool | `false` | Expose only the [remote session routes](../../dev/rest-api/remote-sessions.md#routes) and disable the rest of the REST API. |
|
| `remote_only` | bool | `false` | Expose only the [remote session routes](../../dev/rest-api/remote-sessions.md#routes) and disable the rest of the REST API. |
|
||||||
| `dashboard` | dict | *(unset)* | Server dashboard: `key` is the API key for the read-only `/api/dashboard/` endpoints (status, remote sessions, remote session logs, jobs, keys, services, health, logs, SSE events). Unset leaves those routes unregistered, and a reload that removes the key makes them answer `404`. See [dashboard endpoints](../../dev/rest-api/dashboard.md). |
|
| `dashboard` | dict | *(unset)* | Server dashboard: `key` is the API key for the read-only `/api/dashboard/` endpoints (status, remote sessions, remote session logs, jobs, keys, services, health, logs, SSE events). Unset leaves those routes unregistered, and a reload that removes the key makes them answer `404`. See [dashboard endpoints](../../dev/rest-api/dashboard.md). |
|
||||||
| `session_ttl` | int (s) | `300` | Seconds a remote session can stay idle before it expires. An open session channel, or a request that works on the remote session, keeps it from expiring, so it does not expire during a long download. A remote session that still logs in can stay idle for the larger of this value and 600 seconds. A client that closes or loses its channel and does not come back loses its remote session sooner: see [Client presence](../../dev/rest-api/remote-sessions.md#client-presence). |
|
| `session_ttl` | int (s) | `300` | Seconds a remote session can stay idle before it expires. An open session channel, or a request that works on the remote session, keeps it from expiring, so it does not expire during a long download. A remote session that still logs in can stay idle for the larger of this value and 600 seconds. A client that closes or loses its channel and does not come back loses its remote session sooner: see [Client presence](../../dev/rest-api/remote-sessions.md#client-presence). |
|
||||||
| `max_sessions` | int or null | `100` | Maximum concurrent remote sessions; at the cap the server evicts the least recently used remote session of the API key that holds the most, and a remote session that a request works on goes last. Set it to `null` or `0` for no limit, which is also what `/api/dashboard/status` then reports, so a dashboard can tell "no cap" from a cap that happens to sit at the default. |
|
| `max_sessions` | int or null | `100` | Maximum concurrent remote sessions. At the cap, a new remote session ends one: the server picks first among the remote sessions that no request works on, then among those of the API key that holds the most, and takes the least recently used. Set it to `null` or `0` for no limit, which is also what `/api/dashboard/status` then reports, so a dashboard can tell "no cap" from a cap that happens to sit at the default. |
|
||||||
| `history_limit` | int | `100` | How many finished jobs to retain in history. |
|
| `history_limit` | int | `100` | How many finished jobs to retain in history. |
|
||||||
| `compression_level` | int | `1` | gzip level for responses. |
|
| `compression_level` | int | `1` | gzip level for responses. |
|
||||||
| `services_refresh_interval` | int (s) | `0` | How often the server pulls the git-backed service repositories in `directories.services` and hot-reloads the services that changed. `0` turns it off. A service with a running or queued job, or a live remote session, is staged and swaps to the new code as soon as its last job and session finish. |
|
| `services_refresh_interval` | int (s) | `0` | How often the server pulls the git-backed service repositories in `directories.services` and hot-reloads the services that changed. `0` turns it off. A service with a running or queued job, or a live remote session, is staged and swaps to the new code as soon as its last job and session finish. |
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Key Vaults { #key-vaults }
|
# Key Vault Options { #key-vaults }
|
||||||
|
|
||||||
Two config keys configure the key vaults. What a vault does during a download, the decode
|
Two config keys configure the key vaults. What a vault does during a download, the decode
|
||||||
check and the `kv` commands are in the [Vaults](../../guide/vaults.md) guide.
|
check and the `kv` commands are in the [Vaults](../../guide/vaults.md) guide.
|
||||||
|
|||||||
@@ -1,31 +1,49 @@
|
|||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
import click
|
||||||
|
import pytest
|
||||||
|
|
||||||
from unshackle.commands.dl import dl
|
from unshackle.commands.dl import dl
|
||||||
|
from unshackle.commands.serve import serve
|
||||||
|
|
||||||
CLI_REFERENCE = Path(__file__).parents[2] / "docs" / "guide" / "cli-reference.md"
|
CLI_REFERENCE = Path(__file__).parents[2] / "docs" / "guide" / "cli-reference.md"
|
||||||
|
|
||||||
|
COMMANDS = [pytest.param("dl", dl.cli, id="dl"), pytest.param("serve", serve, id="serve")]
|
||||||
|
|
||||||
def dl_section_flags() -> set[str]:
|
|
||||||
"""The flags that start a code span in the `dl` section of the CLI reference."""
|
def section(command: str) -> str:
|
||||||
text = CLI_REFERENCE.read_text(encoding="utf-8")
|
text = CLI_REFERENCE.read_text(encoding="utf-8")
|
||||||
start = text.index("## `dl`")
|
start = text.index(f"## `{command}`")
|
||||||
section = text[start : text.index("\n## ", start)]
|
return text[start : text.index("\n## ", start)]
|
||||||
return set(re.findall(r"`(--?[a-zA-Z][\w-]*)", section))
|
|
||||||
|
|
||||||
|
|
||||||
def dl_option_flags() -> set[str]:
|
def table_flags(command: str) -> set[str]:
|
||||||
|
"""The flags in the first cell of each table row of one command's section of the CLI reference."""
|
||||||
return {
|
return {
|
||||||
flag
|
flag
|
||||||
for param in dl.cli.params
|
for line in section(command).splitlines()
|
||||||
if param.param_type_name == "option" and not param.hidden
|
if line.startswith("|")
|
||||||
|
for flag in re.findall(r"`(--?[a-zA-Z][\w-]*)[` ]", line.split("|")[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def option_flags(command: click.Command) -> set[str]:
|
||||||
|
return {
|
||||||
|
flag
|
||||||
|
for param in command.params
|
||||||
|
if param.param_type_name == "option" and not getattr(param, "hidden", False)
|
||||||
for flag in (*param.opts, *param.secondary_opts)
|
for flag in (*param.opts, *param.secondary_opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_every_dl_option_is_in_the_cli_reference() -> None:
|
@pytest.mark.parametrize(("name", "command"), COMMANDS)
|
||||||
assert dl_option_flags() - dl_section_flags() == set()
|
def test_every_option_is_in_the_cli_reference(name: str, command: click.Command) -> None:
|
||||||
|
assert option_flags(command) - table_flags(name) == set()
|
||||||
|
|
||||||
|
|
||||||
def test_every_long_flag_in_the_cli_reference_is_a_dl_option() -> None:
|
@pytest.mark.parametrize(("name", "command"), COMMANDS)
|
||||||
assert {flag for flag in dl_section_flags() if flag.startswith("--")} - dl_option_flags() == set()
|
def test_every_flag_in_the_cli_reference_is_an_option(name: str, command: click.Command) -> None:
|
||||||
|
"""Table flags of any length, and long flags anywhere in the section: a short flag in prose can be a value."""
|
||||||
|
long_flags = set(re.findall(r"`(--[a-zA-Z][\w-]*)", section(name)))
|
||||||
|
assert (table_flags(name) | long_flags) - option_flags(command) == set()
|
||||||
|
|||||||
Reference in New Issue
Block a user