A powerful CLI tool for managing audiobook libraries via Audiobookshelf and Audible APIs
Features β’ Quick Start β’ Usage β’ Architecture β’ Security β’ Contributing
Analyze audio quality β’ Find upgrade candidates β’ Enrich with Audible metadata β’ Track series completion
|
Analyze audio quality (bitrate, codec, format) across your entire library with intelligent tier classification. Identify low-quality audiobooks and find matching Audible versions with pricing data. Seamless authentication, library access, catalog search, and metadata enrichment. |
Track series completion, find missing books, and match ABS series with Audible catalogs. SQLite-based caching with TTL and namespaces to minimize API calls and speed up operations. Beautiful terminal output with progress bars, styled tables, spinners, and visual feedback. |
| Requirement | Version | Notes |
|---|---|---|
| Python | 3.12+ | Tested on 3.12 and 3.13 |
| Audiobookshelf | Any | Self-hosted audiobook server |
| Audible Account | β | For enrichment features |
| mediainfo | Any | System package for audio analysis |
# Clone and setup
git clone https://github.com/H2OKing89/a2a.git && cd a2a
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
# Configure
cp config.yaml.example config.yaml
# Edit config.yaml with your ABS URL and API key
# Verify connection
python cli.py statusπ¦ Detailed Installation
git clone https://github.com/H2OKing89/a2a.git
cd a2apython -m venv .venv
source .venv/bin/activate # Linux/macOS
# or
.venv\Scripts\activate # Windows# Production only
make install
# With development tools
make install-dev# Ubuntu/Debian
sudo apt install mediainfo
# macOS
brew install mediainfo
# Arch Linux
sudo pacman -S mediainfoCopy the example configuration:
cp config.yaml.example config.yamlOr use environment variables (.env file):
ABS_URL=https://your-audiobookshelf-server:13378
ABS_API_KEY=your-api-key
AUDIBLE_AUTH_FILE=data/audible_auth.jsoncli.py
βββ status # Global status (ABS + Audible + Cache)
βββ cache # Manage unified SQLite cache
βββ abs # π Audiobookshelf commands
βββ audible # π§ Audible commands
βββ quality # π Quality analysis commands
βββ series # π Series management commandsπ Audiobookshelf (ABS)
# Check connection
python cli.py abs status
# List libraries
python cli.py abs libraries
# Browse items with filtering
python cli.py abs items <library-id> --limit 50
# Search your library
python cli.py abs search <library-id> "Harry Potter"
# View item details
python cli.py abs item <item-id>
# Export library to JSON
python cli.py abs export <library-id> -o library.json| Command | Description |
|---|---|
status |
Check ABS connection status |
libraries |
List all libraries |
stats |
Show library statistics |
items |
List library items |
item |
Show details for a specific item |
search |
Search a library |
export |
Export all library items to JSON |
authors |
List authors in the library |
series |
List series in the library |
collections |
Manage ABS collections |
π§ Audible
# Authenticate (encrypted by default)
python cli.py audible login
# Check status and encryption
python cli.py audible status
# Browse your library
python cli.py audible library --limit 20
# Search Audible catalog
python cli.py audible search "Brandon Sanderson"
# View listening stats
python cli.py audible stats
# Get recommendations
python cli.py audible recommendations| Command | Description |
|---|---|
login |
Login to Audible and save credentials |
encrypt |
Encrypt existing Audible credentials |
status |
Check connection and encryption status |
library |
List your Audible library |
item |
Show details for an audiobook by ASIN |
search |
Search the Audible catalog |
export |
Export full library to JSON |
wishlist |
Manage your Audible wishlist |
stats |
Show listening statistics |
recommendations |
Show personalized recommendations |
π Quality Analysis
# Scan library for quality metrics
python cli.py quality scan <library-id>
# Find low-quality items (below threshold)
python cli.py quality low <library-id> --threshold 128
# Analyze single item
python cli.py quality item <item-id>
# Find upgrade candidates with Audible pricing
python cli.py quality upgrades <library-id>| Command | Description |
|---|---|
scan |
Scan library for audio quality analysis |
low |
List low quality audiobooks below threshold |
item |
Analyze quality of a specific item |
upgrades |
Find upgrade candidates with Audible pricing |
π Series Management
# List all series
python cli.py series list <library-id>
# Analyze series completion
python cli.py series analyze <library-id>A2A uses an intelligent tier system to classify audio quality:
| Tier | Icon | Criteria | Description |
|---|---|---|---|
| Excellent | π | Dolby Atmos OR 256+ kbps | Premium quality, spatial audio |
| Better | β¨ | M4B @ 128-255 kbps | High quality AAC in container |
| Good | π | M4B @ 110-127 kbps OR MP3 @ 128+ kbps | Acceptable quality |
| Low | π | M4B @ 64-109 kbps OR MP3 @ 110-127 kbps | Below recommended |
| Poor | π© | < 64 kbps OR MP3 < 110 kbps | Needs replacement |
Format Priority: M4B/M4A (AAC) > MP3 at equivalent bitrates due to codec efficiency.
src/
βββ abs/ # Audiobookshelf API client (sync + async)
βββ audible/ # Audible API client with encryption
βββ cache/ # SQLite caching layer (TTL, namespaces)
βββ cli/ # Typer CLI command modules
βββ quality/ # Audio quality analysis engine
βββ series/ # Series matching and tracking
βββ output/ # Report formatters (JSON, table, etc.)
βββ utils/ # UI helpers, sample data generation| Component | Description |
|---|---|
ABSClient |
Sync/async client for Audiobookshelf API with rate limiting |
AudibleClient |
Client for Audible API with encrypted credential storage |
QualityAnalyzer |
Audio quality tier calculation with configurable thresholds |
SeriesMatcher |
Fuzzy matching between ABS and Audible series |
SQLiteCache |
Unified caching with TTL, namespaces, and FTS support |
βββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββ
β ABS Library ββββββΆβ QualityAnalyzer ββββββΆβ AudioQuality β
βββββββββββββββ βββββββββββββββββββ ββββββββββ¬ββββββββββ
β
βββββββββββββββ βββββββββββββββββββ βΌ
β Audible ββββββΆβ EnrichmentSvc ββββββΆββββββββββββββββββββ
β Catalog β βββββββββββββββββββ β Upgrade Report β
βββββββββββββββ ββββββββββββββββββββ
|
|
# Encrypt existing credentials
python cli.py audible encrypt
# Check encryption status
python cli.py audible status
β οΈ Never commitconfig.yaml,data/audible_auth.json, or.envfiles. Use the provided.examplefiles as templates.
π Security Configuration
# config.yaml
abs:
host: https://abs.example.com
api_key: "..."
allow_insecure_http: false # Only localhost over HTTP
tls_ca_bundle: "/path/to/ca.pem" # For self-signed certs
audible:
auth_file: ./data/audible_auth.json
auth_encryption: json # Encrypted JSON format# Environment variables
export AUDIBLE_AUTH_PASSWORD="your-secure-password"
export ABS_INSECURE_TLS=1 # DANGEROUS: disable SSL verificationmake test # Run all tests
make coverage # With HTML coverage report
pytest -k "quality" # Run specific tests
pytest -v --tb=short # Verbose with short tracebacksmake format # Black + isort
make lint # flake8 + mypy + bandit
make pre-commit # Run all pre-commit hooksmake setup-hooks # Install git hooks
make update-hooks # Update to latest versionsLocated in tools/:
| Script | Purpose |
|---|---|
dev.py |
Make-like task runner for systems without make |
dev_series_explore.py |
Series matching exploration/testing |
python tools/dev.py help
python tools/dev_series_explore.py --library-id <id>a2a/
βββ .github/ # GitHub Actions, templates, Dependabot
β βββ workflows/ # CI, release, pre-commit autoupdate
β βββ ISSUE_TEMPLATE/ # Bug report, feature request forms
βββ src/ # Source code modules
βββ tests/ # Pytest test suite (577+ tests)
βββ tools/ # Developer utilities
βββ docs/ # Design docs, audit reports
βββ cli.py # Main CLI entry point
βββ config.yaml.example # Configuration template
βββ pyproject.toml # Tool configuration (pytest, black, etc.)
βββ Makefile # Common development commands
Contributions are welcome! Please read our guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Run tests and linting (
make test && make lint) - Commit with conventional commits (
feat:,fix:,docs:) - Push and open a Pull Request
See CONTRIBUTING.md for detailed guidelines and CODE_OF_CONDUCT.md for community standards.
This project is licensed under the MIT License - see LICENSE for details.
β οΈ Note: This project uses theaudiblelibrary which is licensed under AGPL-3.0. For personal CLI use, this has minimal impact. Review the license if distributing.
![]() Audiobookshelf |
audible |
Typer |
Rich |
π Report Bug β’ π‘ Request Feature β’ π Documentation
Made with β€οΈ for audiobook enthusiasts
Star β this repo if you find it useful!
