AlexKucera 5cc3fce0a3 refactor(sync-run): add DI seams and extract helpers
Add 4 injectable parameters (session, history, reporter,
download_all_fn) to sync_run() with backward-compatible defaults.
Extract _print_verbose_config() and _resolve_history_path() helpers.
Refactor _make_download_fn() to take explicit params instead of
closing over enclosing scope.

Tests can now pass fakes via parameters instead of mock.patch.

Closes #44
2026-06-05 22:28:37 +02:00
2026-06-02 17:21:41 +02:00

librofm-downloader

Python 3.11+ License: GPL-3.0

Download owned audiobooks from your Libro.fm account — a lightweight, dependency-minimal CLI tool written in Python.

No Docker. No JVM. Just Python and go.

Features

  • Full library sync — fetches every audiobook in your Libro.fm account with automatic pagination
  • M4B + MP3 formats — downloads M4B (single file) or MP3 (ZIP parts extracted) with automatic fallback
  • Resume support — interrupted downloads pick up where they left off via .partial files
  • Cover art & PDF extras — optional download of cover images and accompanying PDFs
  • 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
  • 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
  • Parallel downloads — ThreadPoolExecutor downloads multiple books simultaneously; configurable via --workers N (default 3)

Quick Start

# 1. Install from source
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 .

# 2. Create XDG config directory
mkdir -p ~/.config/librofm-downloader

# 3. Configure
cat > ~/.config/librofm-downloader/config.yaml << 'EOF'
librofm:
  format: m4b_mp3_fallback
  output_dir: ./audiobooks
  download_extras: true
  download_covers: true
EOF

cat > ~/.config/librofm-downloader/secrets.yaml << 'EOF'
librofm:
  username: your-email@example.com
  password: your-password
EOF

# 3. Run
librofm-downloader            # default: 3 parallel workers
librofm-downloader -w 5      # 5 parallel workers
librofm-downloader --workers 1  # sequential (1 worker)

Documentation

Full documentation is available at docs/ (built with MkDocs):

Page What it covers
Quickstart Install, configure, run your first sync
Configuration Reference Every config.yaml / secrets.yaml field
Secrets Why credentials are separate, common mistakes
Path Patterns All tokens, default behavior, custom examples
Format Strategies m4b_mp3_fallback vs mp3_only vs m4b_only
CLI Usage Flags, exit codes, cron setup, TTY vs non-TTY
Troubleshooting Common errors and solutions

Format strategies

Choose how audiobooks are downloaded via the format setting in config.yaml:

Strategy Description
m4b_mp3_fallback (default) Try M4B first; fall back to MP3 if unavailable. Best for most users.
mp3_only Download MP3 ZIP parts only. For players that don't support M4B.
m4b_only Download M4B only; skip the book if unavailable. For single-file purists.

Path customization

Output paths follow a sensible default (Author/Series/Book N Title for series, Author/Title for standalones) but can be fully customized with tokens like {FIRST_AUTHOR}, {BOOK_TITLE}, {SERIES_NAME}, {ISBN}, {PUBLICATION_YEAR}, and more. See Path Patterns for details.

Comparison

This project is a lightweight Python alternative to the Kotlin-based Docker container that runs a full JVM. If you want something you can debug with standard Python tooling and run without Docker — this is it.

License

GPL-3.0. See LICENSE.md.

S
Description
Download owned audiobooks from your Libro.fm account — a lightweight, dependency-minimal CLI tool written in Python.
Readme
1.5 MiB
0 Stars 1 Watchers 0 Forks
Languages
Python 100%