Name downloaded books with a template
The new "Book Downloads" group in Settings holds a Calibre template for the file name of a direct download. Without a template, the name stays the title. The name is also the title if the template fails or gives no name for a book.
This commit is contained in:
@@ -445,6 +445,53 @@ After the import, Bindery checks the site for new chapters and sends the book to
|
||||
"Check the site for new chapters after import", Bindery only rebuilds the book of a story that it
|
||||
downloaded before.
|
||||
|
||||
## File names of downloaded books
|
||||
|
||||
"Download ePub" on a story page sends the book to your browser with a file name. Without a template,
|
||||
the name is the title, for example `The Book.epub`.
|
||||
|
||||
An admin can set a template for the name under "Book Downloads" in Settings. The template follows
|
||||
the rules of [Calibre's templates](https://manual.calibre-ebook.com/template_lang.html) for file
|
||||
names, so a template from Calibre gives the same name in Bindery. Bindery adds `.epub`. For example,
|
||||
`{series:|| - }{series_index:0>2s|| - }{title} - {authors}` gives
|
||||
`Saga, The - 02 - Book, The - Ann Writer.epub`.
|
||||
|
||||
| Field | Value |
|
||||
| --- | --- |
|
||||
| `{title}` | The title. A leading "The", "A" or "An" moves to the end, as in Calibre: `Book, The`. |
|
||||
| `{title_sort}` | The same value as `{title}`. |
|
||||
| `{authors}`, `{author}` | The authors, with ` & ` between them. |
|
||||
| `{author_sort}` | The authors with the last name first: `Writer, Ann`. |
|
||||
| `{series}` | The series. A leading article moves to the end. |
|
||||
| `{series_index}` | The series number: `2`, or `2.5`. |
|
||||
| `{tags}` | The tags in sorted order, with `, ` between them. |
|
||||
| `{languages}` | The language, as Bindery stores it. |
|
||||
| `{publisher}` | The story site. |
|
||||
| `{pubdate}` | The published date, in the form `May, 2020`. |
|
||||
| `{timestamp}` | The date when Bindery added the story. |
|
||||
| `{last_modified}` | The date when the chapters last changed. |
|
||||
| `{id}` | The CWA book ID. For a story with no library book, and without CWA, the Bindery story ID. |
|
||||
|
||||
- A field with no value becomes empty text. So does a field that Bindery does not have, such as
|
||||
`{rating}` or a custom column.
|
||||
- `{field:format|text before|text after}` adds the two texts only when the field has a value. Each
|
||||
of the three parts can be empty. `{series:|| - }` adds ` - ` after the series.
|
||||
- The format is a Python format. `{series_index:0>3s}` gives `002`, and `{title:.20s}` gives the
|
||||
first 20 characters. `{author_sort[0]}` gives the first character.
|
||||
- `{{` and `}}` give braces. Bindery makes each run of spaces one space.
|
||||
- A download has one file name. If the template has folders, Bindery uses the part after the last
|
||||
`/`. That is the name that Calibre gives the file.
|
||||
- Bindery does not support template functions, such as `{title:uppercase()}`, or the program modes
|
||||
of Calibre. It refuses such a template when you save it.
|
||||
- If the template fails for a book, or gives an empty name, Bindery names the file after the title.
|
||||
The log has a warning.
|
||||
- Bindery replaces each character that a file name cannot have with `_`. A name has 100 characters
|
||||
and 200 bytes at most.
|
||||
|
||||
Bindery follows Calibre 9.2.1 with its default tweaks, for English. The order of tags with letters
|
||||
outside ASCII can differ from Calibre. The template applies only to downloads in the browser. It
|
||||
does not change the names of the files in `INGEST_DIR`. The browser can ignore the name.
|
||||
|
||||
## Download modes
|
||||
|
||||
| Mode | What it does |
|
||||
|
||||
Reference in New Issue
Block a user