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
+1 -1
View File
@@ -56,6 +56,6 @@ Optional:
- [dovi_tool](https://github.com/quietvoid/dovi_tool) - ≥ 2.1 - [dovi_tool](https://github.com/quietvoid/dovi_tool) - ≥ 2.1
- [SubtitleEdit](https://github.com/SubtitleEdit/subtitleedit/releases) - ≥ 5.0 (`SeConv` CLI) - [SubtitleEdit](https://github.com/SubtitleEdit/subtitleedit/releases) - ≥ 5.0 (`SeConv` CLI)
## License ## Licence
[GPL-3.0](LICENSE). Do not use unshackle for content you do not have the rights to. Keep the core free and open. Keep service code private. Be kind. [GPL-3.0](LICENSE). Do not use unshackle for content you do not have the rights to. Keep the core free and open. Keep service code private. Be kind.
+21 -16
View File
@@ -61,7 +61,7 @@ unshackle dl EX 20914 # via an ALIAS
!!! warning "`config.yaml` is shared: keep secrets out of it" !!! warning "`config.yaml` is shared: keep secrets out of it"
Treat `config.yaml` as a checked-in file of **defaults**: it belongs in the Treat `config.yaml` as a checked-in file of **defaults**: it belongs in the
service repo, and everyone who runs the service shares it. Per-user secrets service repo, and everyone who runs the service shares it. Per-user secrets
(API keys, device IDs, account tokens) must **not** live here. Those go in the (API keys, device identifiers, account tokens) must **not** live here. Those go in the
user's own `unshackle.yaml` under `services.<TAG>`, which is **merged into user's own `unshackle.yaml` under `services.<TAG>`, which is **merged into
`self.config` at runtime**. That checked-in-defaults / per-user-overrides `self.config` at runtime**. That checked-in-defaults / per-user-overrides
split is exactly why every URL lives in `config.yaml` with `{}`/`{name}` split is exactly why every URL lives in `config.yaml` with `{}`/`{name}`
@@ -144,6 +144,11 @@ You can read it *and rewrite* it before you fetch tracks. A service that fetches
specific SSL *cipher* behaviour, mount specific SSL *cipher* behaviour, mount
`unshackle.core.utils.sslciphers.SSLCiphers` onto a plain `requests.Session`. `unshackle.core.utils.sslciphers.SSLCiphers` onto a plain `requests.Session`.
!!! note "Keep requests on the proxy"
unshackle warns about a request from service code that does not use the proxy of the run.
Send requests through `self.session`. An HTTP session that goes direct on purpose sets
`session.proxy_exempt = True`.
--- ---
## The methods you write ## The methods you write
@@ -226,7 +231,7 @@ Cookies come from files under `directories.cookies`. Credentials come from the
use `self.request_input(prompt)`, never a bare `input()`. Under `serve` mode use `self.request_input(prompt)`, never a bare `input()`. Under `serve` mode
there is no local terminal, so a bare `input()` would hang the server waiting on there is no local terminal, so a bare `input()` would hang the server waiting on
stdin that never arrives. `request_input` instead relays the prompt to the stdin that never arrives. `request_input` instead relays the prompt to the
client: a remote-dl session gets it through the attached `InputBridge`, and a client: a remote session gets it through the attached `InputBridge`, and a
REST download job shows it as `input_prompt`. Locally it routes through the REST download job shows it as `input_prompt`. Locally it routes through the
shared Rich console (`prompt_user`) so the prompt renders correctly alongside shared Rich console (`prompt_user`) so the prompt renders correctly alongside
progress and log output. progress and log output.
@@ -348,7 +353,7 @@ A service may set `title.data["availability"]` to a dict with two optional field
Only these allowlisted fields reach the REST API as `availability`, including Only these allowlisted fields reach the REST API as `availability`, including
through remote title reconstruction. The CLI's `--list-titles` does not display through remote title reconstruction. The CLI's `--list-titles` does not display
them, and nothing in core reads them to select or authorize downloads. them, and nothing in core reads them to select or authorise downloads.
Common constructor fields: Common constructor fields:
@@ -436,7 +441,7 @@ Episode(..., season=1, number=1, part=2, name="The Reckoning")
Once `part` is set, the filename gains a part token (`S01E01.Part.2`, see Once `part` is set, the filename gains a part token (`S01E01.Part.2`, see
[Output & naming](../guide/output-and-naming.md#split-episodes)), `-w S01E01.2` selects a [Output & naming](../guide/output-and-naming.md#split-episodes)), `-w S01E01.2` selects a
single part while a bare `-w S01E01` selects them all, and the `--list-titles` tree labels single part while a bare `-w S01E01` selects them all, and the `--list-titles` tree labels
the episode `01.2`. The REST API reports it as an extra `part` field on the serialized the episode `01.2`. The REST API reports it as an extra `part` field on the serialised
title, described in [Endpoints](rest-api/endpoints.md#post-apilist-titles). title, described in [Endpoints](rest-api/endpoints.md#post-apilist-titles).
!!! note "Opt-in and additive" !!! note "Opt-in and additive"
@@ -526,7 +531,7 @@ def get_tracks(self, title: Title_T) -> Tracks:
per title that the next fetch overwrites. per title that the next fetch overwrites.
After parsing, you may **correct** track metadata the manifest gets wrong: After parsing, you may **correct** track metadata the manifest gets wrong:
stamp the real `video.range`, fix odd audio channel counts, mark descriptive stamp the real `video.range`, fix odd audio channel layouts, mark descriptive
audio, add hand-built subtitles or an `Attachment` (e.g. cover art). Do *not* audio, add hand-built subtitles or an `Attachment` (e.g. cover art). Do *not*
filter for resolution/bitrate. See `fetch_dash_manifest` in the EXAMPLE service filter for resolution/bitrate. See `fetch_dash_manifest` in the EXAMPLE service
for a thorough demonstration. for a thorough demonstration.
@@ -543,11 +548,11 @@ for a thorough demonstration.
and let the probe relabel the tracks. and let the probe relabel the tracks.
!!! warning "`get_tracks` is your only chance to capture license inputs" !!! warning "`get_tracks` is your only chance to capture license inputs"
The license callbacks (`get_widevine_license` and the others) fire **much later**, in The licence callbacks (`get_widevine_license` and the others) fire **much later**, in
the download/decrypt step, long after `get_tracks` has returned, and they the download/decrypt step, long after `get_tracks` has returned, and they
receive **only** `challenge`, `title`, and `track`. Nothing else from the receive **only** `challenge`, `title`, and `track`. Nothing else from the
manifest response reaches them. So you must stash anything a license call needs manifest response reaches them. So you must stash anything a licence call needs
(the license URL, `dt-custom-data`, a session token) **now**, during (the licence URL, `dt-custom-data`, a session token) **now**, during
`get_tracks`, onto `self.license_data` or `title.data`. This is a `get_tracks`, onto `self.license_data` or `title.data`. This is a
lifecycle-timing consequence you cannot infer from the callback signatures. lifecycle-timing consequence you cannot infer from the callback signatures.
@@ -591,10 +596,10 @@ def get_chapters(self, title: Title_T) -> Chapters:
## Handling DRM ## Handling DRM
The core drives licensing. Your job is to answer the license challenges the CDM The core drives licensing. Your job is to answer the licence challenges the CDM
produces. Mark encrypted tracks with the right DRM in `get_tracks` (the manifest produces. Mark encrypted tracks with the right DRM in `get_tracks` (the manifest
parsers do this automatically for PSSH/`EXT-X-KEY` found in the manifest), then parsers do this automatically for PSSH/`EXT-X-KEY` found in the manifest), then
write the license callbacks you need. Each receives the challenge plus the write the licence callbacks you need. Each receives the challenge plus the
current `title` and `track`. [The service-side hooks](service-architecture.md#the-service-side-hooks) current `title` and `track`. [The service-side hooks](service-architecture.md#the-service-side-hooks)
names each callback, the optional arguments that it can declare, and what it returns: names each callback, the optional arguments that it can declare, and what it returns:
@@ -612,9 +617,9 @@ def get_widevine_license(self, *, challenge: bytes, title, track):
return response.content # others return raw bytes return response.content # others return raw bytes
``` ```
!!! warning "Return the license untouched" !!! warning "Return the licence untouched"
Do **not** base64-encode or decode the challenge or response. Pass them Do **not** base64-encode or decode the challenge or response. Pass them
through verbatim. A malformed license request can get your CDM/device through verbatim. A malformed challenge can get your CDM/device
flagged, banned, or downgraded. flagged, banned, or downgraded.
!!! tip "`ClearKeyCENC` (`org.w3.clearkey`) has three escalating integration levels" !!! tip "`ClearKeyCENC` (`org.w3.clearkey`) has three escalating integration levels"
@@ -628,15 +633,15 @@ def get_widevine_license(self, *, challenge: bytes, title, track):
the content key in `get_tracks` and pre-populate the content key in `get_tracks` and pre-populate
`drm.signatures[kid] = key_hex` on the track's `ClearKeyCENC`. The `drm.signatures[kid] = key_hex` on the track's `ClearKeyCENC`. The
non-obvious payoff: when every KID is already keyed, the framework skips non-obvious payoff: when every KID is already keyed, the framework skips
the license round-trip entirely. the licence round-trip entirely.
Things the service does not do: Things the service does not do:
- **HLS AES-128 (`ClearKey`)** tracks and **DRM-free** tracks have no license - **HLS AES-128 (`ClearKey`)** tracks and **DRM-free** tracks have no licence
callback. The content key comes from the manifest, and unshackle applies it callback. The content key comes from the manifest, and unshackle applies it
directly. directly.
- **Key vaults** cache `KID:KEY` pairs across runs, so repeat downloads skip the - **Key vaults** cache `KID:KEY` pairs across runs, so repeat downloads skip the
license round-trip entirely. licence round-trip entirely.
- **Decryption tooling** (shaka-packager or mp4decrypt) and the choice of local - **Decryption tooling** (shaka-packager or mp4decrypt) and the choice of local
vs remote CDM are user configuration, not service concerns. vs remote CDM are user configuration, not service concerns.
@@ -774,7 +779,7 @@ unshackle dl MYSVC https://myservice.com/watch/abc123
- [ ] `cli` is a `@staticmethod` that returns an instance. `__init__` calls `super().__init__(ctx)`. - [ ] `cli` is a `@staticmethod` that returns an instance. `__init__` calls `super().__init__(ctx)`.
- [ ] `get_titles`, `get_tracks` and `get_chapters` written. Titles carry the original `language`. - [ ] `get_titles`, `get_tracks` and `get_chapters` written. Titles carry the original `language`.
- [ ] Tracks come from a manifest parser with `to_tracks(language=title.language)`. No filtering by quality or language. - [ ] Tracks come from a manifest parser with `to_tracks(language=title.language)`. No filtering by quality or language.
- [ ] Encrypted tracks carry their DRM. The license callbacks you need return responses **unmodified**. - [ ] Encrypted tracks carry their DRM. The licence callbacks you need return responses **unmodified**.
- [ ] URLs, user agents, and certificates live in `config.yaml`, read through `self.config[...]`. - [ ] URLs, user agents, and certificates live in `config.yaml`, read through `self.config[...]`.
- [ ] Multi-file services import their own modules relatively (`from .helpers import x`), so they work when loaded from a repo. - [ ] Multi-file services import their own modules relatively (`from .helpers import x`), so they work when loaded from a repo.
+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 | | `playready_devices` | PlayReady `.prd` devices, by name |
!!! warning "PlayReady access is opt-in per user" !!! 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" !!! 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 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. 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 ### 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" !!! 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 ### 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) ### 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) ## Transport security (HTTPS)
@@ -322,7 +322,7 @@ With `--caddy`, unshackle also starts `caddy run` using the `Caddyfile` located
| Auth header | `X-Secret-Key` | | Auth header | `X-Secret-Key` |
| Query-parameter alternative | `?secret_key=` on `GET /api/download/jobs/{job_id}/events` only | | Query-parameter alternative | `?secret_key=` on `GET /api/download/jobs/{job_id}/events` only |
| Default bind address | `127.0.0.1:8786` | | 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."}` | | Missing-header body | `{"status": 401, "message": "Secret Key is Empty."}` |
| Invalid-key body | `{"status": 401, "message": "Secret Key is Invalid."}` | | Invalid-key body | `{"status": 401, "message": "Secret Key is Invalid."}` |
| Over-limit body | `{"status": 429, "message": "Rate limit exceeded."}`, plus a `Retry-After` header | | 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: 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 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()`. | | `needs_auth` | Whether the service overrides `authenticate()`. |
| `has_search` | Whether the service supports `POST /api/search`. | | `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. | | `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. | | `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. | | `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"]`. | | `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 `credentials` (`{username, password, extra?}`) and `cookies` (base64 of a
zlib-compressed Netscape cookie file) are the same as on 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 [`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 files in the form that [Cache files](remote-sessions.md#cache-files) gives. The server writes these files into the request
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
cache directory before the service authenticates. cache directory before the service authenticates.
When you send `credentials`, `cookies` or `cache`, a successful response also 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" !!! info "The number that `wanted` takes for a song"
A song adds `year` and its music fields, such as `artist`, `album`, `disc`, `track` and 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"`. `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 | | 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. 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. code the server can send.
If you write a client against the API, read this page alongside the endpoint 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. meanings of those codes.
!!! note "Where this comes from" !!! 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, 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 ### 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). | | `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. | | `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`). | | `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. | | `RATE_LIMITED` | 429 | The streaming service is rate-limiting requests. Retryable. |
!!! warning "Not every `429` is `RATE_LIMITED`" !!! 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. HTTP status.
!!! note "Reference consumer" !!! 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 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, `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 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-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-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. | | `--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-api` | off | Include tracebacks and worker stderr in error responses. |
| `--debug` | off | Enable debug-level logging. | | `--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. | | `--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`" === "`--remote-only`"
The server mounts only the remote-session subset of routes (health, services, search, The server mounts only the [remote session routes](remote-sessions.md#routes). This mode implies `--api-only`, and the
and everything under `/api/session/*`). This mode implies `--api-only`, and the
interactive Swagger UI is **not** mounted. interactive Swagger UI is **not** mounted.
=== "`--cdm-only`" === "`--cdm-only`"
@@ -227,7 +226,7 @@ the full model, including per-key service allowlists.
<div class="grid cards" markdown> <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. first end-to-end download over the API.
- **[Authentication](authentication.md)**: the `X-Secret-Key` header, `--no-key`, - **[Authentication](authentication.md)**: the `X-Secret-Key` header, `--no-key`,
per-key service allowlists, and CORS. 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 [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. 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 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`, history file), it masks the sensitive keys (`credential`, `credentials`, `password`,
`token`, `api_key`) and strips userinfo from proxy URLs. The manager also scrubs `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`, 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. 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. 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) | | `--no-key` | off | Disable API-key authentication (allow all requests) |
| `--debug-api` | off | Include tracebacks and stderr in error responses | | `--debug-api` | off | Include tracebacks and stderr in error responses |
| `--debug` | off | Enable DEBUG-level logging | | `--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) | | `--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:
@@ -386,13 +386,13 @@ A retry reuses the original job's service, title, and parameters to enqueue a br
## Beyond a single download ## 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). - **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). - **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. - **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). - **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). 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 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 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 ## Routes
`unshackle serve` mounts these routes in every mode except `--cdm-only`, which keeps only `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 | | Method | Path | Purpose |
|---|---|---| |---|---|---|
+15 -15
View File
@@ -78,11 +78,11 @@ These are abstract. A service will not load unless it defines all three:
`search` command can operate. unshackle calls `authenticate()` first, unless the `search` command can operate. unshackle calls `authenticate()` first, unless the
service sets `ANONYMOUS_SEARCH`. service sets `ANONYMOUS_SEARCH`.
- **Licence callbacks**: see [DRM hooks](#drm-hooks) below. - **Licence callbacks**: see [DRM hooks](#drm-hooks) below.
- **`request_input(prompt, qr=None)`**: prompts the user. It goes through the remote-dl input - **`request_input(prompt, qr=None)`**: prompts the user. It goes through the remote session input
bridge, the REST download job relay, or the rich console. bridge, the REST download job relay, or the rich console.
- **`wait_for_approval(message, check, timeout, interval=3.0, qr=None)`**: shows a message, then - **`wait_for_approval(message, check, timeout, interval=3.0, qr=None)`**: shows a message, then
calls `check` until it returns a value. Use it for a login that the user approves on calls `check` until it returns a value. Use it for a login that the user approves on
another device, such as a pair code. A remote-dl session shows the message as a log another device, such as a pair code. A remote session shows the message as a log
line, and a REST download job shows it as the job's `notice`. Both methods take `qr`, the line, and a REST download job shows it as the job's `notice`. Both methods take `qr`, the
text of a QR code to scan, and the terminal or UI that shows the user the message draws it. text of a QR code to scan, and the terminal or UI that shows the user the message draws it.
When the login API gives only a PNG, `read_qr_image(data)` in `unshackle.core.console` When the login API gives only a PNG, `read_qr_image(data)` in `unshackle.core.console`
@@ -323,8 +323,8 @@ The value also goes to a `--remote` client. A track without it muxes everything
and `sdh`, and `forced` cannot combine with either. `Subtitle.Codec` includes `SubRip` and `sdh`, and `forced` cannot combine with either. `Subtitle.Codec` includes `SubRip`
(SRT), `WebVTT` (VTT), `SubStationAlpha`/`SubStationAlphav4` (SSA/ASS), (SRT), `WebVTT` (VTT), `SubStationAlpha`/`SubStationAlphav4` (SSA/ASS),
`TimedTextMarkupLang` (TTML), `SAMI`, `SCC`, and the box-encapsulated DASH formats `fTTML` `TimedTextMarkupLang` (TTML), `SAMI`, `SCC`, and the box-encapsulated DASH formats `fTTML`
(STPP) and `fVTT` (WVTT). Subtitles receive post-download normalization (STPP) and `fVTT` (WVTT). Subtitles receive post-download normalisation
(segment merging, WebVTT sanitization, format conversion, and optional SDH stripping), (segment merging, WebVTT sanitisation, format conversion, and optional SDH stripping),
all documented for users in [Subtitles](../guide/subtitles.md). all documented for users in [Subtitles](../guide/subtitles.md).
### Chapters and attachments ### Chapters and attachments
@@ -415,7 +415,7 @@ least one and no track is left.
- **Segments** of each format: unshackle inflates a segment body that is one whole gzip member - **Segments** of each format: unshackle inflates a segment body that is one whole gzip member
before the merge, up to a size limit. A CDN can send such a body with no `Content-Encoding` before the merge, up to a size limit. A CDN can send such a body with no `Content-Encoding`
header. Any other body stays as it is, such as AES-128 ciphertext that starts with the gzip magic. header. Any other body stays as it is, such as AES-128 ciphertext that starts with the gzip magic.
- **ISM** has no list of segments and no init segments: the parser synthesizes segment URLs - **ISM** has no list of segments and no init segments: the parser synthesises segment URLs
from the `<c>` fragment timeline, and rebuilds a `moov`/`ftyp` init box from `CodecPrivateData` from the `<c>` fragment timeline, and rebuilds a `moov`/`ftyp` init box from `CodecPrivateData`
(supported for AVC, HEVC, DV-over-HEVC, AAC, EC-3, and TTML). A track id covers the manifest (supported for AVC, HEVC, DV-over-HEVC, AAC, EC-3, and TTML). A track id covers the manifest
URL, so a title you build from one ISM manifest per codec or range keeps every variant: URL, so a title you build from one ISM manifest per codec or range keeps every variant:
@@ -424,16 +424,16 @@ least one and no track is left.
## DRM hooks ## DRM hooks
If a track carries DRM, the framework licenses and decrypts it, but it needs your If a track carries DRM, the framework licenses and decrypts it, but it needs your
service to talk to the platform's license server. unshackle recognizes six DRM classes: service to talk to the platform's licence server. unshackle recognises six DRM classes:
| DRM class | System | License flow | | DRM class | System | Licence flow |
|---|---|---| |---|---|---|
| `Widevine` | Widevine | CDM challenge → license server → content keys (`.wvd` device) | | `Widevine` | Widevine | CDM challenge → licence server → content keys (`.wvd` device) |
| `PlayReady` | PlayReady | CDM challenge (WRM header) → license server → content keys (`.prd` device) | | `PlayReady` | PlayReady | CDM challenge (WRM header) → licence server → content keys (`.prd` device) |
| `ClearKeyCENC` | W3C `org.w3.clearkey` or W3C common PSSH over CENC | JSON KID request → JWK set; no CDM | | `ClearKeyCENC` | W3C `org.w3.clearkey` or W3C common PSSH over CENC | JSON KID request → JWK set; no CDM |
| `ClearKey` | HLS AES-128 | content key fetched directly from a URI; no CDM, no challenge | | `ClearKey` | HLS AES-128 | content key fetched directly from a URI; no CDM, no challenge |
| `CustomDRM` | a system that a DRM plugin adds | `CustomDRM("<plugin id>", kids=..., data=...)`. For a plugin that holds its key, put the key in `data`. For a plugin that licenses locally, put only the data the plugin reads: unshackle licenses it at the licence step. The plugin decrypts. Its README names the `data` it reads | | `CustomDRM` | a system that a DRM plugin adds | `CustomDRM("<plugin id>", kids=..., data=...)`. For a plugin that holds its key, put the key in `data`. For a plugin that licenses locally, put only the data the plugin reads: unshackle licenses it at the licence step. The plugin decrypts. Its README names the `data` it reads |
| `ClearKeyCTR` | AES-128-CTR over a whole file | the service gives the IV and licenses the content key at the licence step; no CDM, no license server | | `ClearKeyCTR` | AES-128-CTR over a whole file | the service gives the IV and licenses the content key at the licence step; no CDM, no licence server |
!!! warning "`ClearKey` vs `ClearKeyCENC`" !!! warning "`ClearKey` vs `ClearKeyCENC`"
Despite the shared prefix these are entirely different systems. `ClearKey` is HLS Despite the shared prefix these are entirely different systems. `ClearKey` is HLS
@@ -459,7 +459,7 @@ When a `--remote` client licenses with its own CDM, the callback on the server g
You do not open CDM sessions or operate shaka-packager yourself. The `Widevine`/`PlayReady` You do not open CDM sessions or operate shaka-packager yourself. The `Widevine`/`PlayReady`
classes drive the CDM handshake and call the decryption backend. Your callback is only the classes drive the CDM handshake and call the decryption backend. Your callback is only the
"send this challenge, give me back the license" step. "send this challenge, give me back the licence" step.
### The FairPlay bridge hook ### The FairPlay bridge hook
@@ -547,11 +547,11 @@ only such tags stops with `None of the key systems are supported` before it down
### How unshackle chooses a CDM and finds keys ### How unshackle chooses a CDM and finds keys
CDM selection is config-driven: the `cdm` map resolves a service tag (and optionally the The CDM choice comes from config: the `cdm` map resolves a service tag (and optionally the
track quality or DRM type) to a device name, which `load_cdm` instantiates as a local track quality or DRM type) to a device name, which `load_cdm` instantiates as a local
`.wvd`/`.prd` or a remote CDM. Before ever requesting a license, the framework tries an `.wvd`/`.prd` or a remote CDM. Before ever requesting a licence, the framework tries an
in-process cache of content keys and the configured **key vaults**. Only unresolved KIDs in-process cache of content keys and the configured **key vaults**. The CDM makes a challenge only
trigger an actual license request, and the framework writes newly licensed keys back to for an unresolved KID, and the framework writes newly licensed keys back to
every vault. This is why the same content key is rarely re-licensed twice. Users configure every vault. This is why the same content key is rarely re-licensed twice. Users configure
all of this in [DRM and CDM](../guide/drm-and-cdm.md) and all of this in [DRM and CDM](../guide/drm-and-cdm.md) and
[Key vaults](../guide/vaults.md). The [DRM API reference](../reference/api/drm.md) gives [Key vaults](../guide/vaults.md). The [DRM API reference](../reference/api/drm.md) gives
+4 -4
View File
@@ -145,7 +145,7 @@ unshackle honours the special language tokens `orig`, `all`, and `best` everywhe
| Flag | Description | | Flag | Description |
|---|---| |---|---|
| `-w`, `--wanted` | Wanted episodes, e.g. `S01-S05,S07`, `S01E01-S02E03`. Supports exclusions with a leading `-` (e.g. `-S03`). For a [split episode](downloading.md#split-episodes), `.N` picks one part (`S01E01.2`), a range must stay inside the episode (`S01E01.1-S01E01.3`), and `S01E01` on its own takes every part. For a [dated episode](downloading.md#daily-and-date-based-content), a token can also be an ISO air date (`2026-08-11`) or a date range with a colon (`2026-08-01:2026-08-31`). For a [music release](downloading.md#music-tracks), a token is a number of the track list (`1-5`, `1,3,7`), or `{disc}x{track}` (`2x3`) when the release has more than one disc. | | `-w`, `--wanted` | Wanted episodes, e.g. `S01-S05,S07`, `S01E01-S02E03`. Supports exclusions with a leading `-` (e.g. `-S03`). For a [split episode](downloading.md#split-episodes), `.N` picks one part (`S01E01.2`), a range must stay inside the episode (`S01E01.1-S01E01.3`), and `S01E01` on its own takes every part. For a [dated episode](downloading.md#daily-and-date-based-content), a token can also be an ISO air date (`2026-08-11`) or a date range with a colon (`2026-08-01:2026-08-31`). For a [music release](downloading.md#songs), a token is a number of the track list (`1-5`, `1,3,7`), or `{disc}x{track}` (`2x3`) when the release has more than one disc. |
| `--select-titles` | Interactively select what to download: episodes of a series, or films when a title has more than one. **Cannot combine with `-w`.** | | `--select-titles` | Interactively select what to download: episodes of a series, or films when a title has more than one. **Cannot combine with `-w`.** |
| `--latest-episode` | Download only the single most recent episode. `-w` has no effect with it. | | `--latest-episode` | Download only the single most recent episode. `-w` has no effect with it. |
| `--latest-episodes N` | Download only the N most recent episodes, which can come from more than one season. A split episode counts as one episode, and all its parts download. `-w` has no effect with it. | | `--latest-episodes N` | Download only the N most recent episodes, which can come from more than one season. A split episode counts as one episode, and all its parts download. `-w` has no effect with it. |
@@ -227,7 +227,7 @@ Keep only certain track types, or skip certain track types.
| `--no-proxy` | Force-disable all proxy use. | | `--no-proxy` | Force-disable all proxy use. |
| `--no-proxy-download` | Bypass the proxy for **all downloads** (manifest, licence, and auth stay proxied). | | `--no-proxy-download` | Bypass the proxy for **all downloads** (manifest, licence, and auth stay proxied). |
| `--proxy-download` | Use a different proxy for **all downloads**, in the same forms as `--proxy` (manifest, licence, and auth stay on `--proxy`). | | `--proxy-download` | Use a different proxy for **all downloads**, in the same forms as `--proxy` (manifest, licence, and auth stay on `--proxy`). |
| `--remote` | Use a remote unshackle server. | | `--remote` | Use a remote unshackle server. See [Remote sessions](remote-sessions.md). |
| `--local` | Use the local service code, also when the config sets `remote: true`. | | `--local` | Use the local service code, also when the config sets `remote: true`. |
| `--server` | Name a remote server from the `remote_services` config. | | `--server` | Name a remote server from the `remote_services` config. |
@@ -262,7 +262,7 @@ Find titles on a service. Like `dl`, `search` is a group whose subcommands are t
unshackle search [OPTIONS] SERVICE [QUERY...] unshackle search [OPTIONS] SERVICE [QUERY...]
``` ```
Each service defines its own query syntax. unshackle prints the results as a tree of titles with their service IDs. Feed an ID straight into `dl`. Each service defines its own query syntax. unshackle prints the results as a tree of titles with their title IDs. Feed an ID straight into `dl`.
unshackle logs in to the service before the search. A service that declares a search with no login is the exception: unshackle then reads no cookies and no credentials, and `--profile` has no effect. unshackle logs in to the service before the search. A service that declares a search with no login is the exception: unshackle then reads no cookies and no credentials, and `--profile` has no effect.
@@ -597,7 +597,7 @@ unshackle serve [OPTIONS]
| `--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 service session endpoints (health, services, search, session). Implies `--api-only`. | | `--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`. |
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`.
+2 -2
View File
@@ -535,7 +535,7 @@ select the tracks of a music release. By default, unshackle downloads **all** ep
`-w` / `--wanted` accepts season and episode ranges, comma-separated. Prefix a token `-w` / `--wanted` accepts season and episode ranges, comma-separated. Prefix a token
with `-` to exclude it. For a music release, the same option takes track numbers. Read with `-` to exclude it. For a music release, the same option takes track numbers. Read
[music tracks](#music-tracks) below. [songs](#songs) below.
=== "Whole seasons" === "Whole seasons"
@@ -586,7 +586,7 @@ with `-` to exclude it. For a music release, the same option takes track numbers
unshackle dl -w 2026-08-01:2026-08-31,-2026-08-15 EXAMPLE 81234567 unshackle dl -w 2026-08-01:2026-08-31,-2026-08-15 EXAMPLE 81234567
``` ```
### Music tracks ### Songs
`-w` selects the tracks of an album, EP, single, or playlist. Give a track by its number. `-w` selects the tracks of an album, EP, single, or playlist. Give a track by its number.
A release with more than one disc uses the `{disc}x{track}` form. A number on its own is a A release with more than one disc uses the `{disc}x{track}` form. A number on its own is a
+24 -24
View File
@@ -3,10 +3,10 @@
A Digital Rights Management (DRM) system protects most commercial streaming titles. A Digital Rights Management (DRM) system protects most commercial streaming titles.
To download a title and play it back, unshackle needs to get the **content keys** To download a title and play it back, unshackle needs to get the **content keys**
for the encrypted tracks and then decrypt them. This page explains the DRM systems for the encrypted tracks and then decrypt them. This page explains the DRM systems
unshackle supports, how to install a device so it can talk to a license server, the unshackle supports, how to install a device so it can talk to a licence server, the
difference between local and remote CDMs, and how to choose a decryption backend. difference between local and remote CDMs, and how to choose a decryption backend.
!!! note "Who this page is for" !!! info "Who this page is for"
This is a practical configuration guide for end users of the unshackle CLI. This is a practical configuration guide for end users of the unshackle CLI.
A few sections have a **Developer** mark. They give internal behaviour that is A few sections have a **Developer** mark. They give internal behaviour that is
useful when you write a service, but you do not need them to download a protected useful when you write a service, but you do not need them to download a protected
@@ -18,10 +18,10 @@ Before configuring anything, it helps to know the vocabulary. unshackle draws a
line between two things: line between two things:
- A **CDM** (Content Decryption Module) is the trusted "black box" that turns a - A **CDM** (Content Decryption Module) is the trusted "black box" that turns a
*license challenge* into *content keys*. A **device** backs it: a file that carries *licence challenge* into *content keys*. A **device** backs it: a file that carries
the cryptographic identity of a real client, such as a phone or a browser. the cryptographic identity of a real client, such as a phone or a browser.
- A **DRM system** is the wrapper around a CDM that parses the protection metadata, - A **DRM system** is the wrapper around a CDM that parses the protection metadata,
drives the challenge → license → keys handshake, and finally invokes an external drives the challenge → licence → keys handshake, and finally invokes an external
tool to physically decrypt the downloaded file. tool to physically decrypt the downloaded file.
A handful of other terms show up throughout: A handful of other terms show up throughout:
@@ -31,27 +31,27 @@ A handful of other terms show up throughout:
| **PSSH** | Protection System Specific Header. The per-system init data extracted from the file's init segment or the manifest. | | **PSSH** | Protection System Specific Header. The per-system init data extracted from the file's init segment or the manifest. |
| **KID** | Key ID: a 16-byte UUID identifying *which* key a track needs. | | **KID** | Key ID: a 16-byte UUID identifying *which* key a track needs. |
| **CEK** | Content Encryption Key: the AES content key, mapped from its KID. | | **CEK** | Content Encryption Key: the AES content key, mapped from its KID. |
| **Challenge** | The license request the CDM produces, sent to the service's license server. | | **Challenge** | The request the CDM produces, sent to the service's licence server. |
| **License** | The server's response, which the CDM parses to recover the content keys. | | **Licence** | The server's response, which the CDM parses to recover the content keys. |
For a Widevine or PlayReady title, the flow is: unshackle reads the PSSH and KIDs For a Widevine or PlayReady title, the flow is: unshackle reads the PSSH and KIDs
from the track, asks the CDM for a license challenge, sends that challenge to the from the track, asks the CDM for a licence challenge, sends that challenge to the
service's license server, hands the response back to the CDM to extract the keys, and service's licence server, hands the response back to the CDM to extract the keys, and
then decrypts the file with those keys. then decrypts the file with those keys.
## Supported DRM systems ## Supported DRM systems
unshackle has five DRM systems built in. Only the first two need a device file and a unshackle has five DRM systems built in. Only the first two need a device file and a
license-server handshake. The rest are special cases. A DRM plugin adds another system (see licence-server handshake. The rest are special cases. A DRM plugin adds another system (see
[DRM plugins](#drm-plugins)). [DRM plugins](#drm-plugins)).
| System | Device file | License flow | Decryption | | System | Device file | Licence flow | Decryption |
|--------|-------------|--------------|------------| |--------|-------------|--------------|------------|
| **Widevine** (Google) | `.wvd` | CDM challenge → license server → CDM parses → keys | shaka-packager / mp4decrypt | | **Widevine** (Google) | `.wvd` | CDM challenge → licence server → CDM parses → keys | shaka-packager / mp4decrypt |
| **PlayReady** (Microsoft) | `.prd` | CDM challenge (WRM header) → license server → CDM parses → keys | shaka-packager / mp4decrypt | | **PlayReady** (Microsoft) | `.prd` | CDM challenge (WRM header) → licence server → CDM parses → keys | shaka-packager / mp4decrypt |
| **ClearKey (CENC)**, W3C EME `org.w3.clearkey` or the W3C common PSSH | none | JSON `{"kids":[...],"type":"temporary"}` → license server returns a JWK Set. No CDM. | shaka-packager / mp4decrypt | | **ClearKey (CENC)**, W3C EME `org.w3.clearkey` or the W3C common PSSH | none | JSON `{"kids":[...],"type":"temporary"}` → licence server returns a JWK Set. No CDM. | shaka-packager / mp4decrypt |
| **ClearKey (HLS)**, AES-128 `EXT-X-KEY` | none | Key fetched directly from a URI or `data:` URL. No CDM, no challenge. | in-process AES-CBC | | **ClearKey (HLS)**, AES-128 `EXT-X-KEY` | none | Key fetched directly from a URI or `data:` URL. No CDM, no challenge. | in-process AES-CBC |
| **ClearKey (CTR)**, AES-128-CTR | none | The service gives the per-track key and IV. No CDM, no license server. | in-process AES-CTR over the whole file | | **ClearKey (CTR)**, AES-128-CTR | none | The service gives the per-track key and IV. No CDM, no licence server. | in-process AES-CTR over the whole file |
!!! warning "Three different ClearKeys" !!! warning "Three different ClearKeys"
"ClearKey (HLS)", "ClearKey (CENC)" and "ClearKey (CTR)" are entirely different systems that "ClearKey (HLS)", "ClearKey (CENC)" and "ClearKey (CTR)" are entirely different systems that
@@ -213,7 +213,7 @@ The `prd` command group creates and maintains `.prd` files.
$ unshackle prd test ./data/PRDs/mydevice.prd -sl 2000 -c aesctr $ unshackle prd test ./data/PRDs/mydevice.prd -sl 2000 -c aesctr
``` ```
Runs a full challenge/license/keys cycle against Microsoft's public PlayReady Runs a full challenge/licence/keys cycle against Microsoft's public PlayReady
test server and prints the returned keys, confirming the device works. test server and prints the returned keys, confirming the device works.
`-sl/--security-level` accepts `150`, `2000`, or `3000` (default `2000`). `-sl/--security-level` accepts `150`, `2000`, or `3000` (default `2000`).
`-c/--ckt` accepts `aesctr` or `aescbc`. `-c/--ckt` accepts `aesctr` or `aescbc`.
@@ -300,7 +300,7 @@ profile.
A CDM can operate in two places: A CDM can operate in two places:
- A **local CDM** loads a `.wvd` or `.prd` device from your machine and performs the - A **local CDM** loads a `.wvd` or `.prd` device from your machine and performs the
challenge/license/keys handshake locally. This is what the `cdm` mapping above challenge/licence/keys handshake locally. This is what the `cdm` mapping above
resolves to by default. resolves to by default.
- A **remote CDM** delegates the CDM operations to an HTTP API. Your device (and its - A **remote CDM** delegates the CDM operations to an HTTP API. Your device (and its
secrets) live on the remote CDM host. unshackle sends it PSSH/challenge data and secrets) live on the remote CDM host. unshackle sends it PSSH/challenge data and
@@ -485,7 +485,7 @@ conditions shaka-packager is the better backend. Switch a specific service to
When an HLS playlist references a content key with an `EXT-X-KEY` tag, unshackle When an HLS playlist references a content key with an `EXT-X-KEY` tag, unshackle
fetches the content key directly (from the given URI or an inline `data:` URL) and fetches the content key directly (from the given URI or an inline `data:` URL) and
decrypts each segment in-process with AES-CBC. There is no device, no CDM, and no decrypts each segment in-process with AES-CBC. There is no device, no CDM, and no
license challenge, so you do not set anything up. unshackle decrypts such tracks licence challenge, so you do not set anything up. unshackle decrypts such tracks
automatically during download. automatically during download.
The `EXT-X-KEY` URI must return a content key of exactly 16 bytes, or the download stops with an error. The `EXT-X-KEY` URI must return a content key of exactly 16 bytes, or the download stops with an error.
@@ -494,7 +494,7 @@ logs one warning for the track, because the content key is possibly wrong.
### ClearKey over CENC (W3C EME `org.w3.clearkey`) ### ClearKey over CENC (W3C EME `org.w3.clearkey`)
The CENC ClearKey scheme is a proper license flow, but the "license server" The CENC ClearKey scheme is a proper licence flow, but the "licence server"
returns the keys as a JWK Set and not a DRM-wrapped blob. unshackle builds a W3C returns the keys as a JWK Set and not a DRM-wrapped blob. unshackle builds a W3C
EME request of the form: EME request of the form:
@@ -502,22 +502,22 @@ EME request of the form:
{"kids": ["<base64url-kid>", ...], "type": "temporary"} {"kids": ["<base64url-kid>", ...], "type": "temporary"}
``` ```
It sends this to the manifest's license URL (or to whatever a service's ClearKey It sends this to the manifest's licence URL (or to whatever a service's ClearKey
license hook returns) and reads the JSON Web Key set back. You do not need a device licence hook returns) and reads the JSON Web Key set back. You do not need a device
file. The decrypted file still goes through shaka-packager or mp4decrypt like any file. The decrypted file still goes through shaka-packager or mp4decrypt like any
other CENC track, so the `decryption` setting applies. other CENC track, so the `decryption` setting applies.
A DASH manifest can also give the KID of a ClearKey track with only the W3C common PSSH A DASH manifest can also give the KID of a ClearKey track with only the W3C common PSSH
(`urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b`). The common PSSH can name KIDs for any DRM (`urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b`). The common PSSH can name KIDs for any DRM
system, so unshackle reads it as ClearKey (CENC) only when the manifest and the init segment system, so unshackle reads it as ClearKey (CENC) only when the manifest and the init segment
give no other DRM system. This scheme has no license URL in the manifest, so the content key give no other DRM system. This scheme has no licence URL in the manifest, so the content key
must come from the service's ClearKey license hook or from a key vault. must come from the service's ClearKey licence hook or from a key vault.
### ClearKey over a whole file (AES-CTR) ### ClearKey over a whole file (AES-CTR)
Some services encrypt one whole audio file with AES-128-CTR and give the content key and Some services encrypt one whole audio file with AES-128-CTR and give the content key and
the IV with the track. unshackle decrypts the file in-process after the download. There is the IV with the track. unshackle decrypts the file in-process after the download. There is
no device, no CDM and no license challenge. The licence step of a download or of a `--skip-dl` run licenses no device, no CDM and no licence challenge. The licence step of a download or of a `--skip-dl` run licenses
the content key, so `--list` asks for none. The IV, the length of the header in front of the media and the the content key, so `--list` asks for none. The IV, the length of the header in front of the media and the
signature the file must start with travel with the track list. signature the file must start with travel with the track list.
@@ -670,7 +670,7 @@ debug_requests: true
``` ```
!!! warning "Keys and paths in logs" !!! warning "Keys and paths in logs"
When you enable key logging, unshackle writes content keys (KID:key pairs) to the logs. When you enable key logging, unshackle writes content keys (`KID:KEY`) to the logs.
Treat those logs as sensitive. The unrelated `redact_paths` option (default Treat those logs as sensitive. The unrelated `redact_paths` option (default
`true`) masks local directory paths in log output. `true`) masks local directory paths in log output.
+2 -7
View File
@@ -115,7 +115,7 @@ For custom templates there is also a standalone [`{part}`](../reference/configur
### Sports events {#sports-events} ### Sports events {#sports-events}
A service can mark an episode as a sports event. That episode then uses the `sports` output template and the `sports` folder template, if you set them. Without them it uses the `series` templates, as before. A service can mark an episode as a sports event. That episode then uses the `sports` output template and the `sports` folder template, if you set them. Without them it uses the `series` templates.
```yaml title="unshackle.yaml" ```yaml title="unshackle.yaml"
output_template: output_template:
@@ -237,7 +237,7 @@ warning. An MKA file gets no cover art.
unshackle writes lyrics when the service supplies them: a `LYRICS` Vorbis comment for FLAC, a unshackle writes lyrics when the service supplies them: a `LYRICS` Vorbis comment for FLAC, a
`USLT` frame for MP3, and a `©lyr` atom for M4A. Ogg uses the same `LYRICS` field as `USLT` frame for MP3, and a `©lyr` atom for M4A. Ogg uses the same `LYRICS` field as
FLAC. unshackle does not write synchronized lyrics (`SYLT`). FLAC. unshackle does not write synchronised lyrics (`SYLT`).
The embedded lyrics are plain text. A service can also save timed lyrics in a file beside The embedded lyrics are plain text. A service can also save timed lyrics in a file beside
the audio, for example `08.Get.Lucky.lrc` next to `08.Get.Lucky.m4a`. A music player reads the audio, for example `08.Get.Lucky.lrc` next to `08.Get.Lucky.m4a`. A music player reads
@@ -501,11 +501,6 @@ When a title has chapters, unshackle writes them to an OGM chapters file (`filen
chapter_fallback_name: "Chapter {i:02}" chapter_fallback_name: "Chapter {i:02}"
``` ```
## Removed & migrated options
!!! warning "`scene_naming` was removed"
The old `scene_naming` option no longer exists. If it is present in your config, unshackle exits immediately with an error asking you to configure `output_template` instead. Migrate any scene-naming setup to the templates described on this page.
## Worked examples ## Worked examples
Each tab shows a template and what it produces for a few different downloads, so you can see Each tab shows a template and what it produces for a few different downloads, so you can see
+1 -48
View File
@@ -344,7 +344,7 @@ network.
!!! note "Each request crosses the tunnel twice" !!! note "Each request crosses the tunnel twice"
A request from the server goes to your machine and then to the service, so it takes A request from the server goes to your machine and then to the service, so it takes
longer than a request that the server sends directly. The segments do not go through the longer than a request that the server sends directly. The segments do not go through the
tunnel: the client downloads them as before. tunnel: the client downloads them as it does without one.
A service that uses a server account does not work with `--local-proxy`, because the server A service that uses a server account does not work with `--local-proxy`, because the server
logs in with its own account. If the tunnel drops, the client connects again, and a new request logs in with its own account. If the tunnel drops, the client connects again, and a new request
@@ -976,53 +976,6 @@ proxy_providers:
The returned proxy is HTTPS on **port 443**. The returned proxy is HTTPS on **port 443**.
## Developer notes
!!! note "One resolution path (developers)"
`dl`, `search`, the REST API handlers and the remote-service client all load proxy
providers through `load_proxy_providers()` in `unshackle/core/proxies/resolve.py`.
The REST API, its download jobs and the remote-service client call it through
`initialize_proxy_providers()`, which leaves out Gluetun because Gluetun starts a
local Docker container. All paths read a value through `resolve_proxy_value()`, which
returns the proxy URI with the proxy provider, the query and the log line: a
`controld://` resolver, a `provider:query` or a bare query tried against providers in
order, or else an explicit proxy URI or `host:port`.
The remote-service client resolves `--proxy` with its own
`resolve_remote_proxy_arg()`. It changes a `controld:` query to a `controld://`
resolver for the server with `get_remote_proxy()`, and it removes Control D from a bare
query, because a loopback forwarder is of no use to a server on another machine.
!!! note "Keeping service requests on the proxy (developers)"
`unshackle/core/utils/run_proxy.py` holds the proxy rules for service traffic:
- `pin(session)` stops environment and system proxies from overriding the proxy of a
requests HTTP session, and keeps the environment CA bundle. Call it on each requests
HTTP session that gets a proxy.
- `fallback_session()` gives a core helper with no HTTP session (a manifest parser, a DRM
class) a session on the proxy of the service that called it.
- An audit hook on `socket.getaddrinfo` and on `socket.connect` to a host name, and a
check in `RnetSession.request`, warn about requests from service code that do not use
the proxy. A service sets
`proxy_exempt = True` on an HTTP session that goes direct on purpose.
!!! note "Implementing a new provider (developers)"
Every proxy provider subclasses `unshackle.core.proxies.proxy.Proxy` and has three
methods:
- `__init__(self, **kwargs)` receives its `proxy_providers` sub-dict splatted as
keyword arguments, so YAML keys map 1:1 to constructor parameters. Check the
configuration here, but make no request: every `dl` run builds every configured
proxy provider, even for a run with no proxy. Read the server or location catalogue
through a `functools.cached_property`, so the first query fetches it.
- `__repr__(self)` is a human summary, conventionally `"{n} Countries ({m} Servers)"`.
- `get_proxy(self, query)` returns a Requests-compatible proxy URI, or `None` only
when the query was valid but no proxy exists. Raise on genuine errors or bad queries.
Optionally add `get_connection_info(query)` (as Gluetun does) or
`last_connection_display()` (as ExpressVPN and Proton VPN do) to make `dl` print a
friendly connection line instead of the raw proxy URL.
## See also ## See also
- [Downloading](downloading.md): the full `dl` command guide, including where proxy - [Downloading](downloading.md): the full `dl` command guide, including where proxy
+2 -2
View File
@@ -1,4 +1,4 @@
# Remote sessions # Remote Sessions
A remote session runs a service on a remote unshackle server and the download on your machine. A remote session runs a service on a remote unshackle server and the download on your machine.
The server logs in to the service, lists the titles, gets the tracks and their manifests, and can The server logs in to the service, lists the titles, gets the tracks and their manifests, and can
@@ -359,7 +359,7 @@ job that uses a remote server sends the end request for at most 4s, then its wor
!!! example "`403 FORBIDDEN` during a download" !!! example "`403 FORBIDDEN` during a download"
The request came from a different IP address than the one that created the remote session. The request came from a different IP address than the one that created the remote session.
Remote sessions are bound to that address. Do not move between networks (or NAT egress Remote sessions are bound to that address. Do not move between networks (or NAT egress
addresses) during a remote download. addresses) during a remote session.
!!! example "The login times out or the prompt never resolves" !!! example "The login times out or the prompt never resolves"
An interactive login has a time limit (see An interactive login has a time limit (see
+3 -3
View File
@@ -4,7 +4,7 @@ Subtitles are first-class tracks in unshackle. When you download a title, unshac
parses the subtitle tracks from the manifest alongside video and audio. It downloads parses the subtitle tracks from the manifest alongside video and audio. It downloads
them, cleans them up, and optionally converts them to the format you want. It then muxes them, cleans them up, and optionally converts them to the format you want. It then muxes
them into the final Matroska file, or writes them out as sidecar files next to it. The them into the final Matroska file, or writes them out as sidecar files next to it. The
sections below cover the supported formats, how unshackle normalizes tracks after sections below cover the supported formats, how unshackle normalises tracks after
download, how to select and filter subtitles, and every subtitle-related configuration download, how to select and filter subtitles, and every subtitle-related configuration
option. option.
@@ -54,7 +54,7 @@ format-appropriate clean-up to make a single, valid file:
- **Segment merging**: when a WebVTT or boxed subtitle arrives as many DASH/HLS - **Segment merging**: when a WebVTT or boxed subtitle arrives as many DASH/HLS
segments, unshackle merges the segments back into one continuous document with segments, unshackle merges the segments back into one continuous document with
correct timing. A cue that a segment boundary cuts in two comes out as one cue. correct timing. A cue that a segment boundary cuts in two comes out as one cue.
- **WebVTT sanitization**: merged WebVTT runs through a repair pipeline that clamps - **WebVTT sanitisation**: merged WebVTT runs through a repair pipeline that clamps
negative timestamps to `00:00:00.000`, removes stray cue identifiers (like `Q0`, `Q1`) negative timestamps to `00:00:00.000`, removes stray cue identifiers (like `Q0`, `Q1`)
that confuse downstream parsers, and merges multi-line cues that a service split into that confuse downstream parsers, and merges multi-line cues that a service split into
separate overlapping cues. By default unshackle keeps the original styling and layout separate overlapping cues. By default unshackle keeps the original styling and layout
@@ -435,7 +435,7 @@ an anchor, and an unquoted number is not read as a colour.
!!! note "Player settings" !!! note "Player settings"
A player draws an ASS subtitle with its own style, so player options for text subtitles, A player draws an ASS subtitle with its own style, so player options for text subtitles,
such as the mpv options `sub-font` and `sub-font-size`, no longer apply. The text size such as the mpv options `sub-font` and `sub-font-size`, do not apply. The text size
follows the height of the video, so on a wide video such as 1920x800 the text is smaller follows the height of the video, so on a wide video such as 1920x800 the text is smaller
than on a 1920x1080 video. than on a 1920x1080 video.
+1 -30
View File
@@ -79,7 +79,7 @@ Every line is a self-contained JSON object. The first line of each log file reco
Quote `unshackle_code_hash` in a bug report. It fingerprints the framework source you operate, so it tells us the exact code state even when you did not install from git. A hash that matches no release means that someone edited the source locally. Quote `unshackle_code_hash` in a bug report. It fingerprints the framework source you operate, so it tells us the exact code state even when you did not install from git. A hash that matches no release means that someone edited the source locally.
Subsequent lines record the operations: service calls, DRM licence requests, vault lookups, downloader progress, and errors. Common fields include: Subsequent lines record the operations: service calls, DRM challenges and licences, vault lookups, downloader progress, and errors. Common fields include:
| Field | Meaning | | Field | Meaning |
|---|---| |---|---|
@@ -358,32 +358,3 @@ Each command reports how many files it removed and how much space it freed, then
unshackle loads the **first** `unshackle.yaml` it finds, in the order that [Where the config file lives](../getting-started/configuration-file.md#where-the-config-file-lives) gives. unshackle loads the **first** `unshackle.yaml` it finds, in the order that [Where the config file lives](../getting-started/configuration-file.md#where-the-config-file-lives) gives.
If you have config in more than one of those locations, an earlier one wins and unshackle silently ignores your edits to a later file. `unshackle env info` prints the path it loaded (or, if none exists, shows every candidate location so you can make the file correctly). See [Configuration](cli-reference.md#cfg) for editing values with the `cfg` command. If you have config in more than one of those locations, an earlier one wins and unshackle silently ignores your edits to a later file. `unshackle env info` prints the path it loaded (or, if none exists, shows every candidate location so you can make the file correctly). See [Configuration](cli-reference.md#cfg) for editing values with the `cfg` command.
---
!!! note "Developer note: structured logging in code"
Service and command code sends entries through the shared `log_event(...)` helper (and the `timed_operation(...)` context manager for timing a block) from `unshackle.core.utilities`. These are no-ops when you disable debug logging, so they are always safe to leave in place. When you add a new feature, call `log_event("my_feature_event", message="...", context={...})`. Do not write the "is the logger enabled?" guard again. unshackle does the redaction and the JSON-serialisation for you, and redacts any field whose name looks like a content key, a secret, or a token. Content keys only appear when the run has `debug_keys` enabled.
### Logging conventions when adding entries
The debug log is tuned for **developers troubleshooting pipeline flow** (maximum signal, minimum noise), not for end users. A few conventions keep it that way. The `log_event` signature does not enforce them, so they are easy to miss and worth stating explicitly.
!!! tip "Log levels are a flow skeleton, not just severity"
Treat `level` as structure, not decoration. Send exactly **one `INFO` milestone per pipeline stage** so that `jq 'select(.level=="INFO")'` reads back the whole end-to-end flow of a run. Everything internal goes to `DEBUG`. Failures go to `ERROR`. A sparse `INFO` is the whole point. It is the line a developer skims first to see where a run got to before it broke.
```console
# Read the pipeline's high-level flow, one line per stage
jq 'select(.level == "INFO")' unshackle_debug_EXAMPLE_20260703-142530.jsonl
```
!!! warning "No request bodies and no raw dumps"
A `log_event` entry never holds a request body or a raw dump: no full `Tracks` object, no MPD/manifest body and no response payload. Only `debug_requests` records request and response bodies, and only as files in its separate body folder. Log only **counts, ids, sizes, and `safe_display_url(url)`**. This keeps the log low-noise and prevents leaking title or manifest data into the file *before* redaction even runs. Redaction is a backstop, not a licence to dump raw objects.
!!! note "Operation names: `<area>_<event>`, no registry"
Operation names are plain lowercase strings that follow an `<area>_<event>` convention: `manifest_dash_parse`, `drm_decrypt`, `vault_get_key`, `tool_run`. We write them inline at each call site on purpose. There is **no central registry or enum**. Do not look for one, and do not make one. The absence is a deliberate design choice, not an omission.
!!! note "Message reads alone; data lives in fields"
Give every entry a single-sentence `message` that stands on its own. Put all structured data (`context`, counts, ids, `duration_ms`) in **fields**, not in the prose. This separation lets the log be both human-scannable and machine-filterable. A message like `"Parsed DASH manifest"` with `context={"video": 4, "audio": 2}` beats `"Parsed manifest with 4 video and 2 audio tracks"`.
!!! tip "Let tool runs log themselves"
For external-tool calls (FFmpeg, mkvmerge, `dovi_tool`, and friends), route through `run_step` / `run_tool` / `ffprobe`, which auto-emit a `tool_run` entry capturing the binary's version, return code, and duration consistently. `run_tool` also raises `ToolFailed`, whose message names the tool, the exit code and the last lines the tool wrote. A failure that the caller recovers from (a retry, a fallback) is named with `handled=` (exit codes or stderr text): its `tool_run` entry is `DEBUG`, not `ERROR`, and the call still raises. Only fall back to calling `log_tool_run` manually for a direct `subprocess.run` you genuinely cannot route through those helpers. Auto-logging is the preferred path precisely because it captures those fields the same way every time.
+1 -1
View File
@@ -201,7 +201,7 @@ $ unshackle kv add keys.txt EXAMPLE local shared
0e7cc1a4e2f9411db0f24a3fbb8f8b21:00112233445566778899aabbccddeeff 0e7cc1a4e2f9411db0f24a3fbb8f8b21:00112233445566778899aabbccddeeff
``` ```
The service argument (`EXAMPLE` above) is normalized to its canonical tag automatically. Keys that already exist in a vault are reported as skipped. The service argument (`EXAMPLE` above) is normalised to its canonical tag automatically. Keys that already exist in a vault are reported as skipped.
If a vault answers and refuses the content keys, `kv add` shows one warning and continues with the next vault. If a vault is unreachable or still rate limited, `kv add` stops with an error. If a vault answers and refuses the content keys, `kv add` shows one warning and continues with the next vault. If a vault is unreachable or still rate limited, `kv add` stops with an error.
+1 -1
View File
@@ -43,7 +43,7 @@ at a title and it will:
| Key vaults | SQLite, MySQL, and HTTP/API vaults to store and share content keys | | Key vaults | SQLite, MySQL, and HTTP/API vaults to store and share content keys |
| Proxies | Basic proxies plus Control D, NordVPN, ProtonVPN, Surfshark, Windscribe, ExpressVPN, Gluetun, and Hola providers | | Proxies | Basic proxies plus Control D, NordVPN, ProtonVPN, Surfshark, Windscribe, ExpressVPN, Gluetun, and Hola providers |
| Services | A plugin API for the service modules you write. unshackle includes none | | Services | A plugin API for the service modules you write. unshackle includes none |
| Automation | A REST API with a job queue, live progress, history, and remote-download sessions | | Automation | A REST API with a job queue, live progress, history, and [remote sessions](guide/remote-sessions.md) |
## Installation at a glance ## Installation at a glance
+2 -2
View File
@@ -22,8 +22,8 @@ directories:
| `cookies` | path | `<data>/cookies` | Yes | Per-service cookie files (and VPN cookie files). | | `cookies` | path | `<data>/cookies` | Yes | Per-service cookie files (and VPN cookie files). |
| `logs` | path | `<data>/logs` | Yes | Log files. | | `logs` | path | `<data>/logs` | Yes | Log files. |
| `exports` | path | `<data>/exports` | Yes | Export JSON files. | | `exports` | path | `<data>/exports` | Yes | Export JSON files. |
| `wvds` | path | `<data>/WVDs` | Yes | Widevine device files (`.wvd`). | | `wvds` | path | `<data>/WVDs` | Yes | WVD files (Widevine devices, `.wvd`). |
| `prds` | path | `<data>/PRDs` | Yes | PlayReady device files (`.prd`). | | `prds` | path | `<data>/PRDs` | Yes | PRD files (PlayReady devices, `.prd`). |
| `plugins` | path | `unshackle/plugins` | Yes | DRM plugins: zip files or folders (see [DRM plugins](../../guide/drm-and-cdm.md#drm-plugins)). | | `plugins` | path | `unshackle/plugins` | Yes | DRM plugins: zip files or folders (see [DRM plugins](../../guide/drm-and-cdm.md#drm-plugins)). |
| `dcsl` | path | `<data>/DCSL` | Yes | DCSL data. | | `dcsl` | path | `<data>/DCSL` | Yes | DCSL data. |
| `commands` | path | `unshackle/commands` | Yes | CLI command modules. | | `commands` | path | `unshackle/commands` | Yes | CLI command modules. |
+4 -4
View File
@@ -1,4 +1,4 @@
# Download & processing { #download-processing } # Download & Processing { #download-processing }
## `dl` ## `dl`
@@ -453,7 +453,7 @@ boolean condition. It logs a warning in each of these cases and tries the next r
`dual`, `multi` and `dubbed` carry the same meaning as the `dual`, `multi` and `dubbed` carry the same meaning as the
[filename variables of those names](#dual_multi_mode). Pair one with a language to name a [filename variables of those names](#dual_multi_mode). Pair one with a language to name a
release yourself, in place of the fixed `DUAL`, `MULTi` and `DUBBED` text. A rule that names release yourself, in place of the fixed `DUAL`, `MULTi` and `DUBBED` text. A rule that names
`dubbed: true` and a language tags a localized dub without tagging a native release the same way. `dubbed: true` and a language tags a localised dub without tagging a native release the same way.
```yaml ```yaml
language_tags: language_tags:
@@ -569,7 +569,7 @@ hdr10plus_probe: true
``` ```
A remote server probes its tracks before it sends them, so the setting on the server applies to A remote server probes its tracks before it sends them, so the setting on the server applies to
remote downloads and to the REST API. remote sessions and to the REST API.
## `generate_dv_mode` ## `generate_dv_mode`
@@ -592,5 +592,5 @@ generate_dv_mode: v29
Dolby Vision that unshackle measures from the decoded video uses its measured average in all modes. Dolby Vision that unshackle measures from the decoded video uses its measured average in all modes.
`v40` raises the lowest average to about 10 nits, and `legacy` is the same as `v29`. `v40` raises the lowest average to about 10 nits, and `legacy` is the same as `v29`.
The setting applies on the machine that runs the hybrid step: the client for a remote download, the The setting applies on the machine that runs the hybrid step: the client for a remote session, the
server for a REST API job. server for a REST API job.
+1 -1
View File
@@ -1,4 +1,4 @@
# A complete annotated example # A Complete Annotated Example
The following config sets a handful of common config keys. Every config key not shown keeps its default. The following config sets a handful of common config keys. Every config key not shown keeps its default.
+3 -5
View File
@@ -84,9 +84,7 @@ each metadata provider can answer with, see
did not ask for. did not ask for.
!!! note "The `imdb` provider needs no key" !!! note "The `imdb` provider needs no key"
It replaces the earlier `imdbapi` metadata provider, which read a third-party mirror It needs no `imdb_api_enabled` switch either.
(api.tiffara.com) and needed the `imdb_api_enabled` switch. That option is gone: delete it
from your config, where it is now ignored.
!!! tip "A different order per title kind" !!! tip "A different order per title kind"
Give a map instead of one list when the best source differs by kind. TVDB is strongest on Give a map instead of one list when the best source differs by kind. TVDB is strongest on
@@ -164,7 +162,7 @@ calls.
|-----|------|---------|-------------| |-----|------|---------|-------------|
| `redact_paths` | bool | `true` | Mask install-root / venv / home prefixes in logged paths (`<unshackle>`, `<venv>`, `~`). Set `false` to show full paths. | | `redact_paths` | bool | `true` | Mask install-root / venv / home prefixes in logged paths (`<unshackle>`, `<venv>`, `~`). Set `false` to show full paths. |
| `debug` | bool | `false` | Global debug mode. | | `debug` | bool | `false` | Global debug mode. |
| `debug_keys` | bool | `false` | Log decryption keys. | | `debug_keys` | bool | `false` | Log content keys. |
| `debug_requests` | bool | `false` | The one switch that writes an `http_request` entry for each HTTP attempt to the JSON debug log, and the request and response bodies as files in a folder beside it; `-d` and `debug` alone write neither. With `-d` it also keeps the HTTP library logs in the console. See [Debugging HTTP traffic](../../guide/troubleshooting.md#debug-requests). | | `debug_requests` | bool | `false` | The one switch that writes an `http_request` entry for each HTTP attempt to the JSON debug log, and the request and response bodies as files in a folder beside it; `-d` and `debug` alone write neither. With `-d` it also keeps the HTTP library logs in the console. See [Debugging HTTP traffic](../../guide/troubleshooting.md#debug-requests). |
| `debug_requests_body_limit` | int | `0` | The maximum number of bytes of a body file of `debug_requests`. `0` or unset records the full body. unshackle cuts a longer body and records its full size. | | `debug_requests_body_limit` | int | `0` | The maximum number of bytes of a body file of `debug_requests`. `0` or unset records the full body. unshackle cuts a longer body and records its full size. |
| `set_terminal_bg` | bool | `false` | Append the theme's background colour to output styling. | | `set_terminal_bg` | bool | `false` | Append the theme's background colour to output styling. |
@@ -198,4 +196,4 @@ calls.
| `curl_impersonate` | **Deprecated** → use [`network`](network.md) | Emits a `DeprecationWarning`; still honoured only if `network` is absent. | | `curl_impersonate` | **Deprecated** → use [`network`](network.md) | Emits a `DeprecationWarning`; still honoured only if `network` is absent. |
| `downloader` | **Deprecated** | Any value other than `"requests"` emits a `DeprecationWarning`; the value is otherwise ignored (the unified requests downloader is always used). | | `downloader` | **Deprecated** | Any value other than `"requests"` emits a `DeprecationWarning`; the value is otherwise ignored (the unified requests downloader is always used). |
| `scene_naming` | **Removed** | If set to any non-null value, unshackle exits with an error directing you to configure [`output_template`](output.md) instead. | | `scene_naming` | **Removed** | If set to any non-null value, unshackle exits with an error directing you to configure [`output_template`](output.md) instead. |
| `imdb_api_enabled` | **Removed** | Ignored. It gated the old `imdbapi` provider, which the keyless [`imdb`](#external-api-keys) provider replaces. Safe to delete from your config. | | `imdb_api_enabled` | **Removed** | Ignored. Safe to delete from your config. |
+1 -1
View File
@@ -1,4 +1,4 @@
# Network & proxy { #network-proxy } # Network & Proxy { #network-proxy }
## `network` ## `network`
+1 -1
View File
@@ -1,4 +1,4 @@
# Output & naming { #output-naming } # Output & Naming { #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
+4 -4
View File
@@ -1,4 +1,4 @@
# Post-scripts { #post-scripts } # Post-Scripts { #post-scripts }
Operate your own script when a download finishes, with unshackle's metadata passed in as Operate your own script when a download finishes, with unshackle's metadata passed in as
`{variable}` placeholders. Use it to hand a finished file to an uploader, send a `{variable}` placeholders. Use it to hand a finished file to an uploader, send a
@@ -42,7 +42,7 @@ extra argument or a shell operator, and you never have to think about quoting. I
means a path containing spaces always arrives as a single argument on every OS. means a path containing spaces always arrives as a single argument on every OS.
!!! warning "Prefix your variables" !!! warning "Prefix your variables"
Titles, episode names and IDs come from the streaming service, not from you. Tokenizing Titles, episode names and IDs come from the streaming service, not from you. Tokenising
first stops a value becoming a *new* argument, but a value on its own can still be a first stops a value becoming a *new* argument, but a value on its own can still be a
whole argument. A bare `{title}` whose value is `--upload-file=/etc/passwd` would arrive whole argument. A bare `{title}` whose value is `--upload-file=/etc/passwd` would arrive
as an option to your script, not as text. Write `--title={title}`, not a bare `{title}`, as an option to your script, not as text. Write `--title={title}`, not a bare `{title}`,
@@ -106,7 +106,7 @@ values.
| `{folder}` | Absolute path of its parent folder | | `{folder}` | Absolute path of its parent folder |
| `{ext}` | Its extension, including the dot | | `{ext}` | Its extension, including the dot |
| `{sidecars}` | Sidecar subtitle files written for this output, newline separated | | `{sidecars}` | Sidecar subtitle files written for this output, newline separated |
| `{title}` | Show, movie or track name, sanitized | | `{title}` | Show, movie or track name, sanitised |
| `{title_raw}` | Exactly what the service returned, untouched | | `{title_raw}` | Exactly what the service returned, untouched |
| `{title_id}` | The service's ID for the title | | `{title_id}` | The service's ID for the title |
| `{service}` | Service tag | | `{service}` | Service tag |
@@ -173,7 +173,7 @@ track arrived in, such as `.flac`, because a music download is not muxed.
`{tmdb}`, `{imdb}` and `{tvdb}` carry the IDs unshackle tags the file with. unshackle reads `{tmdb}`, `{imdb}` and `{tvdb}` carry the IDs unshackle tags the file with. unshackle reads
them at the moment it dispatches the post-script, and not at the start of the run. The title search them at the moment it dispatches the post-script, and not at the start of the run. The title search
inside the download loop finds an episode's TMDB ID, so a post-script fires with it already filled in. that runs during the download finds an episode's TMDB ID, so a post-script fires with it already filled in.
They hold an ID you passed with `--tmdb`, `--imdb` or `--tvdb`, plus a TMDB ID the episode They hold an ID you passed with `--tmdb`, `--imdb` or `--tvdb`, plus a TMDB ID the episode
search resolved. No such search runs for a movie, so a movie post-script gets them empty unless you search resolved. No such search runs for a movie, so a movie post-script gets them empty unless you
+5 -5
View File
@@ -1,4 +1,4 @@
# Services & authentication { #services-auth } # Services & Authentication { #services-auth }
## `services` ## `services`
@@ -150,7 +150,7 @@ your choice, and with a service option that runs the remote session on the serve
`X-Secret-Key` and `X-Api-Key`, which unshackle always appends as fallbacks. It sends the `X-Secret-Key` and `X-Api-Key`, which unshackle always appends as fallbacks. It sends the
first name. If the server answers `401`, it retries the same request with the next name, and first name. If the server answers `401`, it retries the same request with the next name, and
keeps the one that works for the rest of the HTTP session. After a request succeeds, a `401` keeps the one that works for the rest of the HTTP session. After a request succeeds, a `401`
no longer moves the API key to another name. Names you give keep your spelling and does not move the API key to another name. Names you give keep your spelling and
are not repeated in the fallbacks, so unshackle tries are not repeated in the fallbacks, so unshackle tries
`auth_headers: ["Authorization", "x-secret-key"]` as `Authorization`, `x-secret-key`, `X-Api-Key`. `auth_headers: ["Authorization", "x-secret-key"]` as `Authorization`, `x-secret-key`, `X-Api-Key`.
@@ -169,7 +169,7 @@ In `--remote` mode unshackle turns the server's service list into synthetic CLI
commands that operate against it, falling back to the tags in that `services` sub-dict when commands that operate against it, falling back to the tags in that `services` sub-dict when
unshackle cannot fetch the list. Each synthetic command carries the server-side service's options and unshackle cannot fetch the list. Each synthetic command carries the server-side service's options and
documentation, so `unshackle dl --remote <TAG> -h` shows the same help text as it does on the documentation, so `unshackle dl --remote <TAG> -h` shows the same help text as it does on the
server. Service names resolve against the server's tags and aliases, not your local services. server. unshackle resolves a service tag against the server's tags and aliases, not your local services.
If the server does not offer a name to your API key, unshackle rejects the name and lists the If the server does not offer a name to your API key, unshackle rejects the name and lists the
tags it does offer. See [remote sessions](../../guide/remote-sessions.md) for the tags it does offer. See [remote sessions](../../guide/remote-sessions.md) for the
full setup. full setup.
@@ -188,7 +188,7 @@ is the [Server](../../dev/rest-api/index.md) section of the user guide. These ar
| `tiers` | dict | `{}` | Named settings that `users` entries reference by name (see below). | | `tiers` | dict | `{}` | Named settings that `users` entries reference by name (see below). |
| `services` | list | *(unset)* | Global service allowlist. Omit to allow all. | | `services` | list | *(unset)* | Global service allowlist. Omit to allow all. |
| `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)* | Developer 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 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. |
| `history_limit` | int | `100` | How many finished jobs to retain in history. | | `history_limit` | int | `100` | How many finished jobs to retain in history. |
@@ -351,7 +351,7 @@ serve:
EXAMPLE2: true # every profile (or the single credential), any region EXAMPLE2: true # every profile (or the single credential), any region
``` ```
Each entry under a service names a profile from `credentials`, or a cookie file Each entry under a service is the name of a profile from `credentials`, or of a cookie file
`cookies/<TAG>/<profile>.txt` for a service that has no credentials. Its value is the region or `cookies/<TAG>/<profile>.txt` for a service that has no credentials. Its value is the region or
regions that account works in: a two-letter country code, a list of them, or `global`. Quote regions that account works in: a two-letter country code, a list of them, or `global`. Quote
`no` (Norway), because YAML reads the bare word as `false`. `no` (Norway), because YAML reads the bare word as `false`.
+1 -1
View File
@@ -1,4 +1,4 @@
# Key vaults { #key-vaults } # Key Vaults { #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
View File
@@ -1,3 +1,4 @@
mkdocs>=1.6
mkdocs-material>=9.5 mkdocs-material>=9.5
mkdocstrings[python]>=0.26 mkdocstrings[python]>=0.26
# ruff (or black) lets mkdocstrings format rendered signatures # ruff (or black) lets mkdocstrings format rendered signatures
+3 -3
View File
@@ -364,7 +364,7 @@ def _install_config_reload(app: web.Application, *, no_key: bool, serve_widevine
"--remote-only", "--remote-only",
is_flag=True, is_flag=True,
default=False, default=False,
help="Only expose remote service session endpoints (health, services, search, session).", help="Only expose the remote session routes (health, services, search, session, tunnel).",
) )
@click.option( @click.option(
"-q", "-q",
@@ -491,9 +491,9 @@ def serve(
stats.mode = "remote_only" if remote_only else "api_only" if api_only else "cdm_only" if cdm_only else "full" stats.mode = "remote_only" if remote_only else "api_only" if api_only else "cdm_only" if cdm_only else "full"
dashboard = bool(dashboard_key()) dashboard = bool(dashboard_key())
if dashboard: if dashboard:
log.info(f"Developer dashboard endpoints available at http://{host}:{port}/api/dashboard/") log.info(f"Server dashboard endpoints available at http://{host}:{port}/api/dashboard/")
elif quiet: elif quiet:
log.info("Developer dashboard disabled: set serve.dashboard.key in unshackle.yaml to enable it") log.info("Server dashboard disabled: set serve.dashboard.key in unshackle.yaml to enable it")
if not cdm_only: if not cdm_only:
global_speed_limit = parse_speed_limit(config.serve.get("global_speed_limit")) global_speed_limit = parse_speed_limit(config.serve.get("global_speed_limit"))
+2 -2
View File
@@ -15,8 +15,8 @@ class WindscribeVPN(Proxy):
""" """
Proxy provider that uses WindscribeVPN Service Credentials. Proxy provider that uses WindscribeVPN Service Credentials.
You must give a username and password. These are Service Credentials, not your Login Credentials. Give the username and password of the proxy pair from Windscribe's ServerCredentials API.
The Service Credentials can be found here: https://windscribe.com/getconfig/openvpn The OpenVPN and IKEv2 pairs from its config pages answer 407 on the proxy gateway.
server_map pins a query to a hostname. Its keys are either a country code ("ca") or a country server_map pins a query to a hostname. Its keys are either a country code ("ca") or a country
code with a city ("ca:toronto"), and unshackle uses a pinned hostname before any server lookup. code with a city ("ca:toronto"), and unshackle uses a pinned hostname before any server lookup.
+1 -1
View File
@@ -473,7 +473,7 @@ class Service(TitleSource):
"""Request interactive input from the user. """Request interactive input from the user.
Locally, prompts through the shared rich console so the prompt renders alongside Locally, prompts through the shared rich console so the prompt renders alongside
Live progress. A remote-dl session relays it through its :class:`InputBridge`, and a Live progress. A remote session relays it through its :class:`InputBridge`, and a
REST download job relays it through ``prompt_user`` to the job's ``input_prompt``. REST download job relays it through ``prompt_user`` to the job's ``input_prompt``.
*qr* is the text of a QR code for the user to scan; the terminal that asks the user draws it. *qr* is the text of a QR code for the user to scan; the terminal that asks the user draws it.
""" """