feat(config): add filename_replacements to replace text in output names

This commit is contained in:
imSp4rky
2026-11-28 15:03:01 -07:00
parent 127e8e0dcc
commit 418d69b1ec
9 changed files with 115 additions and 10 deletions
+1 -1
View File
@@ -590,7 +590,7 @@ unicode_filenames: true
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.
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.
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).
unshackle warns at startup about a template that contains `< > : " / \ | ? *`. It examines a folder template per path segment, so you can use `/` there as a directory separator.
+1 -1
View File
@@ -32,7 +32,7 @@ Where the file lives, how unshackle discovers it, and how to edit it:
| [Directories](directories.md) | `directories`, `filenames`, `services_repo_force` |
| [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` |
| [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` |
| [Network & proxy](network.md) | `network`, `headers`, `proxy_providers` |
| [Key vaults](vaults.md) | `key_vaults`, `vault_timeout` |
+29
View File
@@ -77,6 +77,7 @@ folder-kind keys.
| `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. |
| [`filename_replacements`](#filename_replacements) | dict | `{}` | Replace text in file and folder names, e.g. `&` with `and`. |
## `codec_names`
@@ -107,6 +108,34 @@ The `dl --export` file name does not use `codec_names`.
unshackle evaluates [`tag_rules`](#tag_rules) after the rename. With the example above, a
rule must match `audio: EAC3`, not `audio: DDP`.
## `filename_replacements`
- **Type:** `dict` &nbsp;·&nbsp; **Default:** `{}`
Replaces text in file and folder names. Each entry of the map names the text to find, and its
value is the text to write instead. An empty value removes the text. unshackle applies the map
in order, before it sanitises the name, so a later entry also sees the result of an earlier
entry. You can also set `filename_replacements` for one service under `services`.
```yaml title="unshackle.yaml"
filename_replacements:
"&": and # Tom & Jerry -> Tom.and.Jerry, Tom&Jerry -> Tom.and.Jerry
```
Put quotes around text such as `"&"`: YAML reads a bare `&` as an anchor. When the text to
find has no letters or digits and the replacement is a word, unshackle puts a separator on each
side of the replacement, so `Tom&Jerry` gives `Tom.and.Jerry`. The map also changes text
inside a word: `AT&T` gives `AT.and.T`. An entry that does not map text to text stops
unshackle at startup with an error.
The map applies to the whole name that a template makes, and also to the title part of the
`dl --export` file name. Find only text that titles contain: an entry for `-` also changes
`WEB-DL` and the `-{tag}` separator. The ` & ` that unshackle writes for `/` and `;` in a
multi-episode name stays as it is, unless the map has an entry for `/` or `;`.
unshackle finds the text before it transliterates the name to ASCII. For a title that uses a
variant of a character, such as the fullwidth `&`, add an entry for that variant too.
## `tag_rules`
- **Type:** `list` &nbsp;·&nbsp; **Default:** `[]`