From 2f8e2aba37ef685df5da6bca0243b0ba2b0a04e1 Mon Sep 17 00:00:00 2001 From: imSp4rky Date: Fri, 4 Dec 2026 18:02:27 -0700 Subject: [PATCH] docs(config): make the configuration reference the one owner of every option table --- docs/getting-started/configuration-file.md | 103 +++---------- docs/getting-started/installation.md | 8 +- docs/getting-started/quickstart.md | 5 +- docs/guide/drm-and-cdm.md | 54 +++---- docs/guide/output-and-naming.md | 171 ++------------------- docs/guide/proxies-and-vpn.md | 150 +++++------------- docs/guide/subtitles.md | 73 +++------ docs/guide/troubleshooting.md | 8 +- docs/guide/vaults.md | 129 +++------------- docs/reference/configuration.md | 19 --- docs/reference/configuration/download.md | 43 +++++- docs/reference/configuration/index.md | 4 +- docs/reference/configuration/network.md | 171 +++++++++++++++++++-- docs/reference/configuration/output.md | 117 ++++++++++++-- docs/reference/configuration/vaults.md | 147 ++++++++++++++---- unshackle/unshackle-example.yaml | 12 +- 16 files changed, 555 insertions(+), 659 deletions(-) delete mode 100644 docs/reference/configuration.md diff --git a/docs/getting-started/configuration-file.md b/docs/getting-started/configuration-file.md index f04e5746..df70b4ec 100644 --- a/docs/getting-started/configuration-file.md +++ b/docs/getting-started/configuration-file.md @@ -9,7 +9,7 @@ A single configuration file named `unshackle.yaml` controls almost everything ab The main configuration file is always named `unshackle.yaml`. It uses plain YAML. You can open and edit it in any text editor, or manage individual values with the [`unshackle cfg`](#editing-the-config-with-unshackle-cfg) command. -If you have never created one, that is fine: unshackle runs entirely on built-in defaults when no config file exists. The file only needs to contain the keys you want to change from their defaults. +The file only needs to contain the keys you want to change from their defaults, with one exception: `dl` needs an [`output_template`](../reference/configuration/output.md#output_template) to name its files, and stops with an error without one. [`unshackle setup`](installation.md#what-unshackle-setup-does) writes a first config that has one. ## Where the config file lives @@ -49,19 +49,24 @@ The path of the per-user config directory depends on your operating system: !!! tip "Not sure which file is being used?" Operate `unshackle env info`. It prints the path unshackle loaded the config from, or tells you that it found none. It also prints every directory unshackle currently uses. -The config is read exactly once, when unshackle starts. If you edit the file, the change takes effect on the next command. +unshackle reads the config once, when it starts. If you edit the file, the change takes effect on the next command. ## Top-level structure `unshackle.yaml` is a flat map of top-level config keys. Each config key configures one area of the program. You include only the config keys you want to change. Everything else falls back to its default. -Here is a small, realistic example that sets a download location, a release tag, a default CDM, and one service's credentials: +Here is a small, realistic example that sets a download location, filename templates, a release tag, a default CDM, and one service's credentials: ```yaml title="unshackle.yaml" # Where finished downloads are written directories: downloads: ~/Videos/unshackle +# How dl names movie and episode files (dl needs this key) +output_template: + movies: "{title}.{year}.{quality}.{source}.WEB-DL.{audio_full}.{video}-{tag?}" + series: "{title}.{season_episode}.{episode_name?}.{quality}.{source}.WEB-DL.{audio_full}.{video}-{tag?}" + # Release group tag appended to filenames tag: MYGRP @@ -79,23 +84,7 @@ headers: Accept-Language: en-US,en;q=0.9 ``` -The top-level keys group loosely into these areas: - -| Area | Example keys | -|------|--------------| -| Downloading & DRM | `dl`, `cdm`, `remote_cdm`, `decryption` | -| Networking | `network`, `headers` | -| Credentials & cookies | `credentials`, `firefox_cookies` | -| Tracks & muxing | `subtitle`, `audio`, `muxing`, `language_tags` | -| Key vaults | `key_vaults`, `vault_timeout` | -| Proxies & remote | `proxy_providers`, `remote_services`, `serve`, `services` | -| Naming & tagging | `tag`, `output_template`, `chapter_fallback_name` | -| External API keys | `tmdb_api_key`, `tvdb_api_key`, `simkl_client_id`, `ipinfo_api_key`, `metadata_providers` | -| Behaviour & logging | `update_checks`, `redact_paths`, `debug`, `unicode_filenames` | -| Post-scripts | `post_scripts` | -| Paths | `directories`, `filenames` | - -For the full list with types and defaults, see the [Configuration Reference](../reference/configuration/index.md). +The [quick index](../reference/configuration/index.md#quick-index) of the Configuration Reference lists every top-level key, grouped by area, with a link to its types and defaults. !!! warning "Unknown keys are silently ignored" unshackle does not validate your config against a schema. If you misspell a config key, unshackle skips it and uses the default. You will not get an error. Examine the config key names (and their nesting) if a setting does not seem to apply. @@ -103,87 +92,35 @@ For the full list with types and defaults, see the [Configuration Reference](../ ## Setting download defaults (`dl:`) If you always pass the same `dl` flags (a language, a resolution, a codec), put them under a -`dl:` config key once and unshackle applies them to every download. Any flag from -[Downloading](../guide/downloading.md) works here. The config key is the flag's long name with -dashes turned into underscores (`--best-available` → `best_available`). +`dl:` config key once and unshackle applies them to every download. An explicit flag on the +command line still wins. ```yaml title="unshackle.yaml" dl: lang: [en] # -l en quality: [1080] # -q 1080 - vcodec: [H.265] # -v H.265 sub_format: srt # convert subtitles to SRT - downloads: 2 # two tracks at once ``` -You can still override any of these on the command line for a one-off. An explicit flag -always beats the config default. You can also scope defaults to a single service by nesting a -`dl:` block under it: - -```yaml title="Per-service defaults" -dl: - lang: [en] # default for everything -services: - EXAMPLE: - dl: - lang: [en, ja] # Example downloads English + Japanese -``` - -!!! tip "A few keys are named after the flag's internal name" - Most keys are obvious, but set these exact ones: `range` (`-r`), `list` (`--list`), - `tmdb_id` (`--tmdb`), `imdb_id` (`--imdb`), `tvdb_id` (`--tvdb`), `no_atmos` (`--noatmos`), and `output_dir` - (`-o`). The [Configuration Reference](../reference/configuration/download.md#dl) has the full list - and every available config key. +The [`dl` reference](../reference/configuration/download.md#dl) gives how a flag becomes a config key, the +keys that do not follow that rule, per-service defaults and the order in which the values +apply. ## The directory layout -The `directories` config key controls where unshackle reads and writes its various files. Each directory has a sensible default, and you can override most of them by giving a new path. A path can use `~` for your home directory. +The `directories` config key controls where unshackle reads and writes its files. Each +directory has a default, and a path can use `~` for your home directory: ```yaml title="unshackle.yaml" directories: downloads: ~/Videos/unshackle temp: /mnt/fast/unshackle-temp - cache: ~/.cache/unshackle ``` -The directories unshackle uses: - -| Name | Purpose | Overridable | -|------|---------|-------------| -| `downloads` | Default output folder for finished downloads | Yes | -| `temp` | Temporary working files during a download | Yes | -| `cache` | Cache store (title cache, update checks, service caches) | Yes | -| `cookies` | Per-service cookie files | Yes | -| `logs` | Log files | Yes | -| `exports` | Export JSONs | Yes | -| `wvds` | Widevine devices (`.wvd` files) | Yes | -| `prds` | PlayReady devices (`.prd` files) | Yes | -| `dcsl` | DCSL data | Yes | -| `services` | Search paths for service code (see below) | Yes | -| `commands` | CLI command modules | Yes | -| `vaults` | Vault modules | Yes | -| `fonts` | Bundled fonts | Yes | - -!!! note "Some directories cannot be moved" - unshackle protects five internal entries: `app_dirs`, `core_dir`, `namespace_dir`, `user_configs`, and `data`. If you write any of them under `directories`, unshackle ignores the override. This is intentional. Those paths come from the package location and your OS user directories. - -### The `services` directory is special - -Unlike the other entries, `services` is a **list**, and each entry can be either a local folder or a remote repository. This lets you mix your own local services with services pulled from Git: - -```yaml title="unshackle.yaml" -directories: - services: - - you/your-services # a GitHub owner/repo shorthand - - https://example.com/private-services.git - - ~/code/local-services # a local folder -``` - -unshackle examines the entries in the order you wrote them, and **the first source to define a given service tag wins**. Put local folders last if you want them to act as fallbacks and not overrides. unshackle clones remote repositories on first use and refreshes them at most once a day. See [Creating a Service](../dev/creating-a-service.md) for how service discovery and repositories work. - -## The `filenames` config key - -Alongside `directories`, the `filenames` config key lets you override the templates unshackle uses when it names its own working and log files. Two examples are the log filename and the temporary chapters file. Most users never need to touch this. The [Configuration Reference](../reference/configuration/directories.md#filenames) gives the available names and their default templates. +The [Directories reference](../reference/configuration/directories.md) lists every directory with its default, +the directories that you cannot move, and how the `services` list loads services from local +folders and Git repositories. The `filenames` config key on the same page changes the names +of unshackle's own working and log files. ## Editing the config with `unshackle cfg` diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.md index bd9cf2d3..49356c99 100644 --- a/docs/getting-started/installation.md +++ b/docs/getting-started/installation.md @@ -118,14 +118,14 @@ overwrites an existing config. On Windows, CCExtractor and its libraries go into their own `ccextractor` subfolder of the tools folder. -On Linux, the user data directory is usually `~/.local/share/unshackle` and the -user config directory is usually `~/.config/unshackle`. On Windows, both are -`%LOCALAPPDATA%\unshackle`. Run `uv run unshackle env info` to see the paths that +On Linux, the user data directory is usually `~/.local/share/unshackle`, and on +Windows `%LOCALAPPDATA%\unshackle`. [Where the config file lives](configuration-file.md#where-the-config-file-lives) +gives the user config directory of each system. Run `uv run unshackle env info` to see the paths that unshackle uses. Its `User_Binaries` row shows the `binaries` folder in the user data directory. Setup writes a new config only when it finds no `unshackle.yaml` in any of the -[config locations](configuration-file.md). It keeps an existing config where it +[config locations](configuration-file.md#where-the-config-file-lives). It keeps an existing config where it is. In a clone, the new config sets only `directories.downloads`, so the data folders stay at their defaults in the clone. diff --git a/docs/getting-started/quickstart.md b/docs/getting-started/quickstart.md index 6680df85..bd05dc6c 100644 --- a/docs/getting-started/quickstart.md +++ b/docs/getting-started/quickstart.md @@ -244,8 +244,9 @@ directories: - **[Downloading](../guide/downloading.md)**. The full `dl` command: quality, codecs, languages, track selection, hybrid Dolby Vision, and output control. -- **[Configuration](configuration-file.md)**. Every `unshackle.yaml` config key, plus - directories, key vaults, proxies, and naming templates. +- **[Configuration](configuration-file.md)**. Where `unshackle.yaml` lives and what a first + config holds. The [Configuration Reference](../reference/configuration/index.md) lists every + config key. - **[REST API](../dev/rest-api/index.md)**. Operate the `serve` server to drive downloads over HTTP. diff --git a/docs/guide/drm-and-cdm.md b/docs/guide/drm-and-cdm.md index e991af14..d4797fc4 100644 --- a/docs/guide/drm-and-cdm.md +++ b/docs/guide/drm-and-cdm.md @@ -112,19 +112,15 @@ appropriate one for each track. ## Providing a device with the `wvd` and `prd` commands -Device files live in dedicated directories, by default: - -| Kind | Default directory | -|------|-------------------| -| Widevine `.wvd` | `data/WVDs` | -| PlayReady `.prd` | `data/PRDs` | - -You can move these with the `directories` section of your `unshackle.yaml`: +Device files live in two directories: `.wvd` files in `directories.wvds` and `.prd` files +in `directories.prds`. Their defaults are in the +[Directories reference](../reference/configuration/directories.md). To move them, set +them under `directories` in your `unshackle.yaml`: ```yaml title="unshackle.yaml" directories: - wvds: /home/george/unshackle-data/WVDs - prds: /home/george/unshackle-data/PRDs + wvds: ~/unshackle-data/WVDs + prds: ~/unshackle-data/PRDs ``` ### Widevine devices: the `wvd` command @@ -250,10 +246,10 @@ cdm: Lookups are case-insensitive. !!! tip "The device name is the file name" - A device named `chromecdm_l3` in the config resolves to `chromecdm_l3.wvd` in the - WVDs directory (or `chromecdm_l3.prd` in the PRDs directory). It may also be the - `name` of a remote CDM defined in `remote_cdm`. See - [Remote CDMs](#remote-cdms) below. + A device named `chromecdm_l3` in the config resolves to a remote CDM of that `name` in + `remote_cdm` (see [Remote CDMs](#remote-cdms) below), else to a device file such as + `chromecdm_l3.wvd` in the device directories. The + [`cdm` reference](../reference/configuration/drm.md#cdm) gives the lookup order. ### Advanced selection: by quality, DRM, or profile @@ -340,9 +336,8 @@ cdm: default: my_wv_remote ``` -`security_level` defaults to `3000` if omitted. unshackle reads field names -case-insensitively, so `Device Type`/`device_type`, `System ID`/`system_id`, and the -other field names are all accepted. +The [`remote_cdm` reference](../reference/configuration/drm.md#remote_cdm) gives the default +of each field and the two spellings of each field name. ### PlayReady remote CDM @@ -387,10 +382,9 @@ decrypt_labs_api_key: your-decrypt-labs-key unshackle sends the API key as the `decrypt-labs-api-key` header. If you do not write `secret` on the entry, unshackle falls back to the global `decrypt_labs_api_key` value. -If neither is present it raises an error. The `host` defaults to -`https://keyxtractor.decryptlabs.com`. PlayReady devices (`SL2`/`SL3`) default to -security level `2000`/`3000` respectively. Widevine devices default to -`system_id: 26830`, `security_level: 3`. +If neither is present it raises an error. The +[`decrypt_labs` fields](../reference/configuration/drm.md#remote-cdm-decrypt-labs) give the host, +system ID and security level that unshackle uses when you leave them out. ### Custom API (`custom_api`) @@ -471,9 +465,10 @@ globally, or a per-service mapping: ``` !!! info "How the value is interpreted" - The default is `shaka`. Only the exact value `mp4decrypt` selects mp4decrypt. - **Anything else** (including `shaka`) selects shaka-packager. Per-service lookups - are case-insensitive, with the `default`/`DEFAULT` entry used as the fallback. + The default is `shaka`. `mp4decrypt` selects mp4decrypt, and **anything else** + (including `shaka`) selects shaka-packager. The + [`decryption` reference](../reference/configuration/drm.md#decryption) gives how unshackle + reads the value, and the tracks that use mp4decrypt whatever this setting says. The two backends give equivalent output for a standard CENC title. In most conditions shaka-packager is the better backend. Switch a specific service to @@ -668,13 +663,10 @@ See [key vaults](vaults.md) for how to configure vault backends. ## Debugging DRM issues -A few configuration toggles help when a title will not decrypt: - -| Config key | Default | Effect | -|------------|---------|--------| -| `debug` | `false` | Global debug output. | -| `debug_keys` | `false` | Log decryption keys. | -| `debug_requests` | `false` | Log HTTP requests to the console with `-d`, each request to the [JSON debug log](troubleshooting.md#debug-requests), and the request and response bodies as files in a folder beside it. The folder holds tokens and content keys as sent and received. | +A few configuration toggles help when a title will not decrypt: `debug`, `debug_keys` (logs +the content keys) and `debug_requests` (logs each HTTP request, see +[Debugging HTTP traffic](troubleshooting.md#debug-requests)). Their defaults and effects are in +the [logging and debug reference](../reference/configuration/misc.md#logging-privacy-debug). ```yaml title="unshackle.yaml" debug_keys: true diff --git a/docs/guide/output-and-naming.md b/docs/guide/output-and-naming.md index 87dbf094..f0bbf6ec 100644 --- a/docs/guide/output-and-naming.md +++ b/docs/guide/output-and-naming.md @@ -44,17 +44,7 @@ output_template: songs: "{track_number}. {title}" ``` -The recognized kinds are: - -| Kind | Applies to | Default when unset | -|---|---|---| -| `movies` | Movies | *(required for movie downloads to be named, no built-in default)* | -| `series` | TV episodes | *(required for episode downloads to be named)* | -| `songs` | Music tracks | `"{track_number}. {title}"` | -| `albums` | Album **folders** only (see below) | - | - -!!! note - `movies` and `series` have no hardcoded filename fallback. If you download those title types, define their templates. `songs` falls back to `"{track_number}. {title}"` when omitted. +The kinds are `movies`, `series`, `sports`, `songs` and `albums` (folders only). The [`output_template` reference](../reference/configuration/output.md#output_template) gives what each kind applies to and what unshackle uses when you leave one out. ### Required vs. optional variables @@ -95,53 +85,7 @@ unshackle looks at the characters you place *between* variables to decide the fi ## Template variables -Every variable below is valid in both output and folder templates. unshackle takes the values from the downloaded media (through MediaInfo), from the title metadata, or from your config. A variable that does not apply to a title becomes an empty string. - -### Common / video - -| Variable | Meaning | Example | -|---|---|---| -| `title` | Title name (movie/show/song name; `$` is rendered as `S`) | `The Show` | -| `title_type` | Media kind of the title | `movie`, `series`, `music` | -| `year` | Release year | `2024` | -| `source` | Service tag / class name (empty with `--no-source`) | `EXAMPLE` | -| `quality` | Standard resolution with scan suffix | `1080p`, `2160p`, `576i` | -| `resolution` | Standard resolution number only | `1080` | -| `video` | Video codec | `H.264`, `H.265` | -| `hdr` | Dynamic-range label | `HDR`, `HDR10P`, `DV`, `DV.HDR`, `DV.HDR10P`, `DV.HDRVivid`, `HDRVivid`, `HLG` | -| `hfr` | High frame rate marker (frame rate > 30) | `HFR` | -| `3d` | Stereoscopic 3D marker (MV-HEVC video) | `3D` | -| `edition` | Edition label from the track, if any | `Directors Cut` | -| `tag` | Release-group tag (from `config.tag` or `--tag`) | `TAG` | -| `repack` | `REPACK` when the `--repack` flag is used | `REPACK` | -| `lang_tag` | Result of your `language_tags` rules, if configured | `MULTi` | - -!!! note "`quality` and `resolution` use the standard height" - unshackle names a video by the nearest standard height (4320, 2160, 1440, 1080, 720, 576, 540, - 480, 360 or 240) when it is within 10%. It measures the short side and the height that a 16:9 - picture of the same width has, and uses the larger one. So a cropped 1920x800, a padded - 1920x1088 and a 1080x1920 portrait video are all `1080p`. A short side within 16 lines of - 2160, 1440 or 1080 gives that height, so an ultrawide 2560x1080 is `1080p`. A size with no - standard height near it, such as 1600x900, keeps its own height. `dl -q` and the - `dl --export` file name use the same rule. - -!!! note "How `language_tags` rules match" - unshackle tries the rules in order, and they compare languages with the same [matching rules](downloading.md#exact-vs-fuzzy-matching) as `-l`: a rule condition of `en` matches `en-US`, `en-GB`, and any other `en-*` form, but `es-419` matches only `es-419`. Within a single rule, **all** conditions must match (AND logic) for it to apply. The first rule that fully matches wins. If none match, unshackle removes `{lang_tag?}` from the filename cleanly. - -### Episode-specific - -| Variable | Meaning | Example | -|---|---|---| -| `season` | Zero-padded season (`S%02d`) | `S01` | -| `episode` | Zero-padded episode (`E%02d`) | `E05` | -| `season_episode` | Combined | `S01E05` | -| `episode_name` | Episode title | `Pilot` | -| `part` | Part index of a [split episode](#split-episodes), empty otherwise | `2` | -| `absolute` | Absolute episode number, zero-padded to 3 digits, empty when unknown | `007` | -| `date` | ISO air date, empty when the episode has none | `2024-06-01` | - -!!! note "Daily & sports content" - When an episode has an air date, unshackle switches to date-based naming automatically. `season` and `season_episode` become the formatted air date, unshackle clears `episode` and `year`, and `{date}` holds the ISO date. The date's internal separator (dots or spaces) follows your `series` template style. +The [template variable reference](../reference/configuration/output.md#template-variables) lists every variable, what it holds, and the templates that can use it. Two kinds of episode get special names. ### Split episodes {#split-episodes} @@ -167,7 +111,7 @@ The same holds for a folder template of your own: `{season}` never picks up the !!! note "What media servers do with the part token" The form above follows scene practice for genuinely split episodes. Kodi stacks the parts back into one playable episode automatically. Jellyfin lists two versions of S01E01, still correct and playable, because its stacking pattern expects the part marker at the end of the name. Plex uses a closed-source scanner, so what it does with text after the part token is not known. -For custom templates there is also a standalone [`{part}`](../reference/configuration/output.md#output_template) variable. You rarely want it, see the caveat on that page. +For custom templates there is also a standalone [`{part}`](../reference/configuration/output.md#template-variables) variable. You rarely want it, see the caveat on that page. ### Sports events {#sports-events} @@ -180,10 +124,7 @@ output_template: sports: "{title}.{year?}" ``` -A `sports` template can use every series variable, with two differences: - -- `{date}` holds the air date in the separator style of the template (`2026.11.01`), and is empty when the event has no air date. -- `{year}` is empty when the event has an air date, because the date holds the year. +A `sports` template can use every series variable. `{date}` and `{year}` work differently there; see the [template variable reference](../reference/configuration/output.md#template-variables). An event with a year and no air date, and an event with an air date: @@ -196,35 +137,6 @@ Club.League.2026/ A `sports` folder template groups by `{year}`, or by the air year when the event has no year. `{season}`, `{episode}` and `{season_episode}` are not useful in a `sports` template. Use `-w S01E02` to select an event: the season and episode numbers stay on the title. -### Audio - -| Variable | Meaning | Example | -|---|---|---| -| `audio` | Audio codec; rename it with [`codec_names`](../reference/configuration/output.md#codec_names) | `DDP`, `DD`, `AAC`, `DTS-X` | -| `audio_channels` | Channel layout; bed.LFE.heights when the track has height channels | `5.1`, `2.0`, `5.1.4` | -| `audio_full` | Codec + channels combined; a name that ends in a digit gets a separator | `DDP5.1`, `DTS-X.5.1.4`, `AC4.2.0` | -| `atmos` | `Atmos` when an audio track in the file carries JOC or is marked Atmos, as in the `--list` row (MediaInfo shows no JOC for AC-4) | `Atmos` | -| `dual` | `DUAL` for two audio languages (see [`dual_multi_mode`](../reference/configuration/download.md#dual_multi_mode)) | `DUAL` | -| `multi` | `MULTi` for more than two audio languages | `MULTi` | -| `dubbed` | `DUBBED` for a single audio language that is not the original (strict mode only) | `DUBBED` | - -### Music-specific - -| Variable | Meaning | -|---|---| -| `track_number` | Zero-padded track number | -| `artist` / `album_artist` | Artist / album artist (falls back to artist) | -| `album` | Album name | -| `disc` | Disc number (only shown when greater than 1) | -| `track_total` / `disc_total` | Totals | -| `release_type` | `album`, `single`, `ep`, or another type the service supplies | -| `genre` | Genre | -| `explicit` | `Explicit` when flagged | -| `isrc` / `upc` / `label` | ISRC, UPC and record label | - -!!! warning "Unknown variables are ignored, not errors" - If you use a variable that is not in the list above, unshackle gives a warning at startup but continues. Double-check spelling. A typo'd `{quailty}` stays in the filename literally, or unshackle drops it. unshackle does not fill it in. - ## Folder templates Folder templates sit under a special `folder` config key inside `output_template`. unshackle reads this config key separately from the filename kinds. You can give it a single string (for all title kinds) or a per-kind map. @@ -250,12 +162,12 @@ Folder templates sit under a special `folder` config key inside `output_template albums: "{artist} - {album} ({year})" ``` -The per-kind folder config keys are `movies`, `series`, `sports`, `songs`, and `albums`. Any other config key gives a startup warning. Folder templates permit path separators (`/` or `\`). unshackle formats each segment independently, so you can assemble nested directory structures like `Show/Season 01`. unshackle reads the separator style from the whole template, so it spaces every segment alike. +The per-kind folder config keys are the [output kinds](../reference/configuration/output.md#output_template). Any other config key gives a startup warning. Folder templates permit path separators (`/` or `\`). unshackle formats each segment independently, so you can assemble nested directory structures like `Show/Season 01`. unshackle reads the separator style from the whole template, so it spaces every segment alike. **Fallback behaviour:** - A per-kind folder template wins if present. If there is none, unshackle uses the single `folder` string. If there is no `folder` string either, unshackle falls back to a built-in default. -- Built-in defaults when no folder template is set. Movies get no folder at all unless a `movies` folder template (or a single-string `folder` template) exists. Series fall back to a folder *derived* from the `series` output template (stripping `{episode}`, `{episode_name}`, and collapsing `{season_episode}` down to `{season}`). A sports event with no `sports` folder template uses the `series` folder template, or derives its folder from the `sports` output template when there is no folder template. Music albums fall back to `{artist} - {album} ({year})`. If the song has no year, the folder name is only `{artist} - {album}`. +- Built-in defaults when no folder template is set. Movies get no folder at all unless a `movies` folder template (or a single-string `folder` template) exists. Series fall back to a folder *derived* from the `series` output template (stripping `{episode}`, `{episode_name}`, and collapsing `{season_episode}` down to `{season}`). A sports event with no `sports` folder template uses the `series` folder template, or derives its folder from the `sports` output template when there is no folder template. Music albums fall back as the [`albums` row](../reference/configuration/output.md#output_template) gives. !!! note "Movies are flat by default" Episodes and songs are always foldered. unshackle writes movies directly into the output directory *unless* you define a `movies` folder template (or a single-string `folder` template, which folders every kind). Set one if you want each movie in its own directory. @@ -488,13 +400,7 @@ muxing: subtitle: en ``` -| Key | Type | Default | Effect | -|---|---|---|---| -| `set_title` | bool | `true` | Write the title name into the MKV container title with `--title`. Set to `false` to omit it. | -| `merge_video` | bool | `false` | Group video tracks that share the same resolution, range, and codec into one file so only language varies inside it. | -| `merge_audio` | bool | `true` | Merge audio tracks of the same kind so multiple languages sit in one file. | -| `default_language` | map | *(unset)* | Preferred language per track type (`video` / `audio` / `subtitle`). A track in the preferred language is flagged as the default track. | -| `default_subtitle_type` | str or list | *(unset)* | The subtitle types that can take the default flag, in order: `forced`, `normal`, `sdh` (CC counts as SDH). The first subtitle track of the first type that the title has gets the flag. | +The [`muxing` reference](../reference/configuration/download.md#muxing) gives the type, default and values of each config key. When no track has the preferred language, unshackle applies sensible defaults. The video default falls back to the title language, then the original-language track, then the first track. The audio default is the original-language track. The subtitle default is a forced track in the language of the default audio track. @@ -550,13 +456,7 @@ tag_group_name: true tag_imdb_tmdb: true ``` -| Key | Type | Default | Effect | -|---|---|---|---| -| `tag` | str | `""` | The release-group tag used for `{tag}`. | -| `tag_group_name` | bool | `true` | Write the group name (`config.tag`) into the MKV `Group` metadata tag. | -| `tag_imdb_tmdb` | bool | `true` | Look up and embed IMDb / TMDB / TVDB external-ID tags in the MKV metadata (uses `tmdb_api_key` / `tvdb_api_key` / `simkl_client_id` when available). | - -unshackle writes the IDs as the Matroska `IMDB`, `TMDB`, and `TVDB2` tags. `TVDB2` values carry the +The [tagging keys](../reference/configuration/output.md#tagging-naming-keys) give the type and default of `tag`, `tag_group_name` and `tag_imdb_tmdb`. unshackle writes the IDs as the Matroska `IMDB`, `TMDB`, and `TVDB2` tags. `TVDB2` values carry the entity prefix the [Matroska tagging spec](https://www.matroska.org/technical/tagging.html) requires: `series/73871` for a show, `movies/113` for a film. @@ -583,12 +483,7 @@ By default unshackle transliterates non-ASCII characters into ASCII equivalents. unicode_filenames: true ``` -| Value | Result | -|---|---| -| `false` (default) | `기생충` → transliterated ASCII; accents stripped. | -| `true` | Native characters preserved in filenames and folders, with the vowel and tone marks of languages such as Thai, Hindi and Bengali. | - -With each value, unshackle first normalises the name to Unicode NFC. A title that a service sends in composed form and in decomposed form gives the same name. +The [`unicode_filenames` row](../reference/configuration/output.md#tagging-naming-keys) gives both values. A title that a service sends in composed form and in decomposed form gives the same name. Regardless of this setting, unshackle always removes or replaces a set of filesystem-unsafe and structural characters during sanitisation. For example, `/` and `;` become ` & `, and unshackle removes characters like `\ * ! ? , ' " < > | $ # ~`. This is why you must never put path-unsafe characters directly in a template. To change other text in a name, such as `&` to `and`, use [`filename_replacements`](../reference/configuration/output.md#filename_replacements). @@ -596,60 +491,16 @@ unshackle warns at startup about a template that contains `< > : " / \ | ? *`. I ## Directory & filename configuration -The `directories` config key relocates unshackle's working folders. You can move only the folders in the table below. unshackle protects the core package paths and silently ignores them if you try to override them. - -```yaml title="unshackle.yaml" -directories: - downloads: "~/Media/unshackle" - temp: "/mnt/fast/unshackle-temp" - cache: "~/.cache/unshackle" - cookies: "~/.config/unshackle/cookies" - logs: "~/.config/unshackle/logs" -``` - -| Name | Purpose | -|---|---| -| `downloads` | Default output directory for finished files. | -| `temp` | Working directory for in-progress downloads, muxing, and intermediate files. | -| `cache` | Title/HTTP cache and update-check state. | -| `cookies` | Per-service cookie files. | -| `logs` | Log files. | -| `exports` | Export JSONs. | -| `services`, `vaults`, `fonts`, `commands` | Search paths for services, key-vault backends, bundled fonts, and CLI commands. | -| `wvds`, `prds`, `dcsl` | Widevine devices, PlayReady devices, and DCSL data. | - -Paths can hold a `~` for expansion. unshackle protects the names `app_dirs`, `core_dir`, `namespace_dir`, `user_configs`, and `data`, so you cannot change them. - -### Filename patterns - -The `filenames` config key overrides the naming patterns for a handful of internal files. These are **not** your media output names. They are logs, temp files, and per-service configs. - -```yaml title="unshackle.yaml" -filenames: - log: "unshackle_{name}_{time}.log" - chapters: "Chapters_{title}_{random}.txt" - subtitle: "Subtitle_{id}_{language}.srt" -``` - -| Name | Default | Where | -|---|---|---| -| `log` | `unshackle_{name}_{time}.log` | `directories.logs` | -| `debug_log` | `unshackle_debug_{service}_{time}.jsonl` | `directories.logs` | -| `config` | `config.yaml` | per-service directory | -| `root_config` | `unshackle.yaml` | main config filename | -| `chapters` | `Chapters_{title}_{random}.txt` | `directories.temp` | -| `subtitle` | `Subtitle_{id}_{language}.srt` | `directories.temp` | +The `directories` config key moves unshackle's working folders, such as `downloads`, `temp` and `cache`. The `filenames` config key changes the names of unshackle's own working files, such as logs and the chapters file; it does not change the names of your media files. The [Directories reference](../reference/configuration/directories.md) lists each folder and each file name, with its default. ### Chapters naming {#chapters-naming} -When a title has chapters, unshackle writes them to an OGM chapters file (`filenames.chapters`) and passes it to the muxer. Unnamed chapters use the `chapter_fallback_name` template: +When a title has chapters, unshackle writes them to an OGM chapters file (`filenames.chapters`) and passes it to the muxer. A chapter with no name gets the [`chapter_fallback_name`](../reference/configuration/output.md#tagging-naming-keys) template: ```yaml title="unshackle.yaml" chapter_fallback_name: "Chapter {i:02}" ``` -The fallback can hold two placeholders: `{i}` (chapter number, starting at 1) and `{j}` (which increments only for unnamed chapters). It permits standard format directives like `{i:02}`. - ## Removed & migrated options !!! warning "`scene_naming` was removed" diff --git a/docs/guide/proxies-and-vpn.md b/docs/guide/proxies-and-vpn.md index 8cf214e6..a306a588 100644 --- a/docs/guide/proxies-and-vpn.md +++ b/docs/guide/proxies-and-vpn.md @@ -15,10 +15,9 @@ a query to a real proxy URL: [basic static proxies](#basic-static-proxies), !!! note "Where proxies are configured" All proxy provider configuration lives under the top-level `proxy_providers:` - config key in your `unshackle.yaml`. Each proxy provider has its own sub-key, and - the config keys inside it map directly onto that proxy provider's settings. See the - [Configuration file](../getting-started/configuration-file.md) page for where the - file lives and how unshackle loads it. + config key in your `unshackle.yaml`. Each proxy provider has its own sub-key. The + [`proxy_providers` reference](../reference/configuration/network.md#proxy_providers) lists the config keys of each + proxy provider, with their types and defaults. ## The `--proxy` flag @@ -154,9 +153,9 @@ such as `--proxy nordvpn:us`, fails and shows the reason it did not load. !!! note "Auto-loading providers" Most providers only load when you configure them under `proxy_providers:`. Three are - special: **ExpressVPN** and **Proton VPN** also load automatically once their cache - file exists on disk (even with no YAML), and **Hola** loads automatically - whenever the `hola-proxy` binary is found on your `PATH`. + special: **ExpressVPN** also loads once its token cache exists on disk (even with no + YAML), **Proton VPN** once its cookie file exists, and **Hola** + whenever unshackle finds the `hola-proxy` binary. ### Connection feedback @@ -385,8 +384,7 @@ proxy_providers: - If a country has a single proxy string, that proxy is always returned. - If it has a list and you give a plain country code, unshackle picks one at random. Append an index (`de1`, `de2`) to pin a specific entry. -- unshackle normalises each URL (a missing scheme defaults to `http`) and validates it, - so it rejects a malformed URI up front and does not fail mid-download. +- See the [`basic` reference](../reference/configuration/network.md#basic) for the URI rules. ```shell unshackle dl --proxy de2 EXAMPLE 81234567 @@ -617,25 +615,13 @@ unshackle normalises friendly names to Gluetun's identifiers (for example `pia` ### Configuration -Each VPN provider you want to use gets an entry under `providers:`, carrying its VPN type, -credentials, and how your region aliases map onto Gluetun's server selectors. +Each VPN provider you want to use gets an entry under `providers:`, with its VPN type, its +credentials, and how your region aliases map onto Gluetun's server selectors: ```yaml title="unshackle.yaml" proxy_providers: gluetun: providers: - windscribe: - vpn_type: wireguard - credentials: - private_key: YOUR_WIREGUARD_PRIVATE_KEY - addresses: YOUR_WIREGUARD_ADDRESS - preshared_key: YOUR_PRESHARED_KEY - server_countries: - us: US - uk: GB - server_cities: {} - server_hostnames: {} - extra_env: {} nordvpn: vpn_type: wireguard credentials: @@ -643,59 +629,19 @@ proxy_providers: server_countries: us: US de: DE - - # Global settings (all optional) - base_port: 8888 - auto_cleanup: true - container_prefix: unshackle-gluetun - auth_user: null - auth_password: null - verify_ip: true ``` -**Per-provider keys:** - -| Key | Purpose | -|---|---| -| `vpn_type` | `wireguard` (default) or `openvpn`. | -| `credentials` | The secrets for the tunnel; see the credential rules below. | -| `server_countries` | Maps your region alias (e.g. `us`) to Gluetun's country value (e.g. `US`). | -| `server_cities` | Optional. Maps an alias to a Gluetun city. | -| `server_hostnames` | Optional. Maps an alias directly to a specific server hostname. | -| `extra_env` | Optional. Raw environment variables merged into the container last, for any Gluetun setting not covered above. | - -**Credential rules by VPN type:** - -=== "WireGuard" - - - `private_key` is **always** required. - - `surfshark`, `mullvad`, and `ivpn` also require `addresses`. - - `windscribe` additionally requires **both** `addresses` and `preshared_key` - (`preshared_key` may be an empty string, but the config key must be present). - Get both from the [Windscribe WireGuard config generator](https://windscribe.com/getconfig/wireguard). - - NordVPN and Proton VPN need only `private_key`. - -=== "OpenVPN" - - - Requires `username` and `password`. +The [`gluetun` reference](../reference/configuration/network.md#gluetun) lists every config key of an entry, the global config keys +(`base_port`, `auto_cleanup`, `verify_ip` and others) and the credentials that each VPN +provider needs. For Windscribe WireGuard, get `addresses` and `preshared_key` from the +[Windscribe WireGuard config generator](https://windscribe.com/getconfig/wireguard). !!! tip "Which `vpn_type` should I pick?" - WireGuard is the default because it **can be faster**, but it needs the fiddlier - credential setup above (private keys, and for some providers `addresses` and a - `preshared_key`). OpenVPN is the **simplest** to configure (only a username and - password) at the cost of some speed. If you start out, or if you have credential - trouble, OpenVPN is the path of least resistance. Switch to WireGuard when you want - the extra throughput. - -**Global keys:** - -| Key | Default | Purpose | -|---|---|---| -| `base_port` | `8888` | The first local port to expose proxies on. Additional containers take the next free ports. | -| `auto_cleanup` | `true` | Remove containers on exit. If `false`, containers are only stopped, not deleted. | -| `container_prefix` | `unshackle-gluetun` | Prefix for Docker container names. | -| `auth_user` / `auth_password` | `null` | Optional HTTP-proxy credentials. If set, the local proxy requires auth and the credentials are embedded in the proxy URL. | -| `verify_ip` | `true` | After connecting, verify the container's real exit IP and region. | + WireGuard is the default because it **can be faster**, but it needs more credential + setup (private keys, and for some providers `addresses` and a `preshared_key`). + OpenVPN is the **simplest** to configure (only a username and password) at the cost of + some speed. If you start out, or if you have credential trouble, use OpenVPN. Switch to + WireGuard when you want the extra throughput. ### Region selection @@ -794,13 +740,8 @@ proxy_providers: myserver: usny-newyork-2 ``` -**Default file location:** - -| File | Default path | -|---|---| -| Token cache | `{cache}/vpn/expressvpn_tokens.json` | - -Where `{cache}` is your configured cache directory. +The [`expressvpn` reference](../reference/configuration/network.md#expressvpn) lists every config key and the default +path of the token cache. **Query forms:** @@ -815,10 +756,6 @@ Where `{cache}` is your configured cache directory. The resolved proxy is an HTTPS proxy on port `443`. On success, unshackle prints a location summary such as `(USA - New York, #3 of 5): .214`. -!!! note "Cache safety" - unshackle writes ExpressVPN's token cache with `0600` permissions, so the refresh - token is never briefly world-readable. - ## NordVPN NordVPN uses your **Service Credentials**, not your normal NordVPN login. Make them @@ -835,12 +772,10 @@ proxy_providers: us:seattle: 5678 ``` -**Required keys:** `username`, `password`. unshackle validates them up front: the -combined username and password must be exactly 48 alphanumeric characters (case-insensitive), and -the username must not contain an `@`. If validation fails, you have almost certainly used -your login credentials instead of your service credentials. +unshackle checks the credentials when it loads: login credentials fail the check of the +[`nordvpn` reference](../reference/configuration/network.md#nordvpn). -`server_map` is optional and maps a region (or `code:city`) to a pinned NordVPN server ID, or to a +`server_map` is optional and pins a region to a NordVPN server ID, or to a selector (see [Choose a server network](#choose-a-server-network)). Its main use is to tune performance: for a given streaming service one specific server often performs noticeably better than NordVPN's recommended pick. So you can hard-code @@ -908,15 +843,8 @@ that free Proton accounts work, but Proton limits them to its free-tier exit cou the sign-in lapses at Proton's ~24h TTL and you must export it again. This is exactly why TV login is the better method for set-and-forget use. -**Default file locations:** - -| File | Default path | -|---|---| -| Cookies | `{cookies}/vpn/protonvpn.txt` | -| Session cache | `{cache}/vpn/protonvpn.json` | - -Proton VPN **auto-loads** if its cookie file exists. Like ExpressVPN, unshackle writes -its cache file with `0600` permissions. +The [`protonvpn` reference](../reference/configuration/network.md#protonvpn) lists every config key and the default paths +of the cookie file and the TV login cache. !!! note "Cache vs cookie precedence" If both a TV-login cache and a cookie file exist, unshackle **prefers the cache** @@ -980,14 +908,11 @@ proxy_providers: us:seattle: us-sea ``` -**Required keys:** `username`, `password`, validated with the same 48-character rule as -NordVPN (combined username+password must be 48 alphanumeric characters, case-insensitive, no `@`). +unshackle checks the credentials with the same [48-character rule](../reference/configuration/network.md#nordvpn) as NordVPN. `server_map` optionally pins a server per region, or holds a selector (see [Choose a server network](#choose-a-server-network)). Give the server name from Surfshark's -server list, for example `us-dal`. A full hostname such as `us-dal.prod.surfshark.com` also -works. Surfshark does not use numeric server IDs. unshackle ignores a numeric or empty value -and logs a warning. A `us:seattle` entry applies only to that city query, and it does not -fall back to the `us` entry. +server list, for example `us-dal`; Surfshark has no numeric server IDs. The +[`surfsharkvpn` reference](../reference/configuration/network.md#surfsharkvpn) gives the value rules. **Query forms:** @@ -1021,9 +946,10 @@ Surfshark configuration. This needs the `server_proxy` grant on your API key. ## Windscribe -Windscribe uses **Service Credentials** from its -[OpenVPN config page](https://windscribe.com/getconfig/openvpn). unshackle only makes -sure that a username and a password are present (there is no 48-character rule). +Windscribe uses its proxy **Service Credentials**, which Windscribe issues through its +`ServerCredentials` API. The OpenVPN and IKEv2 credentials of Windscribe's config +generator pages do not work on the proxy: it refuses them with `407`. unshackle only makes +sure that a username and a password are present. ```yaml title="unshackle.yaml" proxy_providers: @@ -1035,9 +961,9 @@ proxy_providers: us:seattle: us-seattle.totallyacdn.com ``` -**Required keys:** `username`, `password`. `server_map` optionally takes a selector (see +`server_map` optionally takes a selector (see [Choose a server network](#choose-a-server-network)), or maps a region (or -`region:city`) directly to a hostname. +`region:city`) directly to a hostname. See the [`windscribevpn` reference](../reference/configuration/network.md#windscribevpn). **Query forms:** @@ -1101,8 +1027,6 @@ The returned proxy is HTTPS on **port 443**. - [Downloading](downloading.md): the full `dl` command guide, including where proxy flags sit in the download flow. -- [Configuration file](../getting-started/configuration-file.md): the `unshackle.yaml` - reference, including directories for cookies and cache used by the cookie-based - providers. -- [Configuration reference](../reference/api/config.md): the developer-facing - configuration API, including the `proxy_providers` structure. +- [Network & proxy reference](../reference/configuration/network.md): every `proxy_providers` config key. +- [Directories](../reference/configuration/directories.md): the cookies and cache + directories that the cookie-based providers use. diff --git a/docs/guide/subtitles.md b/docs/guide/subtitles.md index 63c0e6e5..0d162f6f 100644 --- a/docs/guide/subtitles.md +++ b/docs/guide/subtitles.md @@ -58,7 +58,7 @@ format-appropriate clean-up to make a single, valid file: 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 separate overlapping cues. By default unshackle keeps the original styling and layout - (see [`preserve_formatting`](#subtitle-configuration)). + (see [`preserve_formatting`](../reference/configuration/download.md#subtitle)). - **Cue markup normalisation**: unshackle removes the WebVTT-only parts of a cue payload, so no player draws them as dialogue. See [Cue markup](#cue-markup-and-html-entities). @@ -202,7 +202,7 @@ CCExtractor tool on your `PATH`. When a language has an SDH track but **no** plain (non-SDH, non-forced) track, unshackle can make a clean non-SDH version for you by stripping the hearing-impaired cues: sound effects, speaker labels, music notes, and similar. This is on by default and -controlled by the [`strip_sdh`](#subtitle-configuration) config key. +controlled by the [`strip_sdh`](../reference/configuration/download.md#subtitle) config key. The check uses the same [matching rules](downloading.md#exact-vs-fuzzy-matching) as `--s-lang`. A plain track covers an SDH track only when it is the same variant: `en` and @@ -210,31 +210,18 @@ The check uses the same [matching rules](downloading.md#exact-vs-fuzzy-matching) copy. When unshackle creates a stripped copy, it keeps the original SDH track as well, so you end up with both. -The [`sdh_method`](#subtitle-configuration) config key selects the stripping engine -itself. The default (`auto`) prefers the `subby` cleaner for SRT, falls back to -SubtitleEdit when you install it, and otherwise uses the built-in `filter-subs` -approach. - -Every engine removes the same three things: bracketed sound effects (`[MUSIC PLAYING]`, -`(door creaks)`), speaker labels (`MAN:`), and font tags. Every engine keeps plain -dialogue and inline `` styling. They differ on music and lyric lines: - -| `sdh_method` | Engine that runs | Lyric lines (`♪ ... ♪`) | -| --- | --- | --- | -| `auto` | `subby` for an SRT track. SubtitleEdit for any other format when you install it, otherwise `filter-subs`. | Kept, unless the fallback reaches `filter-subs`. | -| `subby` | `subby`, but only for a track that is already SRT. Any other format falls through to `filter-subs`. | Kept for SRT, removed otherwise. | -| `subtitleedit` | SubtitleEdit when you install it, otherwise `filter-subs`. | Kept with SubtitleEdit, removed without it. | -| `filter-subs` | `filter-subs` always. | Removed. | +The [`sdh_method`](../reference/configuration/download.md#sdh-engines) config key selects the stripping engine +itself. Every engine removes sound effects, speaker labels and font tags. The engines differ +on lyric lines and on the formats that they read. Pick `filter-subs` when you want lyrics gone as well. Pick `subby` or install SubtitleEdit when you want to read along with the songs. !!! note "Why `convert_before_strip` exists" - `subby`'s SDH stripper only operates on SRT. Handed any other codec it returns - silently without stripping anything, not an error but a no-op that leaves the SDH - cues in place. This is the whole reason for [`convert_before_strip`](#subtitle-configuration): - non-SubtitleEdit engines need the subtitle converted to SRT first, or the - hearing-impaired cues stay in the file. + `subby` and `filter-subs` read only SRT. unshackle gives `subby` only a track that is + already SRT, and sends any other track to `filter-subs`. This is the reason for + [`convert_before_strip`](../reference/configuration/download.md#subtitle): `filter-subs` + needs the subtitle converted to SRT first, or the hearing-impaired cues stay in the file. ## Converting subtitle formats @@ -273,25 +260,13 @@ order in which they are drawn. A `sidecar_format: srt` will still lossily flatten styled subtitles, dropping positioning, colours, and styling, and a per-download `--sub-format srt` forces the muxed track to convert as well. To keep raw styled sidecars, set - [`sidecar_format: original`](#subtitle-configuration). + [`sidecar_format: original`](../reference/configuration/download.md#subtitle). ### How the conversion backend is chosen Under the hood unshackle picks the highest-fidelity converter that supports the -source→target pair. Which converter runs depends on the -[`conversion_method`](#subtitle-configuration) config key (default `auto`) and the -formats involved: - -| Backend | Best at | Requires | -| --- | --- | --- | -| `subtitleedit` | Highest fidelity; preserves positioning and italics | SubtitleEdit installed | -| `subby` | Native SRT output with clean-up | - | -| `pysubs2` | Best fidelity for styled SSA/ASS | - (pure Python, always available) | -| `pycaption` | Last-resort fallback; flattens styling | - | - -With `conversion_method: auto`, unshackle ranks these automatically per conversion. -Setting it to a specific value pins that backend as the first choice, falling back to -others only if the pin cannot convert the pair. +source→target pair. Which converter runs depends on the formats and on the +[`conversion_method`](../reference/configuration/download.md#conversion-backends) config key. #### What each backend preserves @@ -368,7 +343,7 @@ every `conversion_method`: By default unshackle muxes subtitles **into** the final `.mkv`. You can instead (or additionally) write them as separate sidecar files next to the video, controlled by the -[`output_mode`](#subtitle-configuration) config key: +[`output_mode`](../reference/configuration/download.md#subtitle) config key: === "mux (default)" @@ -410,7 +385,7 @@ Show.S01E01.1080p.WEB.en.sdh.srt ``` The pattern is `{base}.{language}[.forced][.sdh].{extension}`. The -[`sidecar_format`](#subtitle-configuration) config key sets the sidecar file format. Use +[`sidecar_format`](../reference/configuration/download.md#subtitle) config key sets the sidecar file format. Use a format name like `srt` or `vtt`, or `original` to keep each subtitle in its downloaded format. @@ -424,7 +399,7 @@ unshackle dl --sub-font "Noto Sans" EXAMPLE 81234567 ``` `--sub-font` sets only the font name. The rest of the look comes from -[`subtitle.ass_style`](#subtitle-configuration), a mapping of style fields. A field takes its +[`subtitle.ass_style`](../reference/configuration/download.md#subtitle), a mapping of style fields. A field takes its [pysubs2 name](https://pysubs2.readthedocs.io/en/latest/api-reference.html#ssastyle-style-of-subtitles) (`primarycolor`) or its ASS name (`PrimaryColour`). Give sizes and margins for a 1080-line picture. unshackle writes a 1080-line canvas in the shape of the video, and the player scales @@ -492,19 +467,7 @@ subtitle: sidecar_format: srt ``` -| Key | Default | Values | Purpose | -| --- | --- | --- | --- | -| `strip_sdh` | `true` | `true` / `false` | Auto-generate a stripped non-SDH copy when a language has only an SDH track. | -| `preserve_formatting` | `true` | `true` / `false` | Keep original WebVTT styling and layout during sanitization. When `false`, WebVTT is re-encoded more aggressively (merging identical cues, dropping empty ones). | -| `conversion_method` | `auto` | `auto`, `subby`, `pysubs2`, `subtitleedit`, `pycaption` | Which conversion backend to prefer. `auto` ranks them per conversion. | -| `sdh_method` | `auto` | `auto`, `subby`, `subtitleedit`, `filter-subs` | Engine used to strip hearing-impaired cues. | -| `convert_before_strip` | `true` | `true` / `false` | Convert a subtitle to SRT before stripping SDH (for non-SubtitleEdit engines). | -| `output_mode` | `mux` | `mux`, `sidecar`, `both` | Whether subtitles are embedded, written as sidecars, or both. | -| `sidecar_format` | `srt` | a format name (e.g. `srt`, `vtt`) or `original` | Format used for sidecar files. | -| `group_by` | `type` | `type`, `language` | Whether all tracks of one type stay together, or each language stays next to its own variants. | -| `language_priority` | *(unset)* | a list of languages | Languages to sort to the top. The rest keep the default order. Nothing is removed. | -| `dedupe_codecs` | *(unset)* | a list of codecs, e.g. `[VTT, STPP, WVTT]` | Keep one copy of a subtitle that the service sends in several codecs: the earliest listed codec wins. | -| `ass_style` | *(unset)* | a mapping of pysubs2 style fields | The look of subtitles converted to ASS; makes ASS the default output format. See [custom font and style](#custom-font-and-style). | +The [`subtitle` reference](../reference/configuration/download.md#subtitle) lists every config key of the block, with its type, default and values. ### Which settings to change @@ -530,8 +493,8 @@ Two keys read as if they control markup, and do not: markup in the file: [cue markup normalisation](#cue-markup-and-html-entities) runs either way. - **`convert_before_strip`** applies to SDH stripping, not to your output format. It - converts the working copy to SRT so a non-SubtitleEdit engine can read it. Turning it - off makes `subby` and `filter-subs` no-ops on anything that is not already SRT. + converts the working copy to SRT so `filter-subs` can read it. Turning it + off makes `filter-subs` a no-op on anything that is not already SRT. !!! tip "SubtitleEdit is optional but recommended" Several high-fidelity paths (the best-quality conversions and the SubtitleEdit SDH diff --git a/docs/guide/troubleshooting.md b/docs/guide/troubleshooting.md index c1da0394..f783f27f 100644 --- a/docs/guide/troubleshooting.md +++ b/docs/guide/troubleshooting.md @@ -355,13 +355,9 @@ Each command reports how many files it removed and how much space it freed, then ## Why is my config not being picked up? -unshackle loads the **first** `unshackle.yaml` it finds, in this order: +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. -1. `unshackle.yaml` inside the package's namespace directory. -2. `unshackle.yaml` in the parent of that directory. -3. `unshackle.yaml` in your OS user-config directory: on Linux `~/.config/unshackle/unshackle.yaml`, on Windows `%LOCALAPPDATA%\unshackle\unshackle.yaml`, on macOS `~/Library/Application Support/unshackle/unshackle.yaml`. - -If you have config in more than one of these, 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 all three candidate locations 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. --- diff --git a/docs/guide/vaults.md b/docs/guide/vaults.md index 1db41b56..677b7610 100644 --- a/docs/guide/vaults.md +++ b/docs/guide/vaults.md @@ -1,11 +1,11 @@ # Key Vaults -A **key vault** is a store of DRM **content keys** that unshackle remembers between downloads. Once unshackle has recovered a title's keys, it saves them to your configured vaults. The next time you download something that reuses those same keys, unshackle finds them in a vault instead of performing another license exchange. The download starts faster and puts less load on the service. +A **key vault** is a store of DRM **content keys** that unshackle remembers between downloads. Once unshackle has recovered a title's keys, it saves them to your configured vaults. The next time you download something that reuses those same keys, unshackle finds them in a vault instead of performing another licence exchange. The download starts faster and puts less load on the service. Vaults are entirely optional, but if you download regularly they are one of the biggest quality-of-life improvements you can configure. -!!! tip "Vaults save license calls even on the very first download" - The benefit is not limited to repeat downloads. Within a single run, a service often issues the *same* Key ID and content key for both the video and audio tracks. The same pair frequently covers several resolutions or bitrates of the same title. Once unshackle has recovered a key it writes it to your vaults immediately. The moment the next track presents a KID it has already seen, the key comes from the vault instead of another license exchange. A single fetched key can therefore satisfy many tracks in one run. +!!! tip "Vaults save licence calls even on the very first download" + The benefit is not limited to repeat downloads. Within a single run, a service often issues the *same* Key ID and content key for both the video and audio tracks. The same pair frequently covers several resolutions or bitrates of the same title. Once unshackle has recovered a key it writes it to your vaults immediately. The moment the next track presents a KID it has already seen, the key comes from the vault instead of another licence exchange. A single fetched key can therefore satisfy many tracks in one run. ## What a vault stores @@ -18,33 +18,40 @@ A vault stores every content key as a **KID → KEY** pair, grouped by **service !!! note "Why keys are matched by KID" Vaults match keys by KID, never by PSSH/CENC header. A KID does not change unless the underlying video file itself changes, whereas the PSSH box can vary between requests for the very same content. That makes the KID a far more reliable match key. -!!! info "Null keys are ignored everywhere" - A content key made entirely of zeroes (`00000000000000000000000000000000`) is treated as "no key". Vault lookups skip it, and every backend raises an error if you try to add one. This prevents a placeholder key from masking a real one. +A null content key (empty or all zeroes) means "no key": a lookup skips it and no vault stores it. ## How lookups and caching work -When unshackle needs a content key during a download it asks your vaults **in the order they appear in your config**. It returns the first non-null key it finds and stops searching. If a vault raises a permission error or is unreachable, unshackle skips it and continues the search with the next one. unshackle does not ask a remote vault again for the rest of the run when it is unreachable or answers with a body that is not a JSON object. It always asks a local SQLite vault. Each failure of a vault shows one warning with the host and the reason; the same failure again goes to the debug log. +When unshackle needs a content key during a download, it asks each local SQLite vault first, one at a time in the order of your config. Then it asks the other vaults at the same time, and the first content key that a vault returns wins. unshackle skips a vault that raises a permission error or is unreachable. unshackle does not ask a remote vault again for the rest of the run when it is unreachable or answers with a body that is not a JSON object. It always asks a local SQLite vault. Each failure of a vault shows one warning with the host and the reason; the same failure again goes to the debug log. A track needs no licence when a vault holds the content key of the KID that encrypts it. The DRM header of the track can name more KIDs, for example those of other tracks. Before the decrypt, unshackle reads the downloaded file, and licenses each of those KIDs that the file uses and no vault holds. When unshackle cannot read which KIDs the file uses, it licenses all of them. -When unshackle recovers new keys from a license, it pushes them to **all** configured vaults, so every vault gradually converges on the same set of keys. Two rules apply to pushing: +When unshackle recovers new keys from a licence, it pushes them to **all** configured vaults, so every vault gradually converges on the same set of keys. Two rules apply to pushing: -- unshackle skips keys that already exist in a vault (it never overwrites or deletes existing data). +- unshackle skips keys that already exist in a vault, and never overwrites them. Only a failed decode check removes a pair (see below). - A vault marked `no_push: true` receives lookups, but unshackle never writes to it. This is useful for read-only or shared upstream vaults you do not own. unshackle pushes keys from every source, not only a local CDM. A run against a remote server that licenses with its own CDM (`--remote`) writes the keys the server returns, and `unshackle import` writes the keys it reads from an export file. ### Wrong keys from a poisoned vault -A public vault can return the right KID with a wrong content key. The decrypters accept a wrong content key and write noise. unshackle therefore trusts a content key from a vault only after FFmpeg decodes the decrypted track with strict error detection. For a fragmented MP4, unshackle reads from the encrypted file which fragments each KID encrypts, and FFmpeg decodes up to three windows of each KID: from its first, middle and last fragment on through the next fragments of that KID, for up to 4 seconds. A window never runs into a fragment of another KID or a clear fragment. A clear lead or a lead under another KID therefore cannot hide a wrong content key, and only the KID that fails is flagged. When every KID in the map has a content key, the map is complete, and a KID that is not in it does not encrypt this file. This file does not judge that KID; the file of its own track judges it. A file with no encrypted sample entry and no encrypted fragment, for example a clear audio track, judges no KID, so it neither flags nor copies a content key. A KID that is not in an incomplete map, for example one with an all-zero KID, and every KID of any other file, gets one check of the whole file. FFmpeg decodes the first seconds and the last seconds. A failure there flags each of those KIDs. When a mapped KID fails, the KIDs that are not in the map get no verdict from that pass; the retry with the replaced key judges them. Content keys from a licence skip this check, with two exceptions: a FairPlay-only track that the FairPlay bridge licensed, and a track of a DRM plugin that licenses locally. A plugin track gets the check of the whole file after the merge of its decrypted segments. An import also checks these content keys when it reads them from an export file. When one of these fails, unshackle flags the pair, stops the track and keeps no output file. A file this FFmpeg build cannot judge counts as a pass, never as a wrong content key: a codec it has no decoder for, or a header it cannot read. A plugin that decrypts each segment can fix the merged file before the check. A pass is not proof. A wrong content key for HEVC video can decode without an error for some seconds, most often at a low resolution, and that content key passes the check. Damage to a small part of the slice data, such as one corrupt NAL unit, also often decodes without an error. Without FFmpeg there is no check at all. +A public vault can return the right KID with a wrong content key. The decrypters accept a wrong content key and write noise. unshackle therefore trusts a content key from a vault only after FFmpeg decodes the decrypted track with strict error detection. + +For a fragmented MP4, unshackle reads from the encrypted file which fragments each KID encrypts. FFmpeg then decodes up to three windows of each KID: from its first, middle and last fragment on through the next fragments of that KID, for up to 4 seconds. A window never runs into a fragment of another KID or a clear fragment. A clear lead or a lead under another KID therefore cannot hide a wrong content key, and only the KID that fails is flagged. + +When every KID in the map has a content key, the map is complete, and a KID that is not in it does not encrypt this file: the file of its own track judges it. A file with no encrypted sample entry and no encrypted fragment, for example a clear audio track, judges no KID, so it neither flags nor copies a content key. A KID that is not in an incomplete map, for example one with an all-zero KID, and every KID of any other file, gets one check of the whole file: FFmpeg decodes the first seconds and the last seconds, and a failure there flags each of those KIDs. When a mapped KID fails, the KIDs that are not in the map get no verdict from that pass; the retry with the replaced key judges them. + +Content keys from a licence skip this check, with two exceptions: a FairPlay-only track that the FairPlay bridge licensed, and a track of a DRM plugin that licenses locally. A plugin track gets the check of the whole file after the merge of its decrypted segments. An import also checks these content keys when it reads them from an export file. When one of these fails, unshackle flags the pair, stops the track and keeps no output file. + +A file this FFmpeg build cannot judge counts as a pass, never as a wrong content key: a codec it has no decoder for, or a header it cannot read. A plugin that decrypts each segment can fix the merged file before the check. A pass is not proof. A wrong content key for HEVC video can decode without an error for some seconds, most often at a low resolution, and that content key passes the check. Damage to a small part of the slice data, such as one corrupt NAL unit, also often decodes without an error. Without FFmpeg there is no check at all. When the decode fails, unshackle: -1. Flags the KID:KEY in the `bad_keys` table of every local SQLite vault, with the service and the name of the vault it came from. The pair also goes out of the service table, except in a vault marked `no_push`, where only the flag is written. A flagged pair cannot go back into a local vault from another vault, a later run, or `kv copy`. A licence that returns the pair clears the flag and stores it. An `API` vault that served the pair gets a report only when a different content key for that KID is accepted. When the CDM returns the same content key, that vault gets no report. `HTTP` and `MySQL` vaults have no report route. A pair from a local vault goes to no remote vault, even when a remote vault holds the same pair. +1. Flags the KID:KEY in the `bad_keys` table of every local SQLite vault, with the service and the name of the vault it came from. The pair also goes out of the service table, except in a vault marked `no_push`, where only the flag is written. A flagged pair cannot go back into a local vault from another vault, a later run, or `kv copy`. A licence that returns the pair clears the flag and stores it. An `API` vault that served the pair gets a report only when a different content key for that KID is accepted. When the CDM returns the same content key, that vault gets no report, and an `API` vault with `no_push` gets none. `HTTP` and `MySQL` vaults have no report route. A pair from a local vault goes to no remote vault, even when a remote vault holds the same pair. 2. Restores the ciphertext from a hard link it made before decryption, then asks for the content key again. Every vault lookup skips a flagged pair, so the request reaches the remaining vaults and then the CDM. A remote answer that arrived after the winning one is reused instead of queried again. 3. Removes the flag when the CDM returns the same content key, because then the decode check was wrong, not the content key. A content key from another vault is checked in its turn, and flagged as well if it also fails. -The download stops with an error instead of writing noise when no ciphertext is left to retry with, or when every vault and the CDM are used up. Without a local SQLite vault nothing remembers a flag, so the same vault serves the same pair again and the download stops there. +The download stops with an error instead of writing noise when no ciphertext is left to retry with, or when every vault and the CDM are used up. Without a local SQLite vault nothing remembers a flag, so the same vault serves the same pair again and the download stops there. A `serve` instance with `server_cdm` flags a pair the same way when a remote client reports it, so a server needs a SQLite vault in its `key_vaults` to remember a bad content key. Per-segment decryption gives up the retry. With `decrypt_segments` on, and always with a plugin that decrypts each segment, the plaintext replaces each segment as it arrives, so no ciphertext is left. A failed decode then flags the pair and stops the download. The next run skips the flagged pair. @@ -55,7 +62,7 @@ unshackle copies a content key from one vault to the others only after this chec ## Configuring vaults -Declare vaults under the `key_vaults` list in your unshackle config file. Each entry is a mapping with two required fields, `type` (which backend to use) and `name` (a label you choose), plus whatever settings that backend needs. +Declare vaults under the `key_vaults` list in your unshackle config file. Each entry needs a `type` (which backend to use) and a `name` (a label you choose), plus the settings of that backend. The fields of each backend, their defaults and `vault_timeout` are in the [key vault reference](../reference/configuration/vaults.md). ```yaml title="unshackle.yaml" key_vaults: @@ -70,28 +77,13 @@ key_vaults: password: "s3cret" ``` -The `type` value is matched to a vault backend by name. The four backends that ship with unshackle are `SQLite`, `MySQL`, `HTTP`, and `API`, described below. - -!!! warning "SQLite vaults are loaded critically" - During a download, a **SQLite** vault that fails to load will **abort the run**. The assumption is that a local database you configured should always be available. `MySQL`, `HTTP`, and `API` vaults are loaded leniently: if one fails to load it is logged and skipped, and the download continues with the remaining vaults. - -### `vault_timeout` - -Network-backed vaults (`HTTP` and `API`) accept an optional per-vault `timeout` in seconds. If you omit it, unshackle injects the global default: - -```yaml title="unshackle.yaml" -vault_timeout: 10.0 # default, in seconds -``` - -A `timeout` set inline on an individual vault always wins over this global value. The `SQLite` and `MySQL` backends do not take a `timeout` field. `MySQL` uses `vault_timeout` as its `connect_timeout`, `read_timeout` and `write_timeout` instead, and falls back to 10 seconds when `vault_timeout` is `0`. To use a different value, set that field on the vault. - -unshackle pushes content keys to all vaults at the same time, so one slow or unreachable vault costs only its own timeout and does not delay the others. +The four backends that ship with unshackle are `SQLite`, `MySQL`, `HTTP`, and `API`. Write the `type` with this exact casing. The [backend table](../reference/configuration/vaults.md#key_vaults) also gives what a vault that fails to load does to a download. --- ## SQLite backend -A locally-accessed SQLite database file. This is the simplest and fastest option and needs no server. +A local SQLite database file. This is the simplest and fastest option and needs no server. See the [`SQLite` fields](../reference/configuration/vaults.md#sqlite). ```yaml title="unshackle.yaml" key_vaults: @@ -100,17 +92,6 @@ key_vaults: path: ~/.local/share/unshackle/vaults/local.db ``` -| Field | Required | Description | -|-------|----------|-------------| -| `type` | yes | Must be `SQLite`. | -| `name` | yes | A label for this vault. | -| `path` | yes | Path to the database file. `~` is expanded. The file (and its tables) are created automatically on first use. | -| `no_push` | no | If `true`, keys are read but never written. Defaults to `false`. | - -Each service gets its own table (named after the service tag), created on demand with `kid` and `key_` columns. Connections use WAL journaling with a 30-second busy timeout, so multiple threads can safely use the same database file. - -One more table, `bad_keys`, is created on demand and holds every KID:KEY that failed the decode check described in [Wrong keys from a poisoned vault](#wrong-keys-from-a-poisoned-vault), with the service, the vault it came from, and the time it was flagged. It is not a service table, and every command that walks the service tables skips it. - !!! warning "Moving the .db file silently forks your vault" Because the file is created on demand, if you relocate an existing `.db` without updating `path` to match, unshackle will create a fresh empty database at the old location. That leaves you with two divergent vaults and no error to warn you. Always update the config path whenever you move the file. @@ -121,7 +102,7 @@ One more table, `bad_keys`, is created on demand and holds every KID:KEY that fa ## MySQL backend -A remotely-accessed MySQL/MariaDB database, ideal for sharing keys across several machines. It connects via `pymysql`. Prefer MariaDB over MySQL where you have the choice. +A MySQL or MariaDB database on a server, to share keys across several machines. It connects through `pymysql`. Prefer MariaDB over MySQL where you have the choice. See the [`MySQL` fields](../reference/configuration/vaults.md#mysql). !!! warning "The vault connects directly to the database server" A `MySQL` vault (like `SQLite`) speaks the database wire protocol directly to the host or IP you configure. It cannot sit behind a PHP API or any other application layer. A common real-world snag: many hosting providers firewall their MySQL server to their own internal network. A database on shared hosting is therefore frequently unreachable from the outside world even when your credentials are perfectly correct. If connections time out, confirm the server accepts remote connections from your address before suspecting the config. @@ -137,36 +118,14 @@ key_vaults: port: 3306 ``` -| Field | Required | Description | -|-------|----------|-------------| -| `type` | yes | Must be `MySQL`. | -| `name` | yes | A label for this vault. | -| `host` | yes | Database server hostname or IP. | -| `database` | yes | Database (schema) name. | -| `username` | yes | Login user. | -| `no_push` | no | If `true`, keys are read but never written. | - -Any additional fields you provide (such as `password`, `port`, or `ssl`) are passed straight through to `pymysql.connect`, so you can use the full range of its connection options. The one exception is `autocommit`, which is always on. - -Each `MySQL` vault keeps one connection open for the whole run and shares it between threads. If the server is down, unshackle skips the vault for the rest of the run. - !!! warning "Account security is on you, not on unshackle" unshackle enforces none of this. It is operational policy for a database that may be shared with a group. Never connect with the `root` account, not even for yourself. Give every account a password, and never let two users share a username/password. Restrict each account's access to only the `unshackle` database, and grant normal users only `SELECT` and `INSERT`. Reserve the `CREATE` grant for a single trusted user who bootstraps the service tables (see [`kv prepare`](#kv-prepare-pre-create-service-tables)); everyone else can insert new keys but should not be creating tables. -!!! note "Grants determine what the vault can do" - On connection the backend reads its own `SHOW GRANTS`. It requires at least `SELECT` to load at all (a missing `SELECT` grant makes the vault fail to load). Writing keys additionally needs `INSERT`, and creating a new service table needs `CREATE`. A read-only account still works fine as a lookup source. It cannot push new keys. Because `MySQL` is loaded leniently during downloads, a permission problem will not abort the run. - --- ## HTTP backend -A flexible HTTP vault that speaks one of three wire protocols, selected with `api_mode`. Use this to integrate with a community or self-hosted vault service. - -| `api_mode` | Transport | Authentication | Notes | -|------------|-----------|----------------|-------| -| `query` (default) | `GET` with query parameters | `username` + `password` | Full read and write. | -| `json` | `POST` with a JSON payload | `password` used as a token | Read and write per content key; cannot bulk-enumerate keys. | -| `decrypt_labs` | `POST` in DecryptLabs format | `api_key` sent as a header | **Read-only**. `no_push` is forced on. | +An HTTP vault that speaks one of three protocols, selected with `api_mode`. Use this to connect a community or self-hosted vault service. The fields and the three protocols are in the [`HTTP` reference](../reference/configuration/vaults.md#http). === "query mode" @@ -180,8 +139,6 @@ A flexible HTTP vault that speaks one of three wire protocols, selected with `ap password: "your-password" ``` - Query mode requires `username`. Both the username and password are sent as query parameters on each request. - === "json mode" ```yaml title="unshackle.yaml" @@ -193,8 +150,6 @@ A flexible HTTP vault that speaks one of three wire protocols, selected with `ap password: "your-api-token" ``` - Requests are `POST`ed as `{"method": ..., "params": ..., "token": ...}` using methods like `GetKey`, `InsertKey`, and `GetServices`. Bulk writes (`kv copy`, `kv add`) first try `InsertKeys` with `params: {"keys": {kid: key, ...}, "service": ..., "title": ...}` (up to 500 content keys per call) and expect `{"inserted": }` back. A server that answers HTTP 404 or `Unknown JSON-RPC method` to `InsertKeys` gets one `InsertKey` call per content key for the rest of the run instead. This mode cannot list all keys in bulk, so a `kv copy` from a json vault relies on the remote server's own duplicate handling. - === "decrypt_labs mode" ```yaml title="unshackle.yaml" @@ -206,29 +161,11 @@ A flexible HTTP vault that speaks one of three wire protocols, selected with `ap api_key: "your-decrypt-labs-key" ``` - A read-only lookup source. The API key is sent in a `decrypt-labs-api-key` header and the vault refuses all writes. - -| Field | Required | Description | -|-------|----------|-------------| -| `type` | yes | Must be `HTTP`. | -| `name` | yes | A label for this vault. | -| `host` | yes | Base URL of the vault API. | -| `api_mode` | no | `query` (default), `json`, or `decrypt_labs`. | -| `username` | for `query` | Required in query mode; ignored otherwise. | -| `password` | one of these | Password (query mode) or token (json mode). | -| `api_key` | one of these | Alternative to `password`; used for `decrypt_labs`. If you give both, `api_key` wins. | -| `no_push` | no | Read-only when `true` (always `true` for `decrypt_labs`). | -| `timeout` | no | Request timeout in seconds; defaults to `vault_timeout`. | - -You must supply either `password` or `api_key`, or the vault will fail to load. - -A host that answers with a body that is not a JSON object, for example a parked domain or a login page, is unreachable. unshackle logs one warning, skips the vault for the rest of the run, and the `serve` health check reports the vault as failed. In json mode, HTTP 404 to a lookup is the exception: it means that the vault has no entry. In decrypt_labs mode, an error status other than 429 is a miss. - --- ## API backend -A simple RESTful HTTP vault with a fixed, well-defined protocol. Authentication is a bearer token. +An HTTP vault with unshackle's own protocol and a bearer token. An API of another vault project does not work with it. See the [`API` reference](../reference/configuration/vaults.md#api). ```yaml title="unshackle.yaml" key_vaults: @@ -241,24 +178,6 @@ key_vaults: CF-Access-Client-Secret: "CLIENT_SECRET_HERE" ``` -| Field | Required | Description | -|-------|----------|-------------| -| `type` | yes | Must be `API`. | -| `name` | yes | A label for this vault. | -| `uri` | yes | Base URI of the vault API (a trailing slash is trimmed). | -| `token` | yes | Bearer token, sent as `Authorization: Bearer `. | -| `no_push` | no | If `true`, keys are read but never written. | -| `timeout` | no | Request timeout in seconds; defaults to `vault_timeout`. | -| `headers` | no | Extra HTTP `headers` sent with every request, for example the Cloudflare Access service-token headers `CF-Access-Client-Id` and `CF-Access-Client-Secret`. | - -The backend talks to endpoints under `uri` (for example `GET {uri}/{service}/{kid}` to look up a single key). It interprets a numeric `code` field in each JSON response to detect errors such as an invalid token, rate limiting, or an invalid service tag. - -!!! warning "This is unshackle's own protocol, not a generic vault client" - The `API` backend expects unshackle's specific HTTP request and response shape. An API or HTTP key-vault endpoint built for a different project or service will generally *not* be compatible. You cannot point this at an arbitrary third-party vault API and expect it to work. To bridge another service, put an adapter in front of it that speaks this format, or use the `HTTP` backend if one of its wire protocols matches. When pushing many keys at once it batches requests and automatically shrinks the batch size if the server rejects an over-large request. After a push that succeeds at a smaller size, later pushes to that vault start at that size. - -!!! tip "DecryptLabs shortcut" - An `API` vault whose `name` contains `decrypt_labs` will have its `token` filled in automatically from a global `decrypt_labs_api_key` in your config if you leave `token` unset. This lets you keep the API key in one place. - --- ## Managing vaults with `unshackle kv` diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md deleted file mode 100644 index 14113d03..00000000 --- a/docs/reference/configuration.md +++ /dev/null @@ -1,19 +0,0 @@ -# Configuration Reference (moved) - -This page has moved. The configuration reference is now split by area under -[`docs/reference/configuration/`](configuration/index.md), or on the docs site at -[docs.unshackle.dev/reference/configuration](https://docs.unshackle.dev/reference/configuration/). - -| Area | Page | -|------|------| -| Overview & quick index | [configuration/index.md](configuration/index.md) | -| Directories & filenames | [configuration/directories.md](configuration/directories.md) | -| Services & authentication | [configuration/services.md](configuration/services.md) | -| Download & processing | [configuration/download.md](configuration/download.md) | -| Output & naming | [configuration/output.md](configuration/output.md) | -| DRM & CDM | [configuration/drm.md](configuration/drm.md) | -| Network & proxy | [configuration/network.md](configuration/network.md) | -| Key vaults | [configuration/vaults.md](configuration/vaults.md) | -| Post-scripts | [configuration/post-scripts.md](configuration/post-scripts.md) | -| Other settings | [configuration/misc.md](configuration/misc.md) | -| Complete annotated example | [configuration/example.md](configuration/example.md) | diff --git a/docs/reference/configuration/download.md b/docs/reference/configuration/download.md index c44618b7..0e448ebb 100644 --- a/docs/reference/configuration/download.md +++ b/docs/reference/configuration/download.md @@ -18,11 +18,13 @@ config keys: | `-r` / `--range` | `range` | | `--list` | `list` | | `--tmdb` | `tmdb_id` | +| `--tvdb` | `tvdb_id` | | `--imdb` | `imdb_id` | | `--anilist` | `anilist_id` | | `-naa` / `--noatmos` | `no_atmos` | | `-o` / `--output` | `output_dir` | -| `--cdm-only` / `--vaults-only` | `cdm_only` | +| `--cdm-only` / `--vaults-only` | `cdm_only` (`true` for `--cdm-only`, `false` for `--vaults-only`) | +| `--cdm` | `cdm_name` | **Precedence** (highest first): an explicit CLI flag → a per-service [`services..dl`](services.md) override → this global `dl:` block → the built-in @@ -273,13 +275,13 @@ in or writes them as sidecar files. See [Subtitles](../../guide/subtitles.md) fo | Sub-key | Type | Default | Description | |---------|------|---------|-------------| | `strip_sdh` | bool | `true` | Strip SDH/CC cues (hearing-impaired annotations) into a clean track. | -| `sdh_method` | str | `"auto"` | SDH-stripping backend to use. | +| `sdh_method` | str | `"auto"` | The engine that strips SDH cues: `auto`, `subby`, `subtitleedit` or `filter-subs`. See [SDH engines](#sdh-engines). | | `preserve_formatting` | bool | `true` | Pass WebVTT cue text through as written. `false` re-encodes it through pycaption, which merges identical cues but flattens styling. unshackle removes WebVTT-only cue markup either way. | -| `convert_before_strip` | bool | `true` | Convert to the working format before stripping SDH. | -| `conversion_method` | str | `"auto"` | Subtitle conversion backend. | +| `convert_before_strip` | bool | `true` | Convert a subtitle that is not SRT to SRT before `filter-subs` strips SDH cues, also when `filter-subs` runs as the fallback of another engine. With `false`, `filter-subs` leaves a subtitle that is not SRT as it is. | +| `conversion_method` | str | `"auto"` | The first conversion backend to try: `auto`, `subtitleedit`, `subby`, `pysubs2` or `pycaption`. `auto` ranks the backends for each conversion. A named backend goes first, and unshackle uses the others only when it cannot convert the pair. See [Conversion backends](#conversion-backends). | | `output_mode` | str | `"mux"` | `mux` embeds subtitles in the MKV; `sidecar` writes separate files; `both` writes sidecars and still muxes. | | `sidecar_format` | str | `"srt"` | Format for sidecar files when `output_mode` is `sidecar` or `both`. | -| `type_priority` | list | *(unset)* | Ordered ranking of subtitle types (`forced`, `normal`, `sdh`; CC counts as SDH). Types you leave out fall to the end. | +| `type_priority` | list | *(unset)* | Ordered ranking of subtitle types (`forced`, `normal`, `sdh`; CC counts as SDH). Types you leave out fall to the end. Unset keeps the order forced, normal, SDH. | | `group_by` | str | `"type"` | Which key groups the subtitle tracks. `type` puts all forced tracks together, then all normal, then all SDH. `language` keeps each language next to its own variants. | | `language_priority` | list | *(unset)* | Languages to sort to the top, in the order you give. The rest keep the default order: original language first, then alphabetical. Nothing is removed. | | `ass_style` | dict | *(unset)* | Style for subtitles converted to ASS, as pysubs2 or ASS style fields (`fontname`, `fontsize`, `primarycolor` or `PrimaryColour`, ...) for a 1080-line picture. Makes ASS the output format when `sub_format` is unset. See [Custom font and style](../../guide/subtitles.md#custom-font-and-style). | @@ -292,6 +294,32 @@ subtitle: sidecar_format: srt ``` +### SDH engines { #sdh-engines } + +Every engine removes bracketed sound effects (`[MUSIC PLAYING]`, `(door creaks)`), speaker +labels (`MAN:`) and font tags, and keeps plain dialogue and inline `` styling. They differ +on music and lyric lines. unshackle compares the value case-sensitively, and an unknown value +gives `filter-subs`. + +| `sdh_method` | Engine that runs | Lyric lines (`♪ ... ♪`) | +| --- | --- | --- | +| `auto` | `subby` for an SRT track. For any other format, SubtitleEdit when you install it and `conversion_method` is `auto` or `subtitleedit`, otherwise `filter-subs`. | Kept, unless the fallback reaches `filter-subs`. | +| `subby` | `subby`, but only for a track that is already SRT. Any other format falls through to `filter-subs`. | Kept for SRT, removed otherwise. | +| `subtitleedit` | SubtitleEdit when you install it, otherwise `filter-subs`. | Kept with SubtitleEdit, removed without it. | +| `filter-subs` | `filter-subs` always. | Removed. | + +### Conversion backends { #conversion-backends } + +| `conversion_method` | Best at | Requires | +| --- | --- | --- | +| `subtitleedit` | Highest fidelity; keeps positioning and italics | SubtitleEdit installed | +| `subby` | SRT output with clean-up | - | +| `pysubs2` | Best fidelity for styled SSA/ASS | - (pure Python, always available) | +| `pycaption` | Last-resort fallback; flattens styling | - | + +What each backend keeps of the styling is in +[What each backend preserves](../../guide/subtitles.md#what-each-backend-preserves). + !!! note "`group_by` track order" | `group_by` | Result | |---|---| @@ -379,7 +407,7 @@ Matroska (MKV) muxing options. | Sub-key | Type | Default | Description | |---------|------|---------|-------------| | `set_title` | bool | `true` | Write a human-readable title into the MKV container. | -| `default_language` | dict | `{}` | Force which language is flagged *default* per track type, e.g. `{audio: en, subtitle: en}`. A tag with a region, such as `en-US`, matches only that variant. | +| `default_language` | dict | `{}` | Force which language is flagged *default* per track type (`video`, `audio`, `subtitle`), e.g. `{audio: en, subtitle: en}`. A tag with a region, such as `en-US`, matches only that variant. | | `default_subtitle_type` | str or list | unset | The subtitle types that can take the *default* flag, in order: `forced`, `normal`, `sdh` (CC counts as SDH, and `cc` is the same as `sdh`). The first subtitle track of the first type that the title has gets the flag. With `default_language.subtitle`, only the tracks in that language count. unshackle ignores a different word with a warning. `normal` is the value for players that read the forced flag. Read [Muxing](../../guide/output-and-naming.md#muxing-options). | | `merge_audio` | bool | `true` | Merge all audio into one file. `--split-audio` on the CLI flips this off. | | `merge_video` | bool | `false` | Merge video tracks that share height, range, and codec into one file, so only language varies inside a file. `--merge-video` on the CLI flips this on. | @@ -403,7 +431,8 @@ muxing: Language-tag remapping and the rule engine behind the `{lang_tag}` filename variable. When a `rules` list is present, unshackle evaluates each rule in order and uses the first match's -`tag`. A rule can examine: +`tag`. Every condition of a rule must match. When no rule matches, `{lang_tag}` is empty. A +rule can examine: | Condition | Meaning | |-----------|---------| diff --git a/docs/reference/configuration/index.md b/docs/reference/configuration/index.md index f2d631fa..f2b4a517 100644 --- a/docs/reference/configuration/index.md +++ b/docs/reference/configuration/index.md @@ -33,7 +33,7 @@ Where the file lives, how unshackle discovers it, and how to edit it: | [Services & authentication](services.md) | `services`, `credentials`, `firefox_cookies`, `remote_services`, `serve` | | [Download & processing](download.md) | `dl`, `continue_downloads`, `merge_segments`, `subtitle`, `audio`, `muxing`, `language_tags`, `dual_multi_mode`, `generate_dv_mode`, `hdr10plus_probe` | | [Output & naming](output.md) | `output_template`, `tag`, `tag_rules`, `codec_names`, `tag_group_name`, `tag_imdb_tmdb`, `chapter_fallback_name`, `unicode_filenames`, `filename_replacements` | -| [DRM & CDM](drm.md) | `cdm`, `remote_cdm`, `decryption` | +| [DRM & CDM](drm.md) | `cdm`, `remote_cdm`, `decryption`, `decrypt_segments` | | [Network & proxy](network.md) | `network`, `headers`, `proxy_providers` | | [Key vaults](vaults.md) | `key_vaults`, `vault_timeout` | | [Post-scripts](post-scripts.md) | `post_scripts` | @@ -41,4 +41,4 @@ Where the file lives, how unshackle discovers it, and how to edit it: | [Caching & updates](misc.md#caching-updates) | `title_cache_enabled`, `title_cache_time`, `title_cache_max_retention`, `update_checks`, `update_check_interval` | | [Appearance](misc.md#appearance) | `theme`, `wide_output` | | [Logging, privacy & debug](misc.md#logging-privacy-debug) | `redact_paths`, `debug`, `debug_keys`, `debug_requests`, `debug_requests_body_limit`, `set_terminal_bg` | -| [Deprecated & removed](misc.md#deprecated-removed-keys) | `curl_impersonate`, `downloader`, `scene_naming` | +| [Deprecated & removed](misc.md#deprecated-removed-keys) | `curl_impersonate`, `downloader`, `scene_naming`, `imdb_api_enabled` | diff --git a/docs/reference/configuration/network.md b/docs/reference/configuration/network.md index 34d13721..307fb2ba 100644 --- a/docs/reference/configuration/network.md +++ b/docs/reference/configuration/network.md @@ -60,23 +60,24 @@ headers: - **Type:** `dict`  ·  **Default:** `{}` -Proxy/VPN provider configuration. Each sub-key names a proxy provider, and unshackle passes its -block straight to that provider's constructor. A bare `--proxy` query tries Basic first, then -the other proxy providers in the order of their sub-keys, and Control D last (see -[Provider load order](../../guide/proxies-and-vpn.md#provider-load-order)). See -[Proxies & VPN](../../guide/proxies-and-vpn.md) for the full proxy provider guide. Recognised proxy -providers and their exit ports: +Proxy provider configuration. Each sub-key names a proxy provider, and unshackle passes its +block to the constructor of that proxy provider, so each config key below is a constructor +argument. Except for `basic` and `gluetun`, a config key that the proxy provider does not know +stops it from loading. The order of the sub-keys sets the order of a bare `--proxy` query (see +[Provider load order](../../guide/proxies-and-vpn.md#provider-load-order)). How to set up each +proxy provider and the queries it accepts are in [Proxies & VPN](../../guide/proxies-and-vpn.md). +Recognised proxy providers and their exit ports: | Provider | Config key | Credentials | Proxy scheme/port | |----------|-----------|-------------|-------------------| -| Basic (static) | `basic` | country → URI(s) | as specified | -| Control D | `controld` | Write API token (profile/resolver pairs optional) | `http://127.0.0.1:{port}` (local forwarder) | -| NordVPN | `nordvpn` | **service** credentials (48 chars combined) | `https://...:89` | -| Surfshark | `surfsharkvpn` | **service** credentials (48 chars combined) | `https://...:443` | -| Windscribe | `windscribevpn` | service credentials | `https://...:443` | -| ExpressVPN | `expressvpn` | device login (`enable: true`) / token cache | `https://cat:...@...:443` | -| ProtonVPN | `protonvpn` | TV login or exported cookies | `https://...:4443` (or `:443` Secure Core) | -| Gluetun | `gluetun` | per-VPN keys/creds | `http://localhost:{port}` (local Docker) | +| Basic (static) | [`basic`](#basic) | country → URI(s) | as specified | +| Control D | [`controld`](#controld) | Write API token (profile/resolver pairs optional) | `http://127.0.0.1:{port}` (local forwarder) | +| NordVPN | [`nordvpn`](#nordvpn) | **service** credentials (48 chars combined) | `https://...:89` | +| Surfshark | [`surfsharkvpn`](#surfsharkvpn) | **service** credentials (48 chars combined) | `https://...:443` | +| Windscribe | [`windscribevpn`](#windscribevpn) | service credentials | `https://...:443` | +| ExpressVPN | [`expressvpn`](#expressvpn) | device login (`enable: true`) / token cache | `https://cat:...@...:443` | +| ProtonVPN | [`protonvpn`](#protonvpn) | TV login or exported cookies | `https://...:4443` (or `:443` Secure Core) | +| Gluetun | [`gluetun`](#gluetun) | per-VPN keys/creds | `http://localhost:{port}` (local Docker) | | Hola | *(none, auto)* | none | `http://...:{peer}` | ```yaml @@ -91,7 +92,23 @@ proxy_providers: password: ``` -### `controld` +### `basic` { #basic } + +Each config key is a two-letter country code, and its value is one proxy URI or a list of +proxy URIs. unshackle adds `http://` to a URI with no scheme. A URI with no host fails when a +query picks it, before the download starts. See [Basic](../../guide/proxies-and-vpn.md#basic-static-proxies) +for the queries. + +```yaml +proxy_providers: + basic: + us: http://user:pass@1.2.3.4:8080 + de: + - http://a.example:8080 + - socks5://b.example:1080 +``` + +### `controld` { #controld } Config keys of the Control D proxy provider. See [Control D](../../guide/proxies-and-vpn.md#control-d) for how unshackle uses them. @@ -104,8 +121,128 @@ Config keys of the Control D proxy provider. See | `profiles` | `list` | `[]` | Optional. More pairs, each a mapping with `profile` and `resolver`. | | `max_profiles` | `int` | `4` | The most profiles unshackle uses: your pairs plus the `unshackle-*` endpoints on the account. It must be 1 or more. unshackle creates an `unshackle-` profile and endpoint only while the total is lower. | +### `expressvpn` { #expressvpn } + +| Key | Type | Default | Meaning | +|---|---|---|---| +| `enable` | `bool` | `false` | Do the one-time interactive device login when no login session exists. | +| `region_map` | `dict` | `{}` | A country code to a city or server preset (`us: ny-02`), used when the query names only the country. An empty value gives a smart random location. | +| `server_map` | `dict` | `{}` | An alias to a location slug (`usny-newyork-2`) or a `.expressprovider.com` hostname. | +| `cache_path` | `str` | `{cache}/vpn/expressvpn_tokens.json` | The token cache. unshackle writes it with `0600` permissions. | +| `refresh_token`, `access_token`, `connection_token` | `str` | none | Tokens to use in place of the token cache. | +| `account_json` | `str` | none | A JSON file to read the tokens from when there is no token cache. | +| `timeout` | `float` | `10.0` | The request timeout in seconds. | + +`{cache}` is [`directories.cache`](directories.md). ExpressVPN also loads with no config block +when its token cache exists. + +### `gluetun` { #gluetun } + +```yaml +proxy_providers: + gluetun: + providers: + windscribe: + vpn_type: wireguard + credentials: + private_key: YOUR_WIREGUARD_PRIVATE_KEY + addresses: YOUR_WIREGUARD_ADDRESS + preshared_key: YOUR_PRESHARED_KEY + server_countries: + us: US + uk: GB + server_cities: {} + server_hostnames: {} + extra_env: {} + base_port: 8888 + auto_cleanup: true + container_prefix: unshackle-gluetun + auth_user: null + auth_password: null + verify_ip: true +``` + +Global keys: + +| Key | Type | Default | Meaning | +|---|---|---|---| +| `providers` | `dict` | `{}` | One entry for each VPN provider, keyed by its name in the query (`gluetun::`). | +| `base_port` | `int` | `8888` | The first local port for a proxy. Other containers take the next free ports. | +| `auto_cleanup` | `bool` | `true` | Remove the containers on exit. With `false`, unshackle only stops them. | +| `container_prefix` | `str` | `unshackle-gluetun` | The prefix of the Docker container names. | +| `auth_user`, `auth_password` | `str` | `null` | HTTP proxy credentials. When set, the local proxy asks for them, and the proxy URI holds them. | +| `verify_ip` | `bool` | `true` | After the connection, check the exit IP and its country. | + +Keys of each entry under `providers`: + +| Key | Type | Default | Meaning | +|---|---|---|---| +| `vpn_type` | `str` | `wireguard` | `wireguard` or `openvpn`. | +| `credentials` | `dict` | `{}` | The secrets of the tunnel; see the rules below. | +| `server_countries` | `dict` | `{}` | Your region alias (`us`) to Gluetun's country value (`US`). | +| `server_cities` | `dict` | `{}` | An alias to a Gluetun city. | +| `server_hostnames` | `dict` | `{}` | An alias to one server hostname. | +| `extra_env` | `dict` | `{}` | Environment variables that go into the container last, for a Gluetun setting that the keys above do not cover. | + +Credentials that each `vpn_type` needs (unshackle checks them when it loads): + +- **`wireguard`:** `private_key` always. `surfshark`, `mullvad` and `ivpn` also need + `addresses`. `windscribe` needs `addresses` and `preshared_key`; `preshared_key` can be an + empty string, but the config key must be there. NordVPN and Proton VPN need only `private_key`. +- **`openvpn`:** `username` and `password`. + +### `nordvpn` { #nordvpn } + +| Key | Type | Default | Meaning | +|---|---|---|---| +| `username` | `str` | required | The NordVPN *Service Credentials* username. | +| `password` | `str` | required | The *Service Credentials* password. | +| `server_map` | `dict` | `{}` | A region (`us`) or `code:city` (`us:seattle`) to a NordVPN server ID, or to an `@` selector (see [Choose a server network](../../guide/proxies-and-vpn.md#choose-a-server-network)). | + +The username and the password together must be 48 letters and digits, and the username must not +contain `@`. Login credentials fail this check. + +### `protonvpn` { #protonvpn } + +| Key | Type | Default | Meaning | +|---|---|---|---| +| `enable` | `bool` | `false` | Do the one-time interactive TV login when no login session exists. | +| `server_map` | `dict` | `{}` | An alias to a server query. | +| `cookie_path` | `str` | `{cookies}/vpn/protonvpn.txt` | The exported `account.proton.me` cookies. | +| `cache_path` | `str` | `{cache}/vpn/protonvpn.json` | The TV login cache. unshackle writes it with `0600` permissions. | +| `timeout` | `float` | `10.0` | The request timeout in seconds. | + +`{cookies}` and `{cache}` are [`directories.cookies`](directories.md) and +`directories.cache`. unshackle also finds the cookie file as `proton.txt`, and in a `vpns` +folder. Proton VPN also loads with no config block when the cookie file exists. A TV login cache +alone does not load it, so keep the `protonvpn` block for a TV login. + +### `surfsharkvpn` { #surfsharkvpn } + +| Key | Type | Default | Meaning | +|---|---|---|---| +| `username` | `str` | required | The Surfshark *Service Credentials* username. | +| `password` | `str` | required | The *Service Credentials* password. | +| `server_map` | `dict` | `{}` | A region (`us`) or `code:city` (`us:seattle`) to a Surfshark server name (`us-dal`, or the full hostname `us-dal.prod.surfshark.com`), or to an `@` selector. unshackle ignores a numeric or empty value with a warning. A city query uses only its `code:city` entry, never the country entry. | + +The username and the password must pass the same 48-character check as `nordvpn`. + +### `windscribevpn` { #windscribevpn } + +| Key | Type | Default | Meaning | +|---|---|---|---| +| `username` | `str` | required | The username of the Windscribe proxy *Service Credentials*. | +| `password` | `str` | required | The password of the proxy *Service Credentials*. | +| `server_map` | `dict` | `{}` | A region (`us`) or `region:city` (`us:seattle`) to a hostname, or to an `@` selector. | + +There is no 48-character check. + +### Hola { #hola } + +Hola has no config key. It loads when unshackle finds the `hola-proxy` binary, in its binaries folders or on your `PATH`. + !!! note "Provider loading differs between CLI and REST server" The `dl` and `search` commands load all providers, including `gluetun`. A server (REST API requests, download jobs and remote sessions) and the remote client do **not** load `gluetun`, - because it starts a local Docker container. ExpressVPN and ProtonVPN also auto-load when their cached session exists, and Hola - auto-loads whenever the `hola-proxy` binary is present. + because it starts a local Docker container. ExpressVPN, Proton VPN and Hola can also load with no config block + (see [`expressvpn`](#expressvpn), [`protonvpn`](#protonvpn) and [Hola](#hola)). diff --git a/docs/reference/configuration/output.md b/docs/reference/configuration/output.md index 1f21dfae..65973a37 100644 --- a/docs/reference/configuration/output.md +++ b/docs/reference/configuration/output.md @@ -1,18 +1,26 @@ # Output & naming { #output-naming } Keys that control the output filename, the per-title subfolder, release-group tagging, and -filename character handling. For template cookbook material and worked naming examples, see +filename character handling. For how unshackle builds a path, and for worked naming examples, see the [Output & naming guide](../../guide/output-and-naming.md). ## `output_template` - **Type:** `dict`  ·  **Required** (no usable default; `dl` exits with an error if this is missing) -Filename templates keyed by media kind, using `{variable}` placeholders. Recognised kinds are -`movies`, `series`, `sports`, and `songs` (and `albums` for folder templates). A trailing `?` on a -variable (e.g. `{quality?}`) marks it optional: if empty, it and one adjacent separator are +Filename templates keyed by media kind, using `{variable}` placeholders. `dl` stops with +`No 'output_template' in your unshackle.yaml` when the config key is missing or empty. A trailing `?` on +a variable (e.g. `{quality?}`) marks it optional: if empty, it and one adjacent separator are dropped. +| Kind | Applies to | When unset | +|---|---|---| +| `movies` | Movies | The title name and year, with spaces: `The Movie (2024)`. | +| `series` | TV episodes | The show, year, episode number and name, with spaces: `The Show 2024 S01E05 Pilot`. | +| `sports` | Episodes that the service marks as a sports event | The `series` template. | +| `songs` | Songs | `"{track_number}. {title}"` | +| `albums` | Album folders, in `folder` only | The `songs` folder template, then a single-string `folder`, then `"{artist} - {album} ({year})"`, or `"{artist} - {album}"` with no year. | + ```yaml title="unshackle.yaml" output_template: movies: "{title}.{year}.{quality?}.{source}-{tag}" @@ -35,13 +43,92 @@ unshackle validates templates on load and emits warnings for unknown variables, values, filesystem-unsafe characters (`< > : " / \ | ? *`), empty templates, and unknown folder-kind keys. -??? example "All valid template variables" - `title`, `year`, `season`, `episode`, `season_episode`, `episode_name`, `part`, - `absolute`, `date`, `quality`, `resolution`, `source`, `tag`, `track_number`, `artist`, - `album_artist`, `album`, `disc`, `track_total`, `disc_total`, `release_type`, `genre`, - `explicit`, `isrc`, `upc`, `label`, `audio`, `audio_channels`, `audio_full`, `atmos`, - `dual`, `multi`, `dubbed`, `video`, `hdr`, `hfr`, `3d`, `edition`, `repack`, `lang_tag`, - `title_type`. +### Template variables { #template-variables } + +unshackle takes the values from the downloaded media (through MediaInfo), from the title +metadata, or from your config. A variable that does not apply to a title becomes an empty +string. The common and audio variables work in every template. The episode variables belong to +the `series` and `sports` templates, and the music variables to the `songs` and `albums` +templates. unshackle warns at startup about such a variable in another template, also in a +single-string `folder` template, which still fills it in for the titles that have it. + +**Common and video** + +| Variable | Meaning | Example | +|---|---|---| +| `title` | Title name (movie/show/song name; `$` is rendered as `S`) | `The Show` | +| `title_type` | Media kind of the title | `movie`, `series`, `music` | +| `year` | Release year | `2024` | +| `source` | Service tag / class name (empty with `--no-source`) | `EXAMPLE` | +| `quality` | Standard resolution with scan suffix | `1080p`, `2160p`, `576i` | +| `resolution` | Standard resolution number only | `1080` | +| `video` | Video codec; rename it with [`codec_names`](#codec_names) | `H.264`, `H.265` | +| `hdr` | Dynamic-range label | `HDR`, `HDR10P`, `DV`, `DV.HDR`, `DV.HDR10P`, `DV.HDRVivid`, `HDRVivid`, `HLG` | +| `hfr` | High frame rate marker (frame rate > 30) | `HFR` | +| `3d` | Stereoscopic 3D marker (MV-HEVC video) | `3D` | +| `edition` | Edition label from the track, if any | `Directors Cut` | +| `tag` | Release-group tag (from [`tag`](#tagging-naming-keys), [`tag_rules`](#tag_rules) or `--tag`) | `TAG` | +| `repack` | `REPACK` when the `--repack` flag is used | `REPACK` | +| `lang_tag` | Result of your [`language_tags`](download.md#language_tags) rules, if configured | `MULTi` | + +**Audio** + +| Variable | Meaning | Example | +|---|---|---| +| `audio` | Audio codec; rename it with [`codec_names`](#codec_names) | `DDP`, `DD`, `AAC`, `DTS-X` | +| `audio_channels` | Channel layout; bed.LFE.heights when the track has height channels | `5.1`, `2.0`, `5.1.4` | +| `audio_full` | Codec + channels combined; a name that ends in a digit gets a separator | `DDP5.1`, `DTS-X.5.1.4`, `AC4.2.0` | +| `atmos` | `Atmos` when an audio track in the file carries JOC or is marked Atmos, as in the `--list` row (MediaInfo shows no JOC for AC-4) | `Atmos` | +| `dual` | `DUAL` for two audio languages (see [`dual_multi_mode`](download.md#dual_multi_mode)) | `DUAL` | +| `multi` | `MULTi` for more than two audio languages | `MULTi` | +| `dubbed` | `DUBBED` for a single audio language that is not the original (strict mode only) | `DUBBED` | + +**Episode** (`series` and `sports` templates) + +| Variable | Meaning | Example | +|---|---|---| +| `season` | Zero-padded season (`S%02d`) | `S01` | +| `episode` | Zero-padded episode (`E%02d`) | `E05` | +| `season_episode` | Combined | `S01E05` | +| `episode_name` | Episode title | `Pilot` | +| `part` | Part index of a [split episode](../../guide/output-and-naming.md#split-episodes), empty otherwise | `2` | +| `absolute` | Absolute episode number, zero-padded to 3 digits, empty when unknown | `007` | +| `date` | ISO air date, empty when the episode has none | `2024-06-01` | + +When an episode has an air date, `season` and `season_episode` become the formatted air date, +unshackle clears `episode` and `year`, and `{date}` holds the ISO date. The separator inside +the date follows the style of the template. A `sports` template differs: `{date}` holds the +air date in the separator style of the template (`2026.11.01`), and `{year}` is empty when the +event has an air date. See [Sports events](../../guide/output-and-naming.md#sports-events). + +**Music** (`songs` and `albums` templates) + +| Variable | Meaning | +|---|---| +| `track_number` | Zero-padded track number | +| `artist` / `album_artist` | Artist / album artist (falls back to artist) | +| `album` | Album name | +| `disc` | Disc number (only shown when greater than 1) | +| `track_total` / `disc_total` | Totals | +| `release_type` | `album`, `single`, `ep`, or another type the service supplies | +| `genre` | Genre | +| `explicit` | `Explicit` when flagged | +| `isrc` / `upc` / `label` | ISRC, UPC and record label | + +!!! note "`quality` and `resolution` use the standard height" + unshackle names a video by the nearest standard height (4320, 2160, 1440, 1080, 720, 576, 540, + 480, 360 or 240) when it is within 10%. It measures the short side and the height that a 16:9 + picture of the same width has, and uses the larger one. So a cropped 1920x800, a padded + 1920x1088 and a 1080x1920 portrait video are all `1080p`. A short side within 16 lines of + 2160, 1440 or 1080 gives that height, so an ultrawide 2560x1080 is `1080p`. A size with no + standard height near it, such as 1600x900, keeps its own height. `dl -q` and the + `dl --export` file name use the same rule. + +!!! warning "An unknown variable stops the naming" + unshackle warns at startup about a variable that is not in the tables above, and continues. + When it names a file, a required variable (no `?`) that the title does not have, such as a + typo like `{quailty}` or `{season}` in a `movies` template, stops the title with + `Missing required template variables`. An optional `{quailty?}` is removed. !!! warning "`{part?}` is already inside `{season_episode}`" `part` holds the bare part index of a @@ -75,8 +162,8 @@ folder-kind keys. | `tag` | str | `""` | Release-group tag. Fills the `{tag}` template variable and is written into MKV/audio tags. | | `tag_group_name` | bool | `true` | Include the group name (`tag`) in the MKV `Group` tag. | | `tag_imdb_tmdb` | bool | `true` | Write IMDb/TMDB/TVDB external-ID tags into the MKV (needs metadata providers). | -| `chapter_fallback_name` | str | `""` | Fallback template for chapter names, e.g. `"Chapter {i:02}"`. | -| `unicode_filenames` | bool | `false` | Allow Unicode in filenames; when `false`, names are ASCII-sanitised. | +| `chapter_fallback_name` | str | `""` | The name of a chapter that has no name, as a template, e.g. `"Chapter {i:02}"`. `{i}` is the chapter number, from 1; `{j}` counts only the chapters without a name. Format directives such as `{i:02}` work. | +| `unicode_filenames` | bool | `false` | `false` transliterates non-ASCII characters to ASCII and removes accents. `true` keeps the native characters in file and folder names, with the vowel and tone marks of languages such as Thai, Hindi and Bengali. With each value, unshackle first normalises the name to Unicode NFC. | | [`filename_replacements`](#filename_replacements) | dict | `{}` | Replace text in file and folder names, e.g. `&` with `and`. | ## `codec_names` @@ -85,7 +172,7 @@ folder-kind keys. Renames the codec and HDR names in the filename. Each map key is a name that unshackle writes by default, and its value is the name to write instead. The map applies to the `video`, `audio`, -and `hdr` [template variables](../../guide/output-and-naming.md#template-variables), and so +and `hdr` [template variables](#template-variables), and so also to `audio_full`. A name that is not in the map stays as it is, and an empty value removes the name. You can also set `codec_names` for one service under `services`. @@ -175,7 +262,7 @@ Put the more specific rules first, because unshackle stops at the first match. also that HDR10 gives `HDR`, not `HDR10`, and so does a PQ video track with no HDR10 metadata. The full set of values is `HDR`, `HDR10P`, `DV`, `DV.HDR`, `DV.HDR10P`, `DV.HDRVivid`, `HDRVivid`, and `HLG`, as listed in the - [variable table](../../guide/output-and-naming.md#template-variables). + [variable table](#template-variables). ### Operators diff --git a/docs/reference/configuration/vaults.md b/docs/reference/configuration/vaults.md index eede75d5..4d2c7a83 100644 --- a/docs/reference/configuration/vaults.md +++ b/docs/reference/configuration/vaults.md @@ -1,23 +1,30 @@ # Key vaults { #key-vaults } -The full guide is at [Vaults](../../guide/vaults.md). Two keys configure them. +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. ## `key_vaults` - **Type:** `list[dict]`  ·  **Default:** `[]` -An ordered list of key-vault backends. unshackle queries them in order and reuses the -content keys instead of licensing them again. Each entry needs a `type` (the backend module -name) and a `name`, plus backend-specific keys. +A list of key-vault backends. The order in which unshackle asks them is in +[How lookups and caching work](../../guide/vaults.md#how-lookups-and-caching-work). Each entry +has these fields, plus the fields of its backend: -| `type` | Purpose | Required keys | Notes | -|--------|---------|--------------|-------| -| `SQLite` | Local SQLite database | `name`, `path` | Loaded **critically**; a failure aborts the run. | -| `MySQL` | Remote MySQL database | `name`, `host`, `database`, `username` | Extra keys (e.g. `password`, `port`) forwarded to pymysql. `connect_timeout`, `read_timeout` and `write_timeout` default to `vault_timeout`. `autocommit` is always on. | -| `API` | RESTful JSON API | `name`, `uri`, `token` | Optional `headers` map is sent with every request. Honours `vault_timeout`. | -| `HTTP` | HTTP API with modes | `name`, `host`, one of `password`/`api_key`, and `username` in query mode | `api_mode`: `query` (default), `json`, `decrypt_labs`. Honours `vault_timeout`. | +| Field | Required | Description | +|-------|----------|-------------| +| `type` | yes | The backend: `SQLite`, `MySQL`, `HTTP` or `API`. The value is the name of the backend module, and the match is case-sensitive: `sqlite` does not load. | +| `name` | yes | A label that you choose. The `kv` commands and the log name the vault by it. | +| `no_push` | no | `true` makes the vault read-only: unshackle reads content keys from it and never writes to it. Default `false`. | -```yaml +| `type` | Purpose | Required fields | Load failure during `dl` | +|--------|---------|-----------------|---------------------------| +| [`SQLite`](#sqlite) | A local SQLite database file | `path` | Stops the run. | +| [`MySQL`](#mysql) | A shared MySQL or MariaDB database | `host`, `database`, `username` | Skipped with a warning. | +| [`HTTP`](#http) | An HTTP vault in one of three protocols | `host`, `password` or `api_key`, `username` in `query` mode | Skipped with a warning. | +| [`API`](#api) | unshackle's own REST vault protocol | `uri`, `token` | Skipped with a warning. | + +```yaml title="unshackle.yaml" key_vaults: - type: SQLite name: Local @@ -31,34 +38,108 @@ key_vaults: no_push: false ``` -!!! note "Per-entry options" - - `no_push: true` makes a vault read-only (unshackle fetches content keys from it but never writes to it). - - A vault of `type: API` whose `name` contains `decrypt_labs` auto-fills its `token` from - [`decrypt_labs_api_key`](misc.md#external-api-keys) when not set inline. Vault `type` values are - case-sensitive module names. - - unshackle treats an empty or all-zero content key, of any length, as "no key" everywhere - and never stores it. +### `SQLite` { #sqlite } -!!! note "Bad content keys" - A content key from a vault is proven by short FFmpeg decodes of the decrypted output, - with windows inside the fragments of each KID in a fragmented MP4. A content key that - fails the decode is written to the `bad_keys` table of every `SQLite` vault with the name - of the vault that supplied it, and every vault lookup skips a flagged pair from then on. A `SQLite` vault also refuses to - store a flagged pair again. Only the `SQLite` backend stores flags; an `API` vault that - supplied the pair gets a report. A `serve` instance with - `server_cdm` flags a pair the same way when a remote client reports it, so a server whose - `key_vaults` hold no `SQLite` entry cannot remember a bad content key. +| Field | Required | Description | +|-------|----------|-------------| +| `path` | yes | The database file. `~` expands. unshackle makes the file and its tables on first use. | + +Each service gets its own table, named after the service tag, with `kid` and `key_` columns. +The connections use WAL journaling with a 30-second busy timeout, so threads can share one file. +A `bad_keys` table holds each KID:KEY that failed the decode check, with the service, the vault +that supplied it and the time of the flag. It is not a service table, and every command that +walks the service tables skips it. Only the `SQLite` backend stores these flags. + +### `MySQL` { #mysql } + +| Field | Required | Description | +|-------|----------|-------------| +| `host` | yes | The database server hostname or IP. | +| `database` | yes | The database (schema) name. | +| `username` | yes | The login user. | +| *(any other field)* | no | Goes to `pymysql.connect` as it is, for example `password`, `port` or `ssl`. `autocommit` is always on. | + +`connect_timeout`, `read_timeout` and `write_timeout` default to +[`vault_timeout`](#vault_timeout), or to 10 seconds when `vault_timeout` is `0`. + +The backend reads its own `SHOW GRANTS` when it connects. It needs `SELECT` to load, +`INSERT` to write content keys, and `CREATE` to make a service table. Each `MySQL` vault keeps +one connection for the whole run and shares it between threads. When the server is down, +unshackle skips the vault for the rest of the run. + +### `HTTP` { #http } + +| Field | Required | Description | +|-------|----------|-------------| +| `host` | yes | The base URL of the vault API. | +| `api_mode` | no | `query` (default), `json` or `decrypt_labs`. | +| `username` | in `query` mode | Ignored in the other modes. | +| `password` | `password` or `api_key` | The password in `query` mode, the token in `json` mode. | +| `api_key` | `password` or `api_key` | Used in `decrypt_labs` mode. When you give both, `api_key` wins. | +| `timeout` | no | The request timeout in seconds. Default [`vault_timeout`](#vault_timeout). | + +A vault with neither `password` nor `api_key` does not load. + +| `api_mode` | Transport | Authentication | Notes | +|------------|-----------|----------------|-------| +| `query` | `GET` with query parameters | `username` and `password` as query parameters | Read and write. | +| `json` | `POST` of `{"method": ..., "params": ..., "token": ...}` | `password` as the token | Read and write one content key at a time. Cannot list all content keys. | +| `decrypt_labs` | `POST` in the DecryptLabs format | `api_key` in a `decrypt-labs-api-key` header | Read-only: `no_push` is always on. | + +In `json` mode the methods are `GetKey`, `InsertKey` and `GetServices`. A bulk write +(`kv copy`, `kv add`) first sends `InsertKeys` with +`params: {"keys": {kid: key, ...}, "service": ..., "title": ...}`, up to 500 content keys a call, +and expects `{"inserted": }`. A server that answers HTTP 404 or +`Unknown JSON-RPC method` to `InsertKeys` gets one `InsertKey` call for each content key for +the rest of the run. Because `json` mode cannot list content keys, a `kv copy` from it relies +on the server to skip duplicates. + +A host that answers with a body that is not a JSON object, for example a parked domain or a +login page, is unreachable: unshackle logs one warning and skips the vault for the rest of the +run, and the `serve` health check reports the vault as failed. In `json` mode, HTTP 404 to a +lookup means that the vault has no entry. In `decrypt_labs` mode, an error status other than +429 is a miss. + +### `API` { #api } + +| Field | Required | Description | +|-------|----------|-------------| +| `uri` | yes | The base URI of the vault API. unshackle removes a trailing slash. | +| `token` | yes | The bearer token, sent as `Authorization: Bearer `. | +| `headers` | no | Extra HTTP headers for each request, for example the Cloudflare Access service-token headers `CF-Access-Client-Id` and `CF-Access-Client-Secret`. | +| `timeout` | no | The request timeout in seconds. Default [`vault_timeout`](#vault_timeout). | + +An `API` vault whose `name` contains `decrypt_labs` and has no `token` takes the token from +[`decrypt_labs_api_key`](misc.md#external-api-keys). + +The backend calls endpoints under `uri`, for example `GET {uri}/{service}/{kid}` for one +content key, and reads the numeric `code` field of each JSON answer to find errors such as a +bad token, a rate limit or an unknown service tag. A push of many content keys goes in batches. +When the server refuses a batch as too large, unshackle makes the batch smaller, and later pushes +to that vault start at the size that worked. + +!!! warning "This is unshackle's own protocol" + The `API` backend expects unshackle's request and response shape. A vault API of another + project does not work with it. Put an adapter in front of such a vault, or use the + [`HTTP`](#http) backend if one of its protocols matches. + +### Bad content keys + +A content key that fails the decode check goes into the `bad_keys` table of each `SQLite` +vault. Which vault gets a report, and what a server does, is in +[Wrong keys from a poisoned vault](../../guide/vaults.md#wrong-keys-from-a-poisoned-vault). ## `vault_timeout` - **Type:** `float`  ·  **Default:** `10.0` -Timeout in seconds for vault operations. Injected automatically into any backend whose -constructor accepts a `timeout` parameter (a per-vault `timeout` still wins). The `MySQL` backend -uses it as the default `connect_timeout`, `read_timeout` and `write_timeout`. +The timeout in seconds of a vault operation. unshackle gives it to each backend that takes a +`timeout` field (`HTTP` and `API`), unless the vault sets its own `timeout`. The `MySQL` +backend uses it as the default `connect_timeout`, `read_timeout` and `write_timeout`. The `API` and `HTTP` backends send a request again up to 3 times when the vault answers `429 Too Many Requests`. They wait the `Retry-After` time, but never longer than this timeout. -A connection failure or a timeout is not tried again. The run does not use a vault again after a -connection failure, a timeout, or a `429` that continues after the retries, so a vault that is -down costs one timeout per run. +unshackle does not try again after a connection failure or a timeout. The run does not use a +vault again after a connection failure, a timeout, or a `429` that continues after the retries, +so a vault that is down costs one timeout per run. unshackle writes to all vaults at the same +time, so a slow vault does not delay the others. diff --git a/unshackle/unshackle-example.yaml b/unshackle/unshackle-example.yaml index a3553515..e9737cac 100644 --- a/unshackle/unshackle-example.yaml +++ b/unshackle/unshackle-example.yaml @@ -10,16 +10,14 @@ tag: "NOGRP" # Conditionally swap the tag above based on filename variables (first match wins). -# See docs/reference/configuration.md#tag_rules for conditions and semantics. +# See docs/reference/configuration/output.md#tag_rules for conditions and semantics. # tag_rules: # - when: {lang_tag: SUBBED} # tag: SUBGRP -# --- Output filename & folder templates --- docs/guide/output-and-naming.md -# The full variable list and all naming options are documented there. -# movies/series have no built-in fallback (define them to download those kinds); -# songs falls back to "{track_number}. {title}". Conditional variables take a -# ? suffix, e.g. {year?}. +# --- Output filename & folder templates --- docs/reference/configuration/output.md +# The full variable list and every kind and its fallback are documented there. +# dl needs this key. Conditional variables take a ? suffix, e.g. {year?}. output_template: # Scene-style naming (dot-separated) movies: "{title}.{year?}.{repack?}.{edition?}.{lang_tag?}.{3d?}.{quality}.{source}.WEB-DL.{dual?}.{multi?}.{dubbed?}.{audio_full}.{atmos?}.{hdr?}.{hfr?}.{video}-{tag}" @@ -37,7 +35,7 @@ output_template: # songs: '{track_number}. {title}' # # Folder naming (optional). One template for all, or a per-kind map. - # Valid kinds: movies, series, songs, albums (album vars: see docs). + # Valid kinds: movies, series, sports, songs, albums (album vars: see docs). # folder: '{title} ({year?})' # folder: # movies: '{title} ({year})'