bookcli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bookcli/__init__.py +3 -0
- bookcli/cache.py +103 -0
- bookcli/cli.py +752 -0
- bookcli/config.py +72 -0
- bookcli/database/__init__.py +32 -0
- bookcli/database/migrations.py +94 -0
- bookcli/downloader.py +130 -0
- bookcli/exceptions.py +34 -0
- bookcli/models.py +23 -0
- bookcli/opener.py +32 -0
- bookcli/providers/__init__.py +1 -0
- bookcli/providers/base.py +61 -0
- bookcli/providers/google_books.py +202 -0
- bookcli/providers/gutenberg.py +211 -0
- bookcli/providers/internet_archive.py +266 -0
- bookcli/providers/openlibrary.py +256 -0
- bookcli/services/__init__.py +1 -0
- bookcli/services/history.py +69 -0
- bookcli/services/ranking.py +169 -0
- bookcli/services/search.py +96 -0
- bookcli/settings.py +28 -0
- bookcli/utils.py +30 -0
- bookcli-0.1.0.dist-info/METADATA +198 -0
- bookcli-0.1.0.dist-info/RECORD +27 -0
- bookcli-0.1.0.dist-info/WHEEL +5 -0
- bookcli-0.1.0.dist-info/entry_points.txt +2 -0
- bookcli-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bookcli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A production-grade Python CLI book search and download application.
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: typer>=0.9.0
|
|
9
|
+
Requires-Dist: rich>=13.0.0
|
|
10
|
+
Requires-Dist: httpx>=0.25.0
|
|
11
|
+
Requires-Dist: pydantic>=2.0.0
|
|
12
|
+
Requires-Dist: rapidfuzz>=3.0.0
|
|
13
|
+
Requires-Dist: aiosqlite>=0.19.0
|
|
14
|
+
|
|
15
|
+
# BookCLI
|
|
16
|
+
|
|
17
|
+
BookCLI is a production-ready, clean-architecture command-line interface application built in Python 3.12+. It allows users to search multiple legal book sources concurrently, merge and rank results dynamically using fuzzy string matching, and safely download books when legally provided by the API source.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- **Concurrent Multi-Provider Search**: Queries Google Books, Open Library, Project Gutenberg, and the Internet Archive concurrently.
|
|
24
|
+
- **Advanced Deduplication & Ranking**: Automatically filters duplicate search entries using fuzzy title and author string comparison via `RapidFuzz` and sorts results based on metadata completeness and direct download availability.
|
|
25
|
+
- **Safe & Legal Downloads**: Only attempts downloads when the source explicitly provides a free/public-domain download link.
|
|
26
|
+
- **Custom Download Paths**: Allows downloading to custom directories or specific files via CLI arguments, search explorer prompts, or global configurations.
|
|
27
|
+
- **Download Resumption**: Supports HTTP range requests to resume interrupted downloads.
|
|
28
|
+
- **Rich Terminal UI**: Displays tabular results, dynamic progress bars, speed, ETA, and styled metadata panel screens utilizing `Rich`.
|
|
29
|
+
- **Offline Mode & Metadata Caching**: Implements local caching in SQLite to preserve previously fetched results, allowing details to be checked offline.
|
|
30
|
+
- **Short Session Indexing**: Supports referring to book search results by their simple short IDs (1, 2, 3...) in follow-up commands like `info`, `download`, `open`, and `favorite`.
|
|
31
|
+
- **Search History & Favorites**: Saves queries and favorites locally.
|
|
32
|
+
- **Configurable Options**: Change default download directory, cache TTL, client timeout, and disable/enable specific providers.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Directory Architecture
|
|
37
|
+
|
|
38
|
+
The project adheres to Clean Architecture principles:
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
bookcli/
|
|
42
|
+
│
|
|
43
|
+
├── database/ # Database initialization and migrations
|
|
44
|
+
│ └── migrations.py
|
|
45
|
+
│
|
|
46
|
+
├── providers/ # API clients for external book metadata providers
|
|
47
|
+
│ ├── base.py
|
|
48
|
+
│ ├── google_books.py
|
|
49
|
+
│ ├── gutenberg.py
|
|
50
|
+
│ ├── internet_archive.py
|
|
51
|
+
│ └── openlibrary.py
|
|
52
|
+
│
|
|
53
|
+
├── services/ # Core business services
|
|
54
|
+
│ ├── history.py
|
|
55
|
+
│ ├── ranking.py
|
|
56
|
+
│ └── search.py
|
|
57
|
+
│
|
|
58
|
+
├── cache.py # SQLite metadata cache implementation
|
|
59
|
+
├── cli.py # Typer CLI application entry point and commands
|
|
60
|
+
├── config.py # Pydantic configuration loader and validator
|
|
61
|
+
├── downloader.py # Async downloader with range-resume and Rich progress
|
|
62
|
+
├── exceptions.py # Custom exceptions for uniform error handling
|
|
63
|
+
├── opener.py # OS-specific default application file opener
|
|
64
|
+
├── settings.py # Configuration defaults and directory paths
|
|
65
|
+
└── utils.py # Formatting and filename utilities
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
Ensure you have Python 3.12+ installed. Install BookCLI locally in editable mode:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/your-username/bookcli.git
|
|
76
|
+
cd bookcli
|
|
77
|
+
pip install -e .
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Once installed, the CLI tool is available globally as `book`. If the script directory is not on your PATH, you can use the provided script wrappers in the project root:
|
|
81
|
+
- On Windows (CMD/PowerShell): `.\book.bat <command>`
|
|
82
|
+
- On Unix/macOS/Git Bash: `./book <command>`
|
|
83
|
+
- Or directly via Python module: `python -m bookcli.cli <command>`
|
|
84
|
+
|
|
85
|
+
> [!NOTE]
|
|
86
|
+
> On Windows, running `.\book.bat` without any command starts the **Interactive Search Explorer** loop, which also includes a menu option to update your default download directory.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Usage
|
|
91
|
+
|
|
92
|
+
### 1. Search for Books
|
|
93
|
+
Query multiple providers concurrently. Results will display in a styled table containing short session IDs.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# General search
|
|
97
|
+
book search "Atomic Habits"
|
|
98
|
+
|
|
99
|
+
# Filtered search
|
|
100
|
+
book search "Clean Code" --author "Robert C. Martin"
|
|
101
|
+
book search "Relativity" --subject "Physics"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Interactive Explorer Mode
|
|
105
|
+
When running search inside a terminal (TTY mode), you enter an interactive prompt:
|
|
106
|
+
- Enter `i <ID>` to see details.
|
|
107
|
+
- Enter `f <ID>` to favorite a book.
|
|
108
|
+
- Enter `o <ID>` to open a downloaded book.
|
|
109
|
+
- Enter `<ID>` to download a book to your default download directory.
|
|
110
|
+
- Enter `<ID> -o <path>` or `<ID> --output <path>` to download a book to a **custom path** (e.g. `1 -o C:\downloads` or `1 -o mybook.epub`).
|
|
111
|
+
- Enter `q` to quit.
|
|
112
|
+
|
|
113
|
+
### 2. View Detailed Metadata
|
|
114
|
+
Examine pages, publishers, description, ISBN, and download status of a book by using its short index ID (from your last search) or exact provider ID.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
book info 1
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 3. Legal Download with Progress Bar
|
|
121
|
+
Download the book with a progress bar. You can choose to download to your default configured directory or specify a custom path (either a directory or exact file path).
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Download to the default configured download directory
|
|
125
|
+
book download 1
|
|
126
|
+
|
|
127
|
+
# Download to a custom directory (automatically creates it if missing)
|
|
128
|
+
book download 1 --output "/path/to/my_downloads/"
|
|
129
|
+
book download 1 -o "C:\my_downloads\"
|
|
130
|
+
|
|
131
|
+
# Download to a specific custom filename
|
|
132
|
+
book download 1 --output "/path/to/my_books/clean_code.epub"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 4. Open File in OS Default Viewer
|
|
136
|
+
Open the downloaded book (EPUB, PDF, TXT) immediately in your operating system's default book reader.
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
book open 1
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 5. Managing Favorites
|
|
143
|
+
Bookmark books to read later.
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Add to favorites
|
|
147
|
+
book favorite add 1
|
|
148
|
+
|
|
149
|
+
# List all favorites
|
|
150
|
+
book favorite list
|
|
151
|
+
|
|
152
|
+
# Remove from favorites
|
|
153
|
+
book favorite remove gutenberg:1342
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### 6. Configuration Settings
|
|
157
|
+
List all configuration options or update parameters:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# View configuration
|
|
161
|
+
book config
|
|
162
|
+
|
|
163
|
+
# Set default download directory (can also use 'download-path' alias)
|
|
164
|
+
book config set download-dir "/path/to/downloads"
|
|
165
|
+
book config set download-path "/path/to/downloads"
|
|
166
|
+
|
|
167
|
+
# Set client requests timeout
|
|
168
|
+
book config set timeout 10
|
|
169
|
+
|
|
170
|
+
# Disable a provider (e.g. internet_archive)
|
|
171
|
+
book config set provider false internet-archive
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### 7. Cache Management
|
|
175
|
+
View statistics or clear cached metadata:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
book cache stats
|
|
179
|
+
book cache clear
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 8. Query History
|
|
183
|
+
View your search history logs:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
book history
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Testing & Code Quality
|
|
192
|
+
|
|
193
|
+
BookCLI includes a comprehensive test suite of unit and integration tests with **80%+ code coverage**.
|
|
194
|
+
|
|
195
|
+
### Run Tests
|
|
196
|
+
```bash
|
|
197
|
+
python -m pytest --cov=bookcli
|
|
198
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
bookcli/__init__.py,sha256=JOjCAWLM7M20mWqqKYXVwebXuYLUShRCvuDBunhyIYI,46
|
|
2
|
+
bookcli/cache.py,sha256=_WyXpiMcoBC_lu23qOQ_gWvyYfP0sHQSnxLFaO69PTs,4414
|
|
3
|
+
bookcli/cli.py,sha256=deyJD-YHOfdakGdZ4_PcTQQaTfCBhWCmY6y5DBEC450,29153
|
|
4
|
+
bookcli/config.py,sha256=T0BJKaoq4GLLgFtfPowVe8reK7EYOwP0DTd4mtlyObU,2705
|
|
5
|
+
bookcli/downloader.py,sha256=0CC1R1kRWExu2XYZLodbWyvRYowBFRW_-MLSP4xCt5k,4788
|
|
6
|
+
bookcli/exceptions.py,sha256=J4id1zvGpTDpzesGR0CxHqruQmPVws-xmMZrIKfiSd0,824
|
|
7
|
+
bookcli/models.py,sha256=jbMQ21Px2b_X9Zop4qErqjC5HUF4As_dqmF_LzKSlHI,1651
|
|
8
|
+
bookcli/opener.py,sha256=Gp4s86v8zSsXO9apwol4maSwEWS_OX6FEUo9MargrnY,1022
|
|
9
|
+
bookcli/settings.py,sha256=XAwYg2azQ3nTLiyeeTDye-C18j7uho_w8VsFEayV1IU,757
|
|
10
|
+
bookcli/utils.py,sha256=hTm6rg84RnujiTJPQeax5iGybUnqhowAE9An6la35Cs,1117
|
|
11
|
+
bookcli/database/__init__.py,sha256=p13I-tucVoKBSGbBJrsGL6rBFIwfRFOPzH6s8rZYEng,1050
|
|
12
|
+
bookcli/database/migrations.py,sha256=IGuukuJWXJsSYy2dAk6-TP1h9rLXGSV-mHDdrUoiCJA,3141
|
|
13
|
+
bookcli/providers/__init__.py,sha256=0GJ7Xl_7ZBHzLrYeuTOIPKEKRNTW2lIAoVcRqyuVRJo,34
|
|
14
|
+
bookcli/providers/base.py,sha256=kEEk2yKwc4R28T8w4_pJHZl8eL2oNXO_ACpfHYTPrT0,1843
|
|
15
|
+
bookcli/providers/google_books.py,sha256=qp01uG9DZhHS1RRQYwww5gfJ1wOP2swMIuJmihPZXIU,7971
|
|
16
|
+
bookcli/providers/gutenberg.py,sha256=pnjrwTmuTaklGdu1wyn3isWTjvnDIKsbiuPMqPM0tAs,8117
|
|
17
|
+
bookcli/providers/internet_archive.py,sha256=WMC3aFlmw8mh0McK050z2G6qIJAnh6FQQ8FHt1acMq0,10615
|
|
18
|
+
bookcli/providers/openlibrary.py,sha256=3ZDBuCwFT-3n7WWSos-xiee7ftyWhZlH63X0Gc4d4U4,10575
|
|
19
|
+
bookcli/services/__init__.py,sha256=BqbzI_AJaobDOqAXjSPTHHZ6mIEvezWURJ2Qij6gTBE,28
|
|
20
|
+
bookcli/services/history.py,sha256=qO6rqP8KGNS82P2TZdUdK2jWPw_nSGxrZ41PFnBdYAs,2523
|
|
21
|
+
bookcli/services/ranking.py,sha256=Tm-JA3ExO6cUR3Q8xMDjOmppognKnd4V22Ewb3hTmVI,6144
|
|
22
|
+
bookcli/services/search.py,sha256=qkfcyKn4IpKh8TxYfBp_4__cSQ1SxuA0_ve4F_z5GMY,3395
|
|
23
|
+
bookcli-0.1.0.dist-info/METADATA,sha256=MorLlSziDiDrLxfe3Jo1qL-agNl0FdrCgbDnPWPaiRQ,7038
|
|
24
|
+
bookcli-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
25
|
+
bookcli-0.1.0.dist-info/entry_points.txt,sha256=Tw4l1qcRgSYfqhAQ0pmndefRiMRrjfCmkH-NumfPVig,41
|
|
26
|
+
bookcli-0.1.0.dist-info/top_level.txt,sha256=ftXFlBlJMCBs2A67OZVgPR55GrJ9Rvudza2pB3aytpQ,8
|
|
27
|
+
bookcli-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bookcli
|