docs: add 1.1-1.4 features to MkDocs and README
Cover parallel downloads, interactive selection (--select), chapter renaming (--rename-chapters), XDG config paths, Ctrl+C handling, and thread-safe history across all docs: index, quickstart, configuration, cli-usage, format-strategies, troubleshooting, and README.
This commit is contained in:
8 files changed
+170
-16
No files matched your search
@@ -10,14 +10,16 @@ No Docker. No JVM. Just Python and go.
|
|||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Full library sync** — fetches every audiobook in your Libro.fm account with automatic pagination
|
- **Full library sync** — fetches every audiobook in your Libro.fm account with automatic pagination
|
||||||
|
- **Interactive book selection** — pick which books to download with `--select` (checkbox prompt)
|
||||||
- **M4B + MP3 formats** — downloads M4B (single file) or MP3 (ZIP parts extracted) with automatic fallback
|
- **M4B + MP3 formats** — downloads M4B (single file) or MP3 (ZIP parts extracted) with automatic fallback
|
||||||
|
- **Chapter renaming** — MP3 files renamed with chapter titles from the manifest (configurable)
|
||||||
- **Resume support** — interrupted downloads pick up where they left off via `.partial` files
|
- **Resume support** — interrupted downloads pick up where they left off via `.partial` files
|
||||||
|
- **Parallel downloads** — `ThreadPoolExecutor` downloads multiple books simultaneously; configurable via `--workers N` (default 3)
|
||||||
- **Cover art & PDF extras** — optional download of cover images and accompanying PDFs
|
- **Cover art & PDF extras** — optional download of cover images and accompanying PDFs
|
||||||
- **Customizable output paths** — token-based patterns for organizing your library on disk
|
- **Customizable output paths** — token-based patterns for organizing your library on disk
|
||||||
- **TTY-aware progress** — rich progress bars in your terminal, clean log lines in cron jobs
|
- **TTY-aware progress** — rich progress bars in your terminal, clean log lines in cron jobs
|
||||||
- **Download history** — tracks what's been downloaded so re-runs only fetch new books
|
- **Download history** — tracks what's been downloaded so re-runs only fetch new books
|
||||||
- **Graceful failure isolation** — one failed book doesn't stop the rest
|
- **Graceful failure isolation** — one failed book doesn't stop the rest
|
||||||
- **Parallel downloads** — `ThreadPoolExecutor` downloads multiple books simultaneously; configurable via `--workers N` (default 3)
|
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
@@ -49,8 +51,10 @@ EOF
|
|||||||
|
|
||||||
# 3. Run
|
# 3. Run
|
||||||
librofm-downloader # default: 3 parallel workers
|
librofm-downloader # default: 3 parallel workers
|
||||||
|
librofm-downloader --select # pick books interactively
|
||||||
librofm-downloader -w 5 # 5 parallel workers
|
librofm-downloader -w 5 # 5 parallel workers
|
||||||
librofm-downloader --workers 1 # sequential (1 worker)
|
librofm-downloader --workers 1 # sequential (1 worker)
|
||||||
|
librofm-downloader --limit 5 # only download 5 new books
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ librofm-downloader [OPTIONS]
|
|||||||
| `--history` | | XDG → CWD search | Path to download history JSON (overrides default search) |
|
| `--history` | | XDG → CWD search | Path to download history JSON (overrides default search) |
|
||||||
| `-v, --verbose` | | off | Print extra detail (URLs, paths, API responses) |
|
| `-v, --verbose` | | off | Print extra detail (URLs, paths, API responses) |
|
||||||
| `--limit` N | | `0` (no limit) | Maximum number of books to download |
|
| `--limit` N | | `0` (no limit) | Maximum number of books to download |
|
||||||
|
| `--rename-chapters` | | config | Rename extracted MP3 files with chapter titles |
|
||||||
|
| `--select` | | off | Interactive book selection (checkbox prompt) |
|
||||||
| `-w, --workers` N | | `3` | Number of parallel download workers (1 = sequential) |
|
| `-w, --workers` N | | `3` | Number of parallel download workers (1 = sequential) |
|
||||||
|
|
||||||
### --verbose
|
### --verbose
|
||||||
@@ -86,6 +88,67 @@ Resolution order (CLI > config > default):
|
|||||||
|
|
||||||
Set to `1` for behavior identical to the pre-parallelism sequential mode.
|
Set to `1` for behavior identical to the pre-parallelism sequential mode.
|
||||||
|
|
||||||
|
### --select
|
||||||
|
|
||||||
|
Launch an interactive book selection prompt before downloading:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Pick which books to download from a checkbox list
|
||||||
|
librofm-downloader --select
|
||||||
|
```
|
||||||
|
|
||||||
|
**Flow:**
|
||||||
|
|
||||||
|
1. Tool fetches your library and filters already-downloaded books
|
||||||
|
2. A checkbox prompt appears — use **space** to toggle, arrows to navigate, **enter** to confirm
|
||||||
|
3. A confirmation summary shows your selection
|
||||||
|
4. Only selected books are downloaded
|
||||||
|
|
||||||
|
**Behavior notes:**
|
||||||
|
|
||||||
|
- Requires an interactive terminal (TTY). Non-interactive environments (cron, pipes) produce an error and exit
|
||||||
|
- When `--select` is active, `--limit` is superseded — a notice is printed if both are specified
|
||||||
|
- Books are downloaded in the order they appear in your library (selection order is preserved)
|
||||||
|
|
||||||
|
**Row format:**
|
||||||
|
|
||||||
|
```
|
||||||
|
1. The Way of Kings — Brandon Sanderson [Stormlight Archive #1]
|
||||||
|
2. Mistborn — Brandon Sanderson [Mistborn #1]
|
||||||
|
3. Elantris — Brandon Sanderson
|
||||||
|
```
|
||||||
|
|
||||||
|
Series info and number are shown when available.
|
||||||
|
|
||||||
|
### --rename-chapters
|
||||||
|
|
||||||
|
Rename extracted MP3 files with chapter titles from the download manifest:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Enable chapter renaming (overrides config)
|
||||||
|
librofm-downloader --rename-chapters
|
||||||
|
```
|
||||||
|
|
||||||
|
**Resolution order (CLI > config > default):**
|
||||||
|
|
||||||
|
1. **`--rename-chapters`** flag on the command line
|
||||||
|
2. **`rename_chapters:`** field in `config.yaml`
|
||||||
|
3. **Default: `true`**
|
||||||
|
|
||||||
|
Only applies when the download pipeline uses MP3 files (`m4b_mp3_fallback` fallback path or `mp3_only` mode). M4B files have built-in chapter metadata and are not affected.
|
||||||
|
|
||||||
|
**Example renaming:**
|
||||||
|
|
||||||
|
```
|
||||||
|
# Before (raw ZIP extraction)
|
||||||
|
01.mp3 02.mp3 03.mp3 04.mp3
|
||||||
|
|
||||||
|
# After (--rename-chapters, default)
|
||||||
|
001 - Opening.mp3 002 - The Arrival.mp3 003 - Revelations.mp3 004 - Departure.mp3
|
||||||
|
```
|
||||||
|
|
||||||
|
Files are zero-padded to match the widest track number (3 digits for 10-999 tracks, 2 for fewer).
|
||||||
|
|
||||||
## Exit codes
|
## Exit codes
|
||||||
|
|
||||||
| Code | Meaning |
|
| Code | Meaning |
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ All non-credential settings. Safe to commit. **Optional** — if missing, built-
|
|||||||
| `output_dir` | `string` | `"./audiobooks"` | Base directory for downloaded files. Relative paths resolve from CWD. |
|
| `output_dir` | `string` | `"./audiobooks"` | Base directory for downloaded files. Relative paths resolve from CWD. |
|
||||||
| `download_extras` | `boolean` | `true` | Download PDF extras (e.g., maps) when available. |
|
| `download_extras` | `boolean` | `true` | Download PDF extras (e.g., maps) when available. |
|
||||||
| `download_covers` | `boolean` | `true` | Download cover art (JPEG/PNG) when available. |
|
| `download_covers` | `boolean` | `true` | Download cover art (JPEG/PNG) when available. |
|
||||||
|
| `rename_chapters` | `boolean` | `true` | Rename extracted MP3 files with chapter titles from the manifest. Only applies to MP3 pipeline (`m4b_mp3_fallback` fallback or `mp3_only`). |
|
||||||
| `workers` | `integer` | `3` | Number of parallel download threads. Set to 1 for sequential mode. Must be ≥ 1. |
|
| `workers` | `integer` | `3` | Number of parallel download threads. Set to 1 for sequential mode. Must be ≥ 1. |
|
||||||
|
|
||||||
### Full example
|
### Full example
|
||||||
|
|||||||
@@ -136,3 +136,21 @@ Summary: 5 downloaded, 2 skipped, 0 failed
|
|||||||
- The ZIP file is deleted after extraction
|
- The ZIP file is deleted after extraction
|
||||||
- Each part supports resume via `Range` headers
|
- Each part supports resume via `Range` headers
|
||||||
- Parts are downloaded sequentially within each book
|
- Parts are downloaded sequentially within each book
|
||||||
|
|
||||||
|
### Chapter renaming (MP3 only)
|
||||||
|
|
||||||
|
When `rename_chapters` is enabled (default), extracted MP3 files are renamed with chapter titles from the download manifest:
|
||||||
|
|
||||||
|
```
|
||||||
|
# Before (raw extraction)
|
||||||
|
01.mp3 02.mp3 03.mp3
|
||||||
|
|
||||||
|
# After (renamed)
|
||||||
|
001 - Opening.mp3 002 - The Arrival.mp3 003 - Departure.mp3
|
||||||
|
```
|
||||||
|
|
||||||
|
- Files are sorted naturally by numeric prefix before renaming
|
||||||
|
- Zero-padding matches the widest track number
|
||||||
|
- Blank or missing titles fall back to the original filename
|
||||||
|
- Titles are sanitized (illegal characters stripped) via the same function used for path components
|
||||||
|
- Disable in `config.yaml` with `rename_chapters: false`, or override per-run with `--rename-chapters` on the CLI
|
||||||
@@ -10,8 +10,11 @@ No Docker. No JVM. Just Python and go.
|
|||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Full library sync** — fetches every audiobook in your Libro.fm account with automatic pagination
|
- **Full library sync** — fetches every audiobook in your Libro.fm account with automatic pagination
|
||||||
|
- **Interactive book selection** — pick which books to download with `--select` (checkbox prompt)
|
||||||
- **M4B + MP3 formats** — downloads M4B (single file) or MP3 (ZIP parts extracted) with automatic fallback
|
- **M4B + MP3 formats** — downloads M4B (single file) or MP3 (ZIP parts extracted) with automatic fallback
|
||||||
|
- **Chapter renaming** — MP3 files renamed with chapter titles from the manifest (configurable)
|
||||||
- **Resume support** — interrupted downloads pick up where they left off via `.partial` files
|
- **Resume support** — interrupted downloads pick up where they left off via `.partial` files
|
||||||
|
- **Parallel downloads** — configurable worker count (`--workers N`, default 3) with graceful Ctrl+C drain
|
||||||
- **Cover art & PDF extras** — optional download of cover images and accompanying PDFs
|
- **Cover art & PDF extras** — optional download of cover images and accompanying PDFs
|
||||||
- **Customizable output paths** — token-based patterns for organizing your library on disk
|
- **Customizable output paths** — token-based patterns for organizing your library on disk
|
||||||
- **TTY-aware progress** — rich progress bars in your terminal, clean log lines in cron jobs
|
- **TTY-aware progress** — rich progress bars in your terminal, clean log lines in cron jobs
|
||||||
|
|||||||
+42
-14
@@ -16,13 +16,9 @@ pip install -e .
|
|||||||
|
|
||||||
Requires **Python 3.11+**.
|
Requires **Python 3.11+**.
|
||||||
|
|
||||||
### From source
|
For development (includes pytest):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/AlexKucera/librofm-downloader.git
|
|
||||||
cd librofm-downloader
|
|
||||||
python -m venv .venv
|
|
||||||
source .venv/bin/activate # or .venv\Scripts\activate on Windows
|
|
||||||
pip install -e ".[dev]"
|
pip install -e ".[dev]"
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -63,6 +59,13 @@ librofm:
|
|||||||
|
|
||||||
# Whether to download cover art when available
|
# Whether to download cover art when available
|
||||||
download_covers: true
|
download_covers: true
|
||||||
|
|
||||||
|
# Whether to rename MP3 chapter files with titles from the manifest
|
||||||
|
# Only applies when format falls back to MP3 (m4b_mp3_fallback or mp3_only)
|
||||||
|
rename_chapters: true
|
||||||
|
|
||||||
|
# Number of parallel download workers (1 = sequential)
|
||||||
|
workers: 3
|
||||||
```
|
```
|
||||||
|
|
||||||
### secrets.yaml
|
### secrets.yaml
|
||||||
@@ -91,21 +94,37 @@ This:
|
|||||||
2. Authenticates with Libro.fm via OAuth2 password grant
|
2. Authenticates with Libro.fm via OAuth2 password grant
|
||||||
3. Fetches your full library (all pages)
|
3. Fetches your full library (all pages)
|
||||||
4. Skips books already in `download_history.json` (XDG → CWD search)
|
4. Skips books already in `download_history.json` (XDG → CWD search)
|
||||||
5. Downloads each new book with a progress bar
|
5. Downloads each new book with up to 3 parallel workers
|
||||||
6. Downloads each new book (3 parallel workers by default) with a progress bar
|
6. Records successful downloads to history
|
||||||
7. Records successful downloads to history
|
|
||||||
|
### Interactive selection
|
||||||
|
|
||||||
|
Pick which books to download from a checkbox list:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
librofm-downloader --select
|
||||||
|
```
|
||||||
|
|
||||||
|
This:
|
||||||
|
|
||||||
|
1. Fetches your library and filters already-downloaded books
|
||||||
|
2. Presents a checkbox prompt (space to toggle, enter to confirm)
|
||||||
|
3. Downloads only the books you selected
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> `--select` requires an interactive terminal (TTY). In non-interactive
|
||||||
|
> environments (cron, pipes), the tool exits with an error.
|
||||||
|
|
||||||
|
When `--select` is active, `--limit` is superseded — you control exactly which books are downloaded.
|
||||||
|
|
||||||
### First run output (TTY)
|
### First run output (TTY)
|
||||||
|
|
||||||
```
|
```
|
||||||
3 book(s) to download:
|
3 book(s) to download:
|
||||||
|
|
||||||
Author One - Book Title One ██████████████████████████ 100.0% 2.1 MB/s 00:01 45.2 MB
|
Brandon Sanderson - The Way of Kings ██████████████████████████ 100.0% 2.1 MB/s 00:01 45.2 MB
|
||||||
✓ Book Title One
|
Author Two - Another Book ██████████████████████████ 100.0% 1.8 MB/s 00:02 120.5 MB
|
||||||
Author Two - Another Book ██████████████████████████ 100.0% 1.8 MB/s 00:02 120.5 MB
|
Author Three - Third Book ██████████████████████████ 100.0% 2.3 MB/s 00:00 89.1 MB
|
||||||
✓ Another Book
|
|
||||||
Author Three - Third Book ██████████████████████████ 100.0% 2.3 MB/s 00:00 89.1 MB
|
|
||||||
✓ Third Book
|
|
||||||
|
|
||||||
Summary: 3 downloaded, 0 skipped, 0 failed
|
Summary: 3 downloaded, 0 skipped, 0 failed
|
||||||
```
|
```
|
||||||
@@ -129,6 +148,14 @@ Completed: Author Two - Another Book
|
|||||||
Summary: 2 downloaded, 0 skipped, 0 failed
|
Summary: 2 downloaded, 0 skipped, 0 failed
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Interrupted downloads
|
||||||
|
|
||||||
|
Press **Ctrl+C** to gracefully stop:
|
||||||
|
|
||||||
|
- First press: in-flight downloads drain to completion, then summary prints
|
||||||
|
- Second press: immediate hard exit
|
||||||
|
- Partial downloads (`.partial` files) resume automatically on next run
|
||||||
|
|
||||||
## What gets downloaded?
|
## What gets downloaded?
|
||||||
|
|
||||||
Files land under your `output_dir` using this structure:
|
Files land under your `output_dir` using this structure:
|
||||||
@@ -147,6 +174,7 @@ audiobooks/
|
|||||||
|
|
||||||
- Books with **cover art or PDF extras** get a subdirectory (`Author/Title/`)
|
- Books with **cover art or PDF extras** get a subdirectory (`Author/Title/`)
|
||||||
- Books without extras are flat files (`Author/Title.m4b`)
|
- Books without extras are flat files (`Author/Title.m4b`)
|
||||||
|
- When using MP3 format, chapter files are renamed with titles from the manifest (e.g., `001 - Opening.mp3`, `002 - The Arrival.mp3`)
|
||||||
- See [Path Patterns](path-patterns.md) for customization options
|
- See [Path Patterns](path-patterns.md) for customization options
|
||||||
|
|
||||||
## Next steps
|
## Next steps
|
||||||
|
|||||||
@@ -123,6 +123,31 @@ $ librofm-downloader
|
|||||||
- Switch to `m4b_mp3_fallback` to get the MP3 version instead
|
- Switch to `m4b_mp3_fallback` to get the MP3 version instead
|
||||||
- Accept that some books aren't available in M4B format
|
- Accept that some books aren't available in M4B format
|
||||||
|
|
||||||
|
## Selection issues
|
||||||
|
|
||||||
|
### "--select requires an interactive terminal"
|
||||||
|
|
||||||
|
**Cause:** You ran `librofm-downloader --select` in a non-interactive environment (cron, piped, SSH without TTY allocation).
|
||||||
|
|
||||||
|
**Behavior:**
|
||||||
|
- Tool exits immediately with exit code **1**
|
||||||
|
- No downloads are attempted
|
||||||
|
|
||||||
|
**Fix options:**
|
||||||
|
- Run in an interactive terminal (local shell, `ssh -t` for TTY allocation)
|
||||||
|
- Use `--limit N` instead for non-interactive capped downloads
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Non-interactive alternative: just download the first 5 new books
|
||||||
|
librofm-downloader --limit 5
|
||||||
|
```
|
||||||
|
|
||||||
|
### --limit seems ignored when using --select
|
||||||
|
|
||||||
|
**Behavior:** When `--select` is active, `--limit` is superseded — you pick exactly which books to download from the checkbox prompt. A notice is printed confirming this.
|
||||||
|
|
||||||
|
**Fix:** This is intentional. Use `--select` to choose books, or use `--limit` alone for automatic capping.
|
||||||
|
|
||||||
## History file problems
|
## History file problems
|
||||||
|
|
||||||
### "Corrupt history file download_history.json: ... Starting with empty history."
|
### "Corrupt history file download_history.json: ... Starting with empty history."
|
||||||
@@ -226,6 +251,18 @@ Use `--limit` to process smaller batches:
|
|||||||
librofm-downloader --limit 5
|
librofm-downloader --limit 5
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or select specific books interactively:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
librofm-downloader --select
|
||||||
|
```
|
||||||
|
|
||||||
|
Or limit to the first 5 new books:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
librofm-downloader --limit 5
|
||||||
|
```
|
||||||
|
|
||||||
## Getting help
|
## Getting help
|
||||||
|
|
||||||
If none of the above covers your issue:
|
If none of the above covers your issue:
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "librofm-downloader"
|
name = "librofm-downloader"
|
||||||
version = "1.1.0"
|
version = "1.4.0"
|
||||||
description = "Download owned audiobooks from your Libro.fm account"
|
description = "Download owned audiobooks from your Libro.fm account"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|||||||
Reference in new issue
Block a user