Merge branch 'develop' into feature/parallel-downloads
This commit is contained in:
22 files changed
+1051
-113
No files matched your search
@@ -12,9 +12,9 @@ librofm-downloader [OPTIONS]
|
||||
|
||||
| Option | Short | Default | Description |
|
||||
|--------|-------|---------|-------------|
|
||||
| `--config` | | `config.yaml` | Path to `config.yaml` |
|
||||
| `--secrets` | | `secrets.yaml` | Path to `secrets.yaml` |
|
||||
| `--history` | | `download_history.json` | Path to download history JSON file |
|
||||
| `--config` | | XDG → CWD search | Path to `config.yaml` (overrides default search) |
|
||||
| `--secrets` | | XDG → CWD search | Path to `secrets.yaml` (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) |
|
||||
| `--limit` N | | `0` (no limit) | Maximum number of books to download |
|
||||
| `-w, --workers` N | | `3` | Number of parallel download workers (1 = sequential) |
|
||||
@@ -25,9 +25,9 @@ Shows internal pipeline state at each stage:
|
||||
|
||||
```
|
||||
── config ──────────────────────────────────────
|
||||
config: config.yaml
|
||||
secrets: secrets.yaml
|
||||
history: download_history.json
|
||||
config: ~/.config/librofm-downloader/config.yaml
|
||||
secrets: ~/.config/librofm-downloader/secrets.yaml
|
||||
history: ~/.config/librofm-downloader/download_history.json
|
||||
format: m4b_mp3_fallback
|
||||
output: ./audiobooks
|
||||
extras: True
|
||||
|
||||
@@ -1,16 +1,47 @@
|
||||
# Configuration Reference
|
||||
|
||||
Complete reference for `config.yaml` and `secrets.yaml`.
|
||||
Complete reference for `config.yaml`, `secrets.yaml`, and download history.
|
||||
|
||||
## File locations
|
||||
## Default file locations
|
||||
|
||||
The CLI looks for these files in the **current working directory** by default:
|
||||
When no `--config`, `--secrets`, or `--history` flags are provided, the tool searches for each file in this order:
|
||||
|
||||
```bash
|
||||
librofm-downloader --config config.yaml --secrets secrets.yaml
|
||||
1. **XDG directory** — `~/.config/librofm-downloader/`
|
||||
2. **Current working directory** (CWD)
|
||||
|
||||
The XDG directory is **created automatically** on first run if it doesn't exist. This means you can drop your files into `~/.config/librofm-downloader/` and run `librofm-downloader` from any directory.
|
||||
|
||||
```
|
||||
~/.config/librofm-downloader/
|
||||
├── config.yaml # optional — built-in defaults used if missing
|
||||
├── secrets.yaml # required — tool exits with an error if missing
|
||||
└── download_history.json # created automatically on first download
|
||||
```
|
||||
|
||||
Both files share the same top-level key: `librofm`.
|
||||
### Missing files: config vs secrets
|
||||
|
||||
The two config files have different missing-file behavior:
|
||||
|
||||
| File | If missing | Behavior |
|
||||
|------|-----------|----------|
|
||||
| `config.yaml` | Non-fatal | Tool runs with built-in defaults (m4b_mp3_fallback, `./audiobooks`, etc.). A notice is printed listing searched paths. |
|
||||
| `secrets.yaml` | Fatal | Tool exits with code **1** and an error listing both searched locations so you know where to create it. |
|
||||
|
||||
### Overriding with CLI flags
|
||||
|
||||
Use `--config`, `--secrets`, and `--history` to bypass the XDG→CWD search entirely and point at specific files:
|
||||
|
||||
```bash
|
||||
# Use files in a custom location
|
||||
librofm-downloader --config /path/to/config.yaml --secrets /path/to/secrets.yaml
|
||||
|
||||
# Custom history file
|
||||
librofm-downloader --history /path/to/download_history.json
|
||||
```
|
||||
|
||||
When a flag is provided, that path is used directly — no search is performed.
|
||||
|
||||
Both config files share the same top-level key: `librofm`.
|
||||
|
||||
## secrets.yaml
|
||||
|
||||
@@ -33,7 +64,7 @@ librofm:
|
||||
|
||||
## config.yaml
|
||||
|
||||
All non-credential settings. Safe to commit.
|
||||
All non-credential settings. Safe to commit. **Optional** — if missing, built-in defaults are used.
|
||||
|
||||
| Field | Type | Default | Description |
|
||||
|-------|------|---------|-------------|
|
||||
@@ -86,11 +117,19 @@ Move them to secrets.yaml (which is gitignored).
|
||||
| `Config error: Credentials (...) found in config.yaml` | Username or password in config file | Move to `secrets.yaml` |
|
||||
| `Missing required fields in secrets.yaml: username` | Missing credential field | Add it to `secrets.yaml` |
|
||||
| `Invalid format 'foo'` | Unknown format value | Use one of: `m4b_mp3_fallback`, `mp3_only`, `m4b_only` |
|
||||
| `config.yaml not found in ~/.config/.../config.yaml → ./config.yaml. Using built-in defaults.` | No config file in either location | Non-fatal — defaults used. Create `config.yaml` to customize. |
|
||||
| `Missing secrets.yaml. Searched: ~/.config/.../secrets.yaml → ./secrets.yaml.` | No secrets file in either location | Create `secrets.yaml` with your credentials in one of the searched locations. |
|
||||
| `Invalid workers value: 0` | Workers < 1 | Set `workers` to an integer ≥ 1 |
|
||||
|
||||
## Download history
|
||||
|
||||
A third file, `download_history.json`, is created automatically on first run:
|
||||
A third file, `download_history.json`, tracks what's been downloaded. It follows the same XDG→CWD search order as the config files, and defaults to the XDG directory when not found anywhere:
|
||||
|
||||
```
|
||||
~/.config/librofm-downloader/download_history.json
|
||||
```
|
||||
|
||||
The file is created automatically on first download. Override with `--history` to use a custom location.
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -106,5 +145,4 @@ A third file, `download_history.json`, is created automatically on first run:
|
||||
|
||||
- Keyed by **ISBN** — each book is recorded once
|
||||
- Used to skip already-downloaded books on subsequent runs
|
||||
- Location defaults to `download_history.json` in CWD; override with `--history`
|
||||
- If the file is corrupt or missing, the tool starts with an empty history (and logs a warning)
|
||||
@@ -26,12 +26,16 @@ The `[dev]` extra installs pytest for testing — omit it if you only want to ru
|
||||
|
||||
## 2. Configure
|
||||
|
||||
librofm-downloader uses two YAML files:
|
||||
librofm-downloader uses two YAML files, searched in `~/.config/librofm-downloader/` first, then the current working directory:
|
||||
|
||||
| File | Purpose | Committed to git? |
|
||||
|------|---------|:-----------------:|
|
||||
| `config.yaml` | Preferences (format, output dir, toggles) | ✅ Yes |
|
||||
| `secrets.yaml` | Credentials only | ❌ No (gitignored) |
|
||||
| File | Purpose | Required? | Committed to git? |
|
||||
|------|---------|:---------:|:-----------------:|
|
||||
| `config.yaml` | Preferences (format, output dir, toggles) | No (defaults used) | ✅ Yes |
|
||||
| `secrets.yaml` | Credentials only | **Yes** | ❌ No (gitignored) |
|
||||
|
||||
> [!TIP]
|
||||
> The XDG directory (`~/.config/librofm-downloader/`) is created automatically on first run.
|
||||
> Place both files there to run `librofm-downloader` from any directory.
|
||||
|
||||
### config.yaml
|
||||
|
||||
@@ -79,12 +83,13 @@ librofm-downloader
|
||||
|
||||
This:
|
||||
|
||||
1. Loads `config.yaml` + `secrets.yaml`
|
||||
1. Searches for `config.yaml` + `secrets.yaml` (XDG directory first, then CWD)
|
||||
2. Authenticates with Libro.fm via OAuth2 password grant
|
||||
3. Fetches your full library (all pages)
|
||||
4. Skips books already in `download_history.json`
|
||||
5. Downloads each new book (3 parallel workers by default) with a progress bar
|
||||
6. Records successful downloads to history
|
||||
4. Skips books already in `download_history.json` (XDG → CWD search)
|
||||
5. Downloads each new book with a progress bar
|
||||
6. Downloads each new book (3 parallel workers by default) with a progress bar
|
||||
7. Records successful downloads to history
|
||||
|
||||
### First run output (TTY)
|
||||
|
||||
|
||||
@@ -56,15 +56,19 @@ librofm:
|
||||
|
||||
### "[Errno 2] No such file or directory: 'config.yaml'"
|
||||
|
||||
**Cause:** The config file doesn't exist at the specified path (default: current directory).
|
||||
**Cause:** The config file doesn't exist at the specified path.
|
||||
|
||||
**Fix:**
|
||||
|
||||
```bash
|
||||
# Run from the directory that contains config.yaml
|
||||
# Option 1: Place files in the XDG directory (recommended)
|
||||
mkdir -p ~/.config/librofm-downloader
|
||||
cp config.yaml secrets.yaml ~/.config/librofm-downloader/
|
||||
|
||||
# Option 2: Run from the directory that contains config.yaml
|
||||
cd /path/to/your/project
|
||||
|
||||
# Or specify the path explicitly
|
||||
# Option 3: Specify paths explicitly
|
||||
librofm-downloader --config /path/to/config.yaml --secrets /path/to/secrets.yaml
|
||||
```
|
||||
|
||||
@@ -133,10 +137,14 @@ $ librofm-downloader
|
||||
|
||||
```bash
|
||||
# Option 1: Delete and let it rebuild
|
||||
rm ~/.config/librofm-downloader/download_history.json
|
||||
librofm-downloader
|
||||
|
||||
# Option 2: If using CWD-based history
|
||||
rm download_history.json
|
||||
librofm-downloader
|
||||
|
||||
# Option 2: Fix the JSON manually (if you know what's in there)
|
||||
# Option 3: Fix the JSON manually (if you know what's in there)
|
||||
# Check for trailing commas, missing braces, etc.
|
||||
```
|
||||
|
||||
@@ -147,7 +155,10 @@ librofm-downloader
|
||||
**Check:**
|
||||
|
||||
```bash
|
||||
# See what's recorded
|
||||
# See what's recorded (XDG location)
|
||||
cat ~/.config/librofm-downloader/download_history.json | python -m json.tool
|
||||
|
||||
# Or if using CWD-based history
|
||||
cat download_history.json | python -m json.tool
|
||||
|
||||
# Look for the ISBN of the book that's re-downloading
|
||||
|
||||
Reference in new issue
Block a user