Files
librofm-downloader/docs/html/search/search_index.json
T
AlexKucera 61543204a8 docs: add MkDocs site and polished README (closes #10)
Add 8-page documentation site with Material theme covering
quickstart, configuration, secrets, path patterns, format
strategies, CLI usage, and troubleshooting. All code snippets
verified against implementation. Rewrite README with badges,
features, quickstart, and format comparison. Build HTML to
docs/html/ with flat URLs.
2026-06-03 16:20:51 +02:00

1 line
42 KiB
JSON

{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"],"fields":{"title":{"boost":1000.0},"text":{"boost":1.0},"tags":{"boost":1000000.0}}},"docs":[{"location":"index.html","title":"librofm-downloader","text":"<p>Download owned audiobooks from your Libro.fm account \u2014 a lightweight, dependency-minimal CLI tool written in Python.</p> <p>No Docker. No JVM. Just <code>pip install</code> and go.</p>"},{"location":"index.html#features","title":"Features","text":"<ul> <li>Full library sync \u2014 fetches every audiobook in your Libro.fm account with automatic pagination</li> <li>M4B + MP3 formats \u2014 downloads M4B (single file) or MP3 (ZIP parts extracted) with automatic fallback</li> <li>Resume support \u2014 interrupted downloads pick up where they left off via <code>.partial</code> files</li> <li>Cover art &amp; PDF extras \u2014 optional download of cover images and accompanying PDFs</li> <li>Customizable output paths \u2014 token-based patterns for organizing your library on disk</li> <li>TTY-aware progress \u2014 rich progress bars in your terminal, clean log lines in cron jobs</li> <li>Download history \u2014 tracks what's been downloaded so re-runs only fetch new books</li> <li>Graceful failure isolation \u2014 one failed book doesn't stop the rest</li> </ul>"},{"location":"index.html#quick-start","title":"Quick Start","text":"<pre><code># 1. Install\npip install librofm-downloader\n\n# 2. Configure\ncat &gt; config.yaml &lt;&lt; 'EOF'\nlibrofm:\n format: m4b_mp3_fallback\n output_dir: ./audiobooks\n download_extras: true\n download_covers: true\nEOF\n\ncat &gt; secrets.yaml &lt;&lt; 'EOF'\nlibrofm:\n username: your-email@example.com\n password: your-password\nEOF\n\n# 3. Run\nlibrofm-downloader\n</code></pre> <p>See Quickstart for the full walkthrough, or jump to Configuration Reference for every option.</p>"},{"location":"cli-usage.html","title":"CLI Usage","text":"<p>Command-line interface reference for <code>librofm-downloader</code>.</p>"},{"location":"cli-usage.html#synopsis","title":"Synopsis","text":"<pre><code>librofm-downloader [OPTIONS]\n</code></pre>"},{"location":"cli-usage.html#options","title":"Options","text":"Option Short Default Description <code>--config</code> <code>config.yaml</code> Path to <code>config.yaml</code> <code>--secrets</code> <code>secrets.yaml</code> Path to <code>secrets.yaml</code> <code>--history</code> <code>download_history.json</code> Path to download history JSON file <code>-v, --verbose</code> off Print extra detail (URLs, paths, API responses) <code>--limit</code> N <code>0</code> (no limit) Maximum number of books to download"},{"location":"cli-usage.html#-verbose","title":"--verbose","text":"<p>Shows internal pipeline state at each stage:</p> <pre><code>\u2500\u2500 config \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n config: config.yaml\n secrets: secrets.yaml\n history: download_history.json\n format: m4b_mp3_fallback\n output: ./audiobooks\n extras: True\n covers: True\n user: me@example.com\n\u2500\u2500 auth \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n \u2713 authenticated\n\u2500\u2500 library \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n 47 book(s) in library\n\u2500\u2500 filtering \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n 42 already downloaded, 5 new\n \u2b07 Book Title [dim](9780743565400)[/dim]\n authors: Brandon Sanderson\n narrators: Kate Reading, Michael Kramer\n ...\n 123,456,789 bytes\n</code></pre>"},{"location":"cli-usage.html#-limit","title":"--limit","text":"<p>Cap how many books are downloaded in a single run. Useful for testing:</p> <pre><code># Download only 1 book (the first new one)\nlibrofm-downloader --limit 1\n\n# Download up to 3 books\nlibrofm-downloader --limit 3 -v\n</code></pre> <p>Books are processed in the order returned by the Libro.fm API. Already-downloaded books are filtered out before the limit is applied.</p>"},{"location":"cli-usage.html#exit-codes","title":"Exit codes","text":"Code Meaning <code>0</code> Success \u2014 all done (including \"nothing new to download\") <code>1</code> Fatal error \u2014 config problem, auth failure, or library fetch failure <code>130</code> Interrupted \u2014 user pressed Ctrl+C during downloads"},{"location":"cli-usage.html#exit-code-0-scenarios","title":"Exit code 0 scenarios","text":"<ul> <li>All new books downloaded successfully</li> <li>No new books to download (<code>All caught up!</code>)</li> <li>Some books failed but the pipeline completed (failures are reported in the summary)</li> </ul> <p>[!NOTE] Exit code 0 does not mean \"zero failures\" \u2014 it means the process ran to completion. Check the summary line for <code>failed</code> count.</p>"},{"location":"cli-usage.html#exit-code-1-scenarios","title":"Exit code 1 scenarios","text":"<pre><code># Config error\n$ librofm-downloader --config missing.yaml\nConfig error: [Errno 2] No such file or directory: 'missing.yaml'\n\n# Auth failure\n$ librofm-downloader\nAuthentication failed: Auth failed (401)\n\n# Library fetch failure\n$ librofm-downloader\nFailed to fetch library: 502 Bad Gateway\n</code></pre>"},{"location":"cli-usage.html#exit-code-130","title":"Exit code 130","text":"<pre><code>$ librofm-downloader\n^CDownload interrupted by user (Ctrl+C).\necho $?\n130\n</code></pre> <p>Partial downloads are preserved as <code>.partial</code> files and will be resumed on the next run.</p>"},{"location":"cli-usage.html#cron-setup","title":"Cron setup","text":""},{"location":"cli-usage.html#basic-daily-sync","title":"Basic daily sync","text":"<pre><code># m h dom mon dow command\n0 4 * * * cd /path/to/librofm-downloader &amp;&amp; .venv/bin/librofm-downloader &gt;&gt; /var/log/librofm.log 2&gt;&amp;1\n</code></pre> <p>Runs every day at 4:00 AM, appends output to a log file.</p>"},{"location":"cli-usage.html#with-email-on-failure","title":"With email on failure","text":"<pre><code>0 4 * * * cd /path/to/librofm-downloader &amp;&amp; .venv/bin/librofm-downloader || echo \"librofm-downloader failed\" | mail -s \"DL failure\" you@example.com\n</code></pre>"},{"location":"cli-usage.html#weekly-with-limit","title":"Weekly with limit","text":"<pre><code>0 3 * * 1 cd /path/to/librofm-downloader &amp;&amp; .venv/bin/librofm-downloader --limit 10 &gt;&gt; /var/log/librofm-weekly.log 2&gt;&amp;1\n</code></pre> <p>Runs Mondays at 3:00 AM, caps at 10 books.</p>"},{"location":"cli-usage.html#systemd-timer-alternative-to-cron","title":"systemd timer (alternative to cron)","text":"<pre><code># /etc/systemd/system/librofm-downloader.service\n[Unit]\nDescription=Libro.fm Audiobook Downloader\nAfter=network-online.target\n\n[Service]\nType=oneshot\nWorkingDirectory=/path/to/librofm-downloader\nExecStart=/path/to/librofm-downloader/.venv/bin/librofm-downloader\n\n# /etc/systemd/system/librofm-downloader.timer\n[Unit]\nDescription=Run librofm-downloader daily\n\n[Timer]\nOnCalendar=daily\nPersistent=true\n\n[Install]\nWantedBy=timers.target\n</code></pre> <pre><code>systemctl enable --now librofm-downloader.timer\njournalctl -u librofm-downloader -f\n</code></pre>"},{"location":"cli-usage.html#tty-vs-non-tty-output","title":"TTY vs non-TTY output","text":"<p>The tool auto-detects whether stdout is a terminal:</p>"},{"location":"cli-usage.html#tty-interactive-terminal","title":"TTY (interactive terminal)","text":"<ul> <li>Rich progress bars with percentage, transfer speed, ETA, and size</li> <li>Color-coded results (\u2713 green, \u2717 red, \u23ed yellow)</li> <li>Progress bars update in-place (no scrolling flood)</li> </ul> <pre><code>Brandon Sanderson - The Way of Kings \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 67.3% 2.1 MB/s 00:03 45.2 MB\n</code></pre>"},{"location":"cli-usage.html#non-tty-cron-pipe-redirect","title":"Non-TTY (cron, pipe, redirect)","text":"<ul> <li>Plain text log lines \u2014 one per event</li> <li>No color, no progress bar updates</li> <li>Same information, machine-friendly format</li> </ul> <pre><code>Downloading: Brandon Sanderson - The Way of Kings (unknown size)\nCompleted: Brandon Sanderson - The Way of Kings\nSummary: 1 downloaded, 0 skipped, 0 failed\n</code></pre> <p>This means you get nice progress in your terminal and clean logs in cron \u2014 no flags needed.</p>"},{"location":"configuration.html","title":"Configuration Reference","text":"<p>Complete reference for <code>config.yaml</code> and <code>secrets.yaml</code>.</p>"},{"location":"configuration.html#file-locations","title":"File locations","text":"<p>The CLI looks for these files in the current working directory by default:</p> <pre><code>librofm-downloader --config config.yaml --secrets secrets.yaml\n</code></pre> <p>Both files share the same top-level key: <code>librofm</code>.</p>"},{"location":"configuration.html#secretsyaml","title":"secrets.yaml","text":"<p>Credentials only. This file must not be committed to version control.</p> Field Type Required Description <code>username</code> <code>string</code> \u2705 Your Libro.fm account email <code>password</code> <code>string</code> \u2705 Your Libro.fm password <pre><code>librofm:\n username: your-email@example.com\n password: your-password\n</code></pre> <p>[!IMPORTANT] Only <code>username</code> and <code>password</code> belong in this file. All other settings go in <code>config.yaml</code>. If either field is missing, the tool exits with code 1 and an error message.</p>"},{"location":"configuration.html#configyaml","title":"config.yaml","text":"<p>All non-credential settings. Safe to commit.</p> Field Type Default Description <code>format</code> <code>string</code> <code>\"m4b_mp3_fallback\"</code> Audio download strategy. See Format Strategies. <code>output_dir</code> <code>string</code> <code>\"./audiobooks\"</code> Base directory for downloaded files. Relative paths resolve from CWD. <code>download_extras</code> <code>boolean</code> <code>true</code> Download PDF extras (e.g., maps) when available. <code>download_covers</code> <code>boolean</code> <code>true</code> Download cover art (JPEG/PNG) when available."},{"location":"configuration.html#full-example","title":"Full example","text":"<pre><code>librofm:\n format: m4b_mp3_fallback\n output_dir: ./audiobooks\n download_extras: true\n download_covers: true\n</code></pre>"},{"location":"configuration.html#minimal-example","title":"Minimal example","text":"<p>Only <code>format</code> is meaningful here \u2014 everything else has a default:</p> <pre><code>librofm:\n format: mp3_only\n</code></pre>"},{"location":"configuration.html#how-merging-works","title":"How merging works","text":"<p><code>config.yaml</code> and <code>secrets.yaml</code> are deep-merged at startup:</p> <ol> <li><code>config.yaml</code> is loaded as the base</li> <li><code>secrets.yaml</code> is layered on top (overrides on conflict)</li> <li>The merged result is validated</li> </ol> <p>This means you could theoretically put any field in either file \u2014 but credentials in <code>config.yaml</code> are explicitly rejected at load time with a clear error:</p> <pre><code>Config error: Credentials (username, password) found in config.yaml.\nMove them to secrets.yaml (which is gitignored).\n</code></pre>"},{"location":"configuration.html#validation-errors","title":"Validation errors","text":"Error Cause Fix <code>Config error: Credentials (...) found in config.yaml</code> Username or password in config file Move to <code>secrets.yaml</code> <code>Missing required fields in secrets.yaml: username</code> Missing credential field Add it to <code>secrets.yaml</code> <code>Invalid format 'foo'</code> Unknown format value Use one of: <code>m4b_mp3_fallback</code>, <code>mp3_only</code>, <code>m4b_only</code>"},{"location":"configuration.html#download-history","title":"Download history","text":"<p>A third file, <code>download_history.json</code>, is created automatically on first run:</p> <pre><code>{\n \"9780743565400\": {\n \"isbn\": \"9780743565400\",\n \"title\": \"The Way of Kings\",\n \"format\": \"m4b\",\n \"path\": \"./audiobooks/Brandon Sanderson/The Way of Kings/The Way of Kings.m4b\",\n \"downloaded_at\": \"2026-06-03T10:30:00+00:00\"\n }\n}\n</code></pre> <ul> <li>Keyed by ISBN \u2014 each book is recorded once</li> <li>Used to skip already-downloaded books on subsequent runs</li> <li>Location defaults to <code>download_history.json</code> in CWD; override with <code>--history</code></li> <li>If the file is corrupt or missing, the tool starts with an empty history (and logs a warning)</li> </ul>"},{"location":"format-strategies.html","title":"Format Strategies","text":"<p>librofm-downloader supports three audio format strategies, controlled by the <code>format</code> field in <code>config.yaml</code>.</p>"},{"location":"format-strategies.html#overview","title":"Overview","text":"Strategy Behavior Best for <code>m4b_mp3_fallback</code> Try M4B first; fall back to MP3 if unavailable Default \u2014 maximum compatibility <code>mp3_only</code> Download MP3 ZIP only (skip M4B entirely) Players that don't support M4B <code>m4b_only</code> Download M4B only; skip book if unavailable Audiobook apps that prefer M4B"},{"location":"format-strategies.html#m4b_mp3_fallback-default","title":"m4b_mp3_fallback (default)","text":"<p>The recommended strategy for most users.</p> <pre><code>librofm:\n format: m4b_mp3_fallback\n</code></pre> <p>Flow:</p> <ol> <li>Request the M4B download URL from Libro.fm API</li> <li>If available \u2192 download as a single <code>.m4b</code> file</li> <li>If the API returns 404 \u2192 fall back to fetching the MP3 manifest</li> <li>Download all MP3 ZIP parts and extract them</li> </ol> <p>What you get:</p> <ul> <li>Most books: one <code>.m4b</code> file (AAC/ALAC audio, bookmarkable, chapter markers)</li> <li>Older or region-locked books: extracted MP3 files (one or more per book)</li> <li>No books are skipped \u2014 every downloadable title is fetched in some format</li> </ul> <p>Output examples:</p> <pre><code># M4B succeeded\naudiobooks/Brandon Sanderson/The Way of Kings.m4b # single file, ~450 MB\n\n# Fell back to MP3\naudiobooks/Some Author/Old Book/ # directory with MP3s\n\u251c\u2500\u2500 part1.mp3\n\u251c\u2500\u2500 part2.mp3\n\u2514\u2500\u2500 part3.mp3\n</code></pre>"},{"location":"format-strategies.html#mp3_only","title":"mp3_only","text":"<p>Skip M4B entirely and always use the MP3 ZIP pipeline.</p> <pre><code>librofm:\n format: mp3_only\n</code></pre> <p>Flow:</p> <ol> <li>Fetch the MP3 download manifest from Libro.fm API</li> <li>Download each ZIP part listed in the manifest</li> <li>Extract all files into the output directory</li> </ol> <p>When to use this:</p> <ul> <li>Your media player doesn't support M4B/M4A containers</li> <li>You want raw MP3 files for editing or conversion</li> <li>You're feeding files into a system that only accepts MP3</li> </ul> <p>Output: Always a directory with extracted MP3 files:</p> <pre><code>audiobooks/Brandon Sanderson/The Way of Kings/\n\u251c\u2500\u2500 part1.mp3\n\u251c\u2500\u2500 part2.mp3\n\u2514\u2500\u2500 ...\n</code></pre>"},{"location":"format-strategies.html#m4b_only","title":"m4b_only","text":"<p>Only attempt M4B download. Skip books where M4B is not available.</p> <pre><code>librofm:\n format: m4b_only\n</code></pre> <p>Flow:</p> <ol> <li>Request the M4B download URL from Libro.fm API</li> <li>If available \u2192 download as a single <code>.m4b</code> file</li> <li>If the API returns 404 \u2192 log a skip message, move to next book</li> </ol> <p>When to use this:</p> <ul> <li>You only want single-file audiobooks (cleaner library management)</li> <li>Your audiobook app (Apple Books, etc.) handles M4B natively</li> <li>You'd rather miss a book than get split MP3 files</li> </ul> <p>Output example:</p> <pre><code># Success\naudiobooks/Brandon Sanderson/The Way of Kings.m4b\n\n# Skipped (shows in summary)\nSummary: 5 downloaded, 2 skipped, 0 failed\n Skipped:\n \u23ed Some Author - Old Book [9781234567890]\n</code></pre>"},{"location":"format-strategies.html#how-to-choose","title":"How to choose","text":"<pre><code>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\u2502\n\u2502 Want every book? \u2502 \u2192 m4b_mp3_fallback (default) \u2502\n\u2502 Only need MP3? \u2502 \u2192 mp3_only \u2502\n\u2502 Single-file or nothing? \u2502 \u2192 m4b_only \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n</code></pre>"},{"location":"format-strategies.html#technical-details","title":"Technical details","text":""},{"location":"format-strategies.html#m4b-downloads","title":"M4B downloads","text":"<ul> <li>Single HTTP stream with 8 MB chunk buffering</li> <li>Written to <code>{title}.m4b.partial</code> during transfer</li> <li>Atomic rename to final <code>.m4b</code> on completion</li> <li>Supports resume: if a <code>.partial</code> file exists, sends <code>Range</code> header to continue</li> <li>Progress reporting via <code>Content-Length</code> header (% complete, speed, ETA)</li> </ul>"},{"location":"format-strategies.html#mp3-downloads","title":"MP3 downloads","text":"<ul> <li>Fetches a manifest (<code>/api/v10/download-manifest?isbn=...</code>) listing ZIP part URLs</li> <li>Each part is downloaded as a <code>.zip.partial</code> file, then renamed to <code>.zip</code></li> <li>ZIP contents are extracted into the output directory</li> <li>The ZIP file is deleted after extraction</li> <li>Each part supports resume via <code>Range</code> headers</li> <li>Parts are downloaded sequentially within each book</li> </ul>"},{"location":"path-patterns.html","title":"Path Patterns","text":"<p>How librofm-downloader organizes files on disk, and how to customize the layout with tokens.</p>"},{"location":"path-patterns.html#default-behavior","title":"Default behavior","text":"<p>When no custom pattern is set, the output path is determined by conditional logic based on whether a book belongs to a series:</p>"},{"location":"path-patterns.html#standalone-book-no-series","title":"Standalone book (no series)","text":"<pre><code>{FIRST_AUTHOR}/{BOOK_TITLE}\n</code></pre> <p>Example: <code>Brandon Sanderson/The Way of Kings.m4b</code></p>"},{"location":"path-patterns.html#book-in-a-series-with-series-number","title":"Book in a series (with series number)","text":"<pre><code>{FIRST_AUTHOR}/{SERIES_NAME}/Book {SERIES_NUM} {BOOK_TITLE}\n</code></pre> <p>Example: <code>Brandon Sanderson/Stormlight Archive/Book 1 The Way of Kings.m4b</code></p>"},{"location":"path-patterns.html#book-in-a-series-no-series-number","title":"Book in a series (no series number)","text":"<pre><code>{FIRST_AUTHOR}/{SERIES_NAME}/{BOOK_TITLE}\n</code></pre> <p>Example: <code>J.K. Rowling/Harry Potter/Harry Potter and the Sorcerer's Stone.m4b</code></p>"},{"location":"path-patterns.html#subdirectory-logic","title":"Subdirectory logic","text":"<p>A book gets its own subdirectory when any of these are true:</p> <ul> <li>The book has PDF extras available (<code>pdf_extras: true</code>)</li> <li><code>download_covers: true</code> and the book has a cover URL</li> </ul> <p>Otherwise the audio file sits directly under the author directory as a flat file.</p>"},{"location":"path-patterns.html#available-tokens","title":"Available tokens","text":"<p>Use these inside <code>{TOKEN}</code> placeholders in a custom pattern:</p> Token Source Example value Notes <code>{FIRST_AUTHOR}</code> First item in authors list <code>Brandon Sanderson</code> Empty if no authors <code>{ALL_AUTHORS}</code> Authors joined by <code>,</code> <code>Sanderson, Brandon</code> Empty if no authors <code>{SERIES_NAME}</code> Series name <code>Stormlight Archive</code> Empty string if not in a series <code>{SERIES_NUM}</code> Series position integer <code>1</code> Empty if not in a series or no number <code>{BOOK_TITLE}</code> Book title <code>The Way of Kings</code> Sanitized for filesystem safety <code>{ISBN}</code> ISBN identifier <code>9780743565400</code> As returned by the API <code>{FIRST_NARRATOR}</code> First narrator <code>Kate Reading</code> Empty if no narrators <code>{ALL_NARRATORS}</code> Narrators joined by <code>,</code> <code>Kate Reading, Michael Kramer</code> Empty if no narrators <code>{PUBLICATION_YEAR}</code> Year published <code>2024</code> Empty if unknown <code>{PUBLICATION_MONTH}</code> Month published <code>8</code> Empty if unknown <code>{PUBLICATION_DAY}</code> Day published <code>15</code> Empty if unknown"},{"location":"path-patterns.html#custom-patterns","title":"Custom patterns","text":"<p>To override the default conditional logic, set a <code>path_pattern</code> key in your config:</p> <pre><code>librofm:\n format: m4b_mp3_fallback\n output_dir: ./audiobooks\n path_pattern: \"{PUBLICATION_YEAR}/{FIRST_AUTHOR} - {BOOK_TITLE}\"\n</code></pre> <p>This would produce paths like:</p> <pre><code>./audiobooks/2024/Brandon Sanderson - The Way of Kings.m4b\n./audiobooks/2023/Suzanne Collins - The Hunger Games.m4b\n</code></pre> <p>[!NOTE] Custom patterns are applied via regex substitution (<code>{TOKEN_NAME}</code> \u2192 value). Unknown tokens resolve to empty strings \u2014 no error is raised. Each path component is sanitized (colons replaced, illegal chars stripped, capped at 255 chars).</p>"},{"location":"path-patterns.html#pattern-examples","title":"Pattern examples","text":""},{"location":"path-patterns.html#flat-by-author","title":"Flat by author","text":"<pre><code>path_pattern: \"{ALL_AUTHORS}/{BOOK_TITLE}\"\n</code></pre> <p>Output: <pre><code>audiobooks/Sanderson, Brandon/The Way of Kings.m4b\naudiobooks/Collins, Suzanne/The Hunger Games.m4b\n</code></pre></p>"},{"location":"path-patterns.html#organized-by-series","title":"Organized by series","text":"<pre><code>path_pattern: \"{FIRST_AUTHOR}/{SERIES_NAME}/{SERIES_NUM:03d} - {BOOK_TITLE}\"\n</code></pre> <p>Output: <pre><code>audiobooks/Brandon Sanderson/Stormlight Archive/001 - The Way of Kings.m4b\naudiobooks/Brandon Sanderson/Mistborn/001 - The Final Empire.m4b\n</code></pre></p> <p>[!WARNING] Python format specs like <code>:03d</code> are not supported \u2014 tokens produce plain strings only. Use <code>{SERIES_NUM}</code> directly; it will render as <code>1</code>, <code>2</code>, etc.</p>"},{"location":"path-patterns.html#by-narrator","title":"By narrator","text":"<pre><code>path_pattern: \"{FIRST_NARRATOR}/{BOOK_TITLE}\"\n</code></pre> <p>Output: <pre><code>audiobooks/Kate Reading/The Way of Kings.m4b\n</code></pre></p>"},{"location":"path-patterns.html#iso-style-date-prefix","title":"ISO-style date prefix","text":"<pre><code>path_pattern: \"{PUBLICATION_YEAR}-{PUBLICATION_MONTH}-{PUBLICATION_DAY}/{FIRST_AUTHOR}/{BOOK_TITLE}\"\n</code></pre> <p>Output: <pre><code>audiobooks/2024-8-15/Brandon Sanderson/The Way of Kings.m4b\n</code></pre></p>"},{"location":"path-patterns.html#path-sanitization","title":"Path sanitization","text":"<p>Every path component goes through sanitization before being written to disk:</p> <ol> <li>Colons (<code>:</code>) \u2192 replaced with <code>-</code></li> <li>Illegal characters <code>&lt; &gt; / \\ | ? *</code> \u2192 stripped</li> <li>Control characters (U+0000\u2013U+001F) \u2192 stripped</li> <li>Trailing dots \u2192 removed</li> <li>Whitespace \u2192 trimmed</li> <li>Length \u2192 capped at 255 characters</li> </ol> <p>Preserved characters include dashes, commas, apostrophes, parentheses, and non-trailing periods.</p>"},{"location":"quickstart.html","title":"Quickstart","text":"<p>Get librofm-downloader installed, configured, and running in three steps.</p>"},{"location":"quickstart.html#1-install","title":"1. Install","text":""},{"location":"quickstart.html#from-pypi-recommended","title":"From PyPI (recommended)","text":"<pre><code>pip install librofm-downloader\n</code></pre> <p>Requires Python 3.11+.</p>"},{"location":"quickstart.html#from-source","title":"From source","text":"<pre><code>git clone https://github.com/AlexKucera/librofm-downloader.git\ncd librofm-downloader\npython -m venv .venv\nsource .venv/bin/activate # or .venv\\Scripts\\activate on Windows\npip install -e \".[dev]\"\n</code></pre> <p>The <code>[dev]</code> extra installs pytest for testing \u2014 omit it if you only want to run the tool.</p>"},{"location":"quickstart.html#2-configure","title":"2. Configure","text":"<p>librofm-downloader uses two YAML files:</p> File Purpose Committed to git? <code>config.yaml</code> Preferences (format, output dir, toggles) \u2705 Yes <code>secrets.yaml</code> Credentials only \u274c No (gitignored)"},{"location":"quickstart.html#configyaml","title":"config.yaml","text":"<pre><code># libro.fm downloader configuration\n# This file is safe to commit \u2014 no credentials here.\n# Credentials go in secrets.yaml (which is gitignored).\n\nlibrofm:\n # Audio format preference:\n # m4b_mp3_fallback \u2014 try M4B first, fall back to MP3 ZIP (default)\n # mp3_only \u2014 download MP3 ZIP only\n # m4b_only \u2014 download M4B only, skip if unavailable\n format: m4b_mp3_fallback\n\n # Where downloaded audiobooks are saved\n output_dir: ./audiobooks\n\n # Whether to download PDF extras when available\n download_extras: true\n\n # Whether to download cover art when available\n download_covers: true\n</code></pre>"},{"location":"quickstart.html#secretsyaml","title":"secrets.yaml","text":"<pre><code>librofm:\n username: your-email@example.com\n password: your-password\n</code></pre> <p>[!WARNING] Never commit <code>secrets.yaml</code>. It is listed in <code>.gitignore</code> by default. If you accidentally put credentials in <code>config.yaml</code>, the tool will refuse to start and tell you to move them.</p>"},{"location":"quickstart.html#3-run","title":"3. Run","text":""},{"location":"quickstart.html#basic-sync","title":"Basic sync","text":"<pre><code>librofm-downloader\n</code></pre> <p>This:</p> <ol> <li>Loads <code>config.yaml</code> + <code>secrets.yaml</code></li> <li>Authenticates with Libro.fm via OAuth2 password grant</li> <li>Fetches your full library (all pages)</li> <li>Skips books already in <code>download_history.json</code></li> <li>Downloads each new book with a progress bar</li> <li>Records successful downloads to history</li> </ol>"},{"location":"quickstart.html#first-run-output-tty","title":"First run output (TTY)","text":"<pre><code>3 book(s) to download:\n\nAuthor One - Book Title One \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 100.0% 2.1 MB/s 00:01 45.2 MB\n \u2713 Book Title One\nAuthor Two - Another Book \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 100.0% 1.8 MB/s 00:02 120.5 MB\n \u2713 Another Book\nAuthor Three - Third Book \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 100.0% 2.3 MB/s 00:00 89.1 MB\n \u2713 Third Book\n\nSummary: 3 downloaded, 0 skipped, 0 failed\n</code></pre>"},{"location":"quickstart.html#subsequent-run-nothing-new","title":"Subsequent run (nothing new)","text":"<pre><code>All caught up! No new books to download.\n</code></pre>"},{"location":"quickstart.html#cron-non-tty-output","title":"Cron / non-TTY output","text":"<p>When stdout is not a terminal (e.g., cron, piped), output switches to plain text log lines:</p> <pre><code>Downloading: Author One - Book Title One (unknown size)\nCompleted: Author One - Book Title One\nDownloading: Author Two - Another Book (unknown size)\nCompleted: Author Two - Another Book\n\nSummary: 2 downloaded, 0 skipped, 0 failed\n</code></pre>"},{"location":"quickstart.html#what-gets-downloaded","title":"What gets downloaded?","text":"<p>Files land under your <code>output_dir</code> using this structure:</p> <pre><code>audiobooks/\n\u251c\u2500\u2500 Brandon Sanderson/\n\u2502 \u251c\u2500\u2500 The Way of Kings/\n\u2502 \u2502 \u251c\u2500\u2500 The Way of Kings.m4b\n\u2502 \u2502 \u251c\u2500\u2500 cover.jpg\n\u2502 \u2502 \u2514\u2500\u2500 map.pdf\n\u2502 \u2514\u2500\u2500 Words of Radiance.m4b \u2190 no extras = flat file\n\u2514\u2500\u2500 Suzanne Collins/\n \u2514\u2500\u2500 The Hunger Games.m4b\n</code></pre> <ul> <li>Books with cover art or PDF extras get a subdirectory (<code>Author/Title/</code>)</li> <li>Books without extras are flat files (<code>Author/Title.m4b</code>)</li> <li>See Path Patterns for customization options</li> </ul>"},{"location":"quickstart.html#next-steps","title":"Next steps","text":"<ul> <li>Configuration Reference \u2014 every field documented</li> <li>Format Strategies \u2014 choose the right mode for your setup</li> <li>CLI Usage \u2014 all flags, exit codes, cron examples</li> <li>Troubleshooting \u2014 common problems and solutions</li> </ul>"},{"location":"secrets.html","title":"Secrets","text":"<p>Why <code>secrets.yaml</code> exists, how it works, and common mistakes to avoid.</p>"},{"location":"secrets.html#purpose","title":"Purpose","text":"<p>Libro.fm authentication requires your email and password. These are stored in a separate file from your regular configuration so you can safely commit <code>config.yaml</code> to version control without leaking credentials.</p>"},{"location":"secrets.html#file-format","title":"File format","text":"<pre><code>librofm:\n username: your-email@example.com\n password: your-password\n</code></pre> <p>Two fields, both required, both strings. That's it.</p>"},{"location":"secrets.html#why-its-gitignored","title":"Why it's gitignored","text":"<p>The <code>.gitignore</code> entry:</p> <pre><code>secrets.yaml\n</code></pre> <p>This is set up by default in the project template. If you clone the repo and create <code>secrets.yaml</code>, Git will never track it.</p>"},{"location":"secrets.html#common-mistakes","title":"Common mistakes","text":""},{"location":"secrets.html#1-putting-credentials-in-configyaml","title":"1. Putting credentials in config.yaml","text":"<p>If you accidentally add <code>username</code> or <code>password</code> to <code>config.yaml</code>:</p> <pre><code># \u274c Wrong \u2014 config.yaml\nlibrofm:\n username: me@example.com # &lt;-- this will be rejected\n password: secret # &lt;-- this will be rejected\n format: m4b_mp3_fallback\n</code></pre> <p>The tool refuses to start:</p> <pre><code>Config error: Credentials (username, password) found in config.yaml.\nMove them to secrets.yaml (which is gitignored).\n</code></pre> <p>Fix: Remove those lines from <code>config.yaml</code> and put them in <code>secrets.yaml</code>.</p>"},{"location":"secrets.html#2-committing-before-gitignore","title":"2. Committing before gitignore","text":"<p>If you <code>git add secrets.yaml</code> before the <code>.gitignore</code> rule was added, Git may already be tracking it:</p> <pre><code># Check if Git is tracking it\ngit ls-files | grep secrets.yaml\n\n# If it shows up, remove it from tracking (keeps local file)\ngit rm --cached secrets.yaml\ngit commit -m \"Stop tracking secrets.yaml\"\n</code></pre>"},{"location":"secrets.html#3-missing-fields","title":"3. Missing fields","text":"<p>If <code>secrets.yaml</code> exists but is missing <code>username</code> or <code>password</code>:</p> <pre><code>Missing required fields in secrets.yaml: username, password.\nAdd them to your secrets.yaml file.\n</code></pre> <p>Both fields are required \u2014 there are no defaults for credentials.</p>"},{"location":"secrets.html#4-wrong-indentation","title":"4. Wrong indentation","text":"<p>YAML is whitespace-sensitive. The <code>librofm:</code> key must be at column 0, and <code>username</code>/<code>password</code> must be indented with exactly 2 spaces:</p> <pre><code># \u2705 Correct\nlibrofm:\n username: me@example.com\n password: secret\n\n# \u274c Wrong \u2014 no indentation\nlibrofm:\nusername: me@example.com\npassword: secret\n\n# \u274c Wrong \u2014 wrong key name (not under librofm:)\nusername: me@example.com\npassword: secret\n</code></pre>"},{"location":"secrets.html#security-notes","title":"Security notes","text":"<ul> <li>The password is stored in plaintext on disk \u2014 this is a CLI tool for personal use, not a multi-user service</li> <li>The password is sent to Libro.fm's OAuth2 token endpoint over HTTPS; it is never logged or transmitted elsewhere</li> <li>If your Libro.fm account has 2FA enabled, you may need an app-specific password depending on how Libro.fm handles OAuth2 password grants</li> <li>Never share your <code>secrets.yaml</code> file \u2014 if you do, rotate your Libro.fm password immediately</li> </ul>"},{"location":"troubleshooting.html","title":"Troubleshooting","text":"<p>Common errors, their causes, and how to fix them.</p>"},{"location":"troubleshooting.html#authentication-failures","title":"Authentication failures","text":""},{"location":"troubleshooting.html#authentication-failed-auth-failed-401","title":"\"Authentication failed: Auth failed (401)\"","text":"<p>Cause: Wrong email or password in <code>secrets.yaml</code>.</p> <p>Fix:</p> <ol> <li>Verify you can log in to libro.fm in a browser with the same credentials</li> <li>Check for typos in <code>secrets.yaml</code> (YAML is case-sensitive)</li> <li>If you changed your Libro.fm password recently, update <code>secrets.yaml</code></li> </ol>"},{"location":"troubleshooting.html#authentication-failed-auth-failed-xxx-non-401","title":"\"Authentication failed: Auth failed (xxx)\" (non-401)","text":"<p>Cause: Network issue or Libro.fm API temporarily down.</p> <p>Fix:</p> <ol> <li>Check your internet connection</li> <li>Try again in a few minutes</li> <li>Check Libro.fm status if available</li> </ol>"},{"location":"troubleshooting.html#configuration-errors","title":"Configuration errors","text":""},{"location":"troubleshooting.html#config-error-credentials-found-in-configyaml","title":"\"Config error: Credentials (...) found in config.yaml\"","text":"<p>Cause: You put <code>username</code> or <code>password</code> in <code>config.yaml</code> instead of <code>secrets.yaml</code>.</p> <p>Fix: Remove those lines from <code>config.yaml</code>. They belong only in <code>secrets.yaml</code>. See Secrets.</p>"},{"location":"troubleshooting.html#missing-required-fields-in-secretsyaml-username","title":"\"Missing required fields in secrets.yaml: username\"","text":"<p>Cause: <code>secrets.yaml</code> is missing a required field.</p> <p>Fix: Add both <code>username</code> and <code>password</code> under the <code>librofm:</code> key:</p> <pre><code>librofm:\n username: your-email@example.com\n password: your-password\n</code></pre>"},{"location":"troubleshooting.html#invalid-format-xyz","title":"\"Invalid format 'xyz'\"","text":"<p>Cause: The <code>format</code> value in <code>config.yaml</code> is not one of the three valid strategies.</p> <p>Fix: Use one of:</p> <ul> <li><code>m4b_mp3_fallback</code></li> <li><code>mp3_only</code></li> <li><code>m4b_only</code></li> </ul>"},{"location":"troubleshooting.html#errno-2-no-such-file-or-directory-configyaml","title":"\"[Errno 2] No such file or directory: 'config.yaml'\"","text":"<p>Cause: The config file doesn't exist at the specified path (default: current directory).</p> <p>Fix:</p> <pre><code># Run from the directory that contains config.yaml\ncd /path/to/your/project\n\n# Or specify the path explicitly\nlibrofm-downloader --config /path/to/config.yaml --secrets /path/to/secrets.yaml\n</code></pre>"},{"location":"troubleshooting.html#download-issues","title":"Download issues","text":""},{"location":"troubleshooting.html#download-stops-partway-through","title":"Download stops partway through","text":"<p>Cause: Network interruption, timeout, or you pressed Ctrl+C.</p> <p>Behavior: - Exit code 130 if Ctrl+C - Partial file saved as <code>{filename}.m4b.partial</code> or <code>{filename}.zip.partial</code></p> <p>Fix \u2014 resume on next run: The tool automatically detects <code>.partial</code> files and sends an HTTP <code>Range</code> header to resume from where it stopped. Just run again:</p> <pre><code>librofm-downloader\n</code></pre>"},{"location":"troubleshooting.html#failed-author-title-isbn-connection-error","title":"\"Failed: Author - Title [ISBN] (connection error)\"","text":"<p>Cause: Intermittent network failure during a single book's download.</p> <p>Behavior: - That book is marked as failed in the summary - All other books continue downloading normally - Exit code is still 0 (pipeline completed)</p> <p>Fix: Run again \u2014 the failed book will be retried (it wasn't recorded in history since it didn't complete):</p> <pre><code>$ librofm-downloader\nSummary: 0 downloaded, 0 skipped, 1 failed\n Failed:\n \u2717 Brandon Sanderson - The Way of Kings [9780743565400] (connection error)\n\n# Run again \u2014 it will retry the failed book\n$ librofm-downloader\n</code></pre>"},{"location":"troubleshooting.html#book-shows-as-skipped-with-m4b_only-mode","title":"Book shows as skipped with m4b_only mode","text":"<p>Cause: The book has no M4B format available from Libro.fm (API returns 404).</p> <p>Behavior: - Book appears under <code>Skipped:</code> in summary - Not written to download history</p> <p>Fix options: - Switch to <code>m4b_mp3_fallback</code> to get the MP3 version instead - Accept that some books aren't available in M4B format</p>"},{"location":"troubleshooting.html#history-file-problems","title":"History file problems","text":""},{"location":"troubleshooting.html#corrupt-history-file-download_historyjson-starting-with-empty-history","title":"\"Corrupt history file download_history.json: ... Starting with empty history.\"","text":"<p>Cause: The <code>download_history.json</code> file exists but contains invalid JSON.</p> <p>Behavior: - Tool starts with empty history (all books appear as \"new\") - Already-downloaded books will be re-downloaded</p> <p>Fix:</p> <pre><code># Option 1: Delete and let it rebuild\nrm download_history.json\nlibrofm-downloader\n\n# Option 2: Fix the JSON manually (if you know what's in there)\n# Check for trailing commas, missing braces, etc.\n</code></pre>"},{"location":"troubleshooting.html#books-re-downloading-after-already-being-downloaded","title":"Books re-downloading after already being downloaded","text":"<p>Cause: The ISBN in the library response doesn't match what's stored in history.</p> <p>Check:</p> <pre><code># See what's recorded\ncat download_history.json | python -m json.tool\n\n# Look for the ISBN of the book that's re-downloading\n</code></pre> <p>Possible reasons: - The book was re-published under a new ISBN - History file was deleted or moved - You're running from a different directory with a different history file</p>"},{"location":"troubleshooting.html#output-path-issues","title":"Output / path issues","text":""},{"location":"troubleshooting.html#files-going-to-wrong-directory","title":"Files going to wrong directory","text":"<p>Cause: <code>output_dir</code> setting or CWD mismatch.</p> <p>Check:</p> <pre><code># Verify your config\ngrep output_dir config.yaml\n\n# Check where you're running from\npwd\n\n# Use absolute paths to avoid ambiguity\nlibrofm-downloader --config /absolute/path/to/config.yaml\n</code></pre>"},{"location":"troubleshooting.html#permission-denied-when-writing-files","title":"\"Permission denied\" when writing files","text":"<p>Cause: The user running the tool doesn't have write access to <code>output_dir</code>.</p> <p>Fix:</p> <pre><code># Check permissions\nls -la ./audiobooks/\n\n# Fix ownership or choose a writable directory\nchmod u+w ./audiobooks/\n# or set output_dir to somewhere writable in config.yaml\n</code></pre>"},{"location":"troubleshooting.html#performance","title":"Performance","text":""},{"location":"troubleshooting.html#downloads-are-slow","title":"Downloads are slow","text":"<p>Check:</p> <ol> <li>Your internet connection speed</li> <li>Whether a VPN/proxy is adding latency</li> <li>Libro.fm CDN responsiveness (varies by region)</li> </ol> <p>The tool downloads in a single stream per book (no parallelism within one book), but processes books sequentially. There is no built-in rate limiting or parallel download feature.</p>"},{"location":"troubleshooting.html#large-library-takes-a-long-time","title":"Large library takes a long time","text":"<p>Audiobooks are large (200 MB \u2013 1 GB each). A library of 50 books at 2 MB/s would take ~7 hours just for transfer time. This is expected behavior.</p> <p>Use <code>--limit</code> to process smaller batches:</p> <pre><code># Download 5 books at a time\nlibrofm-downloader --limit 5\n</code></pre>"},{"location":"troubleshooting.html#getting-help","title":"Getting help","text":"<p>If none of the above covers your issue:</p> <ol> <li>Run with <code>-v</code> (<code>--verbose</code>) to get detailed output including URLs and tracebacks</li> <li>Check the GitHub Issues for known problems</li> <li>Open a new issue with:</li> <li>The error message (from <code>-v</code> output)</li> <li>Your <code>format</code> setting</li> <li>Whether it happens on every book or specific ones</li> <li>Your OS and Python version (<code>python --version</code>)</li> </ol>"}]}