A production-grade Python CLI book search and download application.
Project description
๐ BookCLI
BookCLI is a production-grade, clean-architecture command-line interface (CLI) application built in Python 3.12+. It enables you to concurrently search multiple legal book sources, intelligently rank and merge metadata, cache details locally, and safely download public domain/free books directly from the terminal with a beautiful Rich UI.
โโโโโโโ โโโโโโโ โโโโโโโ โโโ โโโ โโโโโโโโโโ โโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโ
โโโโโโโโโโโ โโโโโโ โโโโโโโโโโ โโโ โโโ โโโ
โโโโโโโโโโโ โโโโโโ โโโโโโโโโโ โโโ โโโ โโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโ โโโโโโโ โโโโโโโ โโโ โโโ โโโโโโโโโโโโโโโโโโ
Search, inspect, and legally download books
Powered by Open Library & Gutenberg
Developer - Dipesh Malla
GitHub : greycode009
๐ Key Features
- โก Concurrent Multi-Provider Search: Queries Google Books, Open Library, Project Gutenberg, and the Internet Archive concurrently using async/await handlers.
- ๐ Clean & Interactive TUI Dashboard: Launch the dashboard menu with zero arguments to browse options, review search history, access favorites, inspect cache stats, and customize app configurations.
- ๐ง Intelligent Deduplication & Ranking: Merges results from all providers using
RapidFuzzfuzzy matching on title/author strings. Automatically ranks entries based on metadata completeness and direct download availability. - ๐ Safe & Legal Downloads: Only downloads books that are explicitly public domain or marked as free by their host provider.
- โฌ HTTP Range-Resume Downloads: Supports HTTP Range headers for downloading larger books safely; auto-resumes interrupted connections with standard
Richprogress displays. - ๐ Direct OS File Integration: Automatically launch downloaded books (EPUB, PDF, TXT) inside your default OS-registered reader using standard process controls.
- ๐พ Local Caching & Offline State: Backed by a local SQLite database using
aiosqlite, providing fast offline retrieval of previously searched metadata, history logs, and favorites. - ๐ ๏ธ Flexible Configurations: Toggle providers, set custom cache TTLs, change client timeout constraints, and update default download pathways directly from the CLI or dashboard settings.
๐๏ธ Clean Architecture
The codebase adheres strictly to Clean Architecture principles to separate core services, data layers, providers, and presentation:
graph TD
User[User] -->|Interact| CLI[cli.py / TUI Dashboard]
CLI -->|Execute commands/search| SearchService[services/search.py]
CLI -->|Manage settings| ConfigService[config.py / settings.py]
CLI -->|Track queries/favs| HistoryService[services/history.py]
CLI -->|Open files| Opener[opener.py]
CLI -->|Download files| Downloader[downloader.py]
SearchService -->|Rank/De-duplicate| RankingService[services/ranking.py]
SearchService -->|Cache lookup/write| CacheService[cache.py]
SearchService -->|Concurrent requests| Providers[Providers Layer]
CacheService -->|Local database| SQLite[(SQLite: bookcli.db)]
HistoryService -->|Local database| SQLite
Providers -->|API| GoogleBooks[Google Books Provider]
Providers -->|API| OpenLibrary[Open Library Provider]
Providers -->|Scrape/Download| Gutenberg[Project Gutenberg]
Providers -->|Search/Download| InternetArchive[Internet Archive]
Directory Layout
bookcli/
โโโ database/ # Database initialization and schema migrations
โ โโโ migrations.py
โโโ providers/ # Concretely implemented API / web providers
โ โโโ base.py # Abstract base client provider
โ โโโ google_books.py
โ โโโ gutenberg.py
โ โโโ internet_archive.py
โ โโโ openlibrary.py
โโโ services/ # Pure domain services (business rules)
โ โโโ history.py # Query log tracking
โ โโโ ranking.py # Metadata scoring and deduplication (RapidFuzz)
โ โโโ search.py # Orchestrates concurrent API querying & caching
โโโ cache.py # SQLite metadata cache mechanisms
โโโ cli.py # Typer/Rich CLI interface and main interactive loop
โโโ config.py # Pydantic models for configuration and serialization
โโโ downloader.py # Async downloader with range-resume & rich progress bars
โโโ exceptions.py # Domain-specific custom exception hierarchy
โโโ opener.py # Platform-specific document launcher
โโโ settings.py # Default constants and path configuration directories
โโโ utils.py # Clean utilities (unit formatting, filenames)
๐ Installation
Ensure you have Python 3.12+ installed on your system.
-
Clone the Repository
git clone https://github.com/Greycode009/bookcli.git cd bookcli
-
Install in Editable Mode
pip install -e .
Command Execution wrappers
Once installed, the CLI tool is available globally as the book command. If the python script directory is not present on your PATH, you can use the wrappers provided in the project root:
- Windows (PowerShell/CMD):
.\book.bat <command> - Linux / macOS / Git Bash:
./book <command> - Python Direct Module:
python -m bookcli.cli <command>
๐ฎ How to Use
๐ฅ๏ธ 1. The Interactive Dashboard
Run book without arguments in an interactive terminal to enter the console dashboard:
book
This launches a complete navigation dashboard:
- ๐ Search Books: Prompts for a search query and filters, then displays search results.
- ๐ Search History: Shows list of past queries. Includes an option to clear history.
- โญ Favorite Books: Displays all favorited items with quick options to download (
d <index>), open in reader (o <index>), or remove (r <index>). - โก Metadata Cache Stats: Shows cache storage metadata sizes.
- ๐งน Clear Metadata Cache: Evicts database-cached search metadata.
- โ๏ธ Settings / Configuration: Change active settings interactively (download path, client timeouts, toggling search providers).
- Exit Dashboard.
Inline Search Explorer Actions
Inside the Search Books menu:
- Enter
<ID>to download the book (e.g.,1). - Enter
<ID> -o <path>or<ID> --output <path>to save to a custom path (e.g.,1 -o C:\downloadsor1 -o book.epub). - Enter
i <ID>to show complete details (description, pages, published year, publishers, ISBN). - Enter
f <ID>to add to favorites. - Enter
o <ID>to open a downloaded file in the OS default reader. - Enter
qto return to the main dashboard menu.
โ๏ธ 2. Direct CLI Command Reference
If you prefer to bypass the dashboard, you can invoke direct commands from your shell:
Concurrently Search Providers
book search "Clean Architecture"
Filter searches by specific parameters:
book search "Relativity" --subject "Physics"
book search "Refactoring" --author "Martin Fowler"
Export results directly to a structured file:
book search "Science" --export results.json
book search "History" --export history_books.csv
Get Detailed Information
View structured metadata cards of search entries using either a short session ID (e.g., 1, 2) from your last search or a provider-specific key (e.g., gutenberg:1342):
book info 1
Download Books Legally
Download files with async resume support and live progress bars. Custom output paths automatically resolve folder hierarchies:
# Save to default downloads folder (~/.bookcli/downloads)
book download 1
# Save to custom directory
book download 1 --output "D:\Books"
# Save to custom file path
book download 1 -o "/Users/greycode/Desktop/design_patterns.epub"
Open Files Instantly
Fire up files inside the OS default viewer:
book open 1
Manage Favorites
book favorite add 1
book favorite list
book favorite remove gutenberg:1342
Manage Cache and History
# Show cache count and storage dates
book cache stats
# Remove all cached records
book cache clear
# List past search queries
book history
Modify Settings
Show settings or update values:
# Display settings
book config
# Set default downloads directory
book config set download-dir "C:\Users\Dipesh\Downloads"
# Adjust network client timeout
book config set timeout 20
# Disable Google Books search provider
book config set provider false google-books
๐ ๏ธ Development & Testing
Running Tests
To run the project test suites (if pytest is installed in your python environment):
python -m pytest --cov=bookcli
Data Storage Directories
By default, BookCLI stores its application databases and configurations in:
- Default directory:
~/.bookcli/(resolves toC:\Users\<User>\.bookclion Windows) - Database:
~/.bookcli/bookcli.db - Settings File:
~/.bookcli/config.json - Download Path:
~/.bookcli/downloads/
You can redirect the home directory by setting the BOOKCLI_HOME environment variable.
๐ค Author
- Dipesh Malla
- GitHub: @greycode009
- Repository: https://github.com/Greycode009/bookcli
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bookcli-0.2.2.tar.gz.
File metadata
- Download URL: bookcli-0.2.2.tar.gz
- Upload date:
- Size: 36.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40d6d622aa4292fdbd228dfe1b632608f732f429ceea62d7fafdadb92e6f307b
|
|
| MD5 |
3f2372ea35c725224522ba9bce3a5e90
|
|
| BLAKE2b-256 |
6c9a8362d47273796c6bf5c0cbad6e22012bbfc620bb4ae211021b477baa8677
|
File details
Details for the file bookcli-0.2.2-py3-none-any.whl.
File metadata
- Download URL: bookcli-0.2.2-py3-none-any.whl
- Upload date:
- Size: 41.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c981765f0fb54cc26eda514bdf1d3fdf6fa5d59fd3e27829972f316ac936cf3
|
|
| MD5 |
39527b9ce4403346125700f9d3c4c6d5
|
|
| BLAKE2b-256 |
cc978408217c33e8536c1411a35e3cb8137b12d85c35af6bce8378f52296a431
|