bookcli 0.2.0__tar.gz → 0.2.2__tar.gz
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-0.2.2/PKG-INFO +266 -0
- bookcli-0.2.2/README.md +252 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/__init__.py +1 -1
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/cli.py +4 -1
- bookcli-0.2.2/bookcli.egg-info/PKG-INFO +266 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/pyproject.toml +1 -1
- bookcli-0.2.0/PKG-INFO +0 -198
- bookcli-0.2.0/README.md +0 -184
- bookcli-0.2.0/bookcli.egg-info/PKG-INFO +0 -198
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/cache.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/config.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/database/__init__.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/database/migrations.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/downloader.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/exceptions.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/models.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/opener.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/providers/__init__.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/providers/base.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/providers/google_books.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/providers/gutenberg.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/providers/internet_archive.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/providers/openlibrary.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/services/__init__.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/services/history.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/services/ranking.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/services/search.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/settings.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli/utils.py +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli.egg-info/SOURCES.txt +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli.egg-info/dependency_links.txt +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli.egg-info/entry_points.txt +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli.egg-info/requires.txt +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/bookcli.egg-info/top_level.txt +0 -0
- {bookcli-0.2.0 → bookcli-0.2.2}/setup.cfg +0 -0
bookcli-0.2.2/PKG-INFO
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bookcli
|
|
3
|
+
Version: 0.2.2
|
|
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
|
+
[](https://www.python.org/)
|
|
18
|
+
[](https://opensource.org/licenses/MIT)
|
|
19
|
+
[](https://github.com/greycode009)
|
|
20
|
+
[](https://github.com/greycode009)
|
|
21
|
+
|
|
22
|
+
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.
|
|
23
|
+
|
|
24
|
+
```text
|
|
25
|
+
██████╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗██╗ ██╗
|
|
26
|
+
██╔══██╗██╔═══██╗██╔═══██╗██║ ██╔╝██╔════╝██║ ██║
|
|
27
|
+
██████╔╝██║ ██║██║ ██║█████╔╝ ██║ ██║ ██║
|
|
28
|
+
██╔══██╗██║ ██║██║ ██║██╔═██╗ ██║ ██║ ██║
|
|
29
|
+
██████╔╝╚██████╔╝╚██████╔╝██║ ██╗╚██████╗███████╗██║
|
|
30
|
+
╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝
|
|
31
|
+
Search, inspect, and legally download books
|
|
32
|
+
Powered by Open Library & Gutenberg
|
|
33
|
+
Developer - Dipesh Malla
|
|
34
|
+
GitHub : greycode009
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 🌟 Key Features
|
|
40
|
+
|
|
41
|
+
* **⚡ Concurrent Multi-Provider Search**: Queries Google Books, Open Library, Project Gutenberg, and the Internet Archive concurrently using async/await handlers.
|
|
42
|
+
* **📊 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.
|
|
43
|
+
* **🧠 Intelligent Deduplication & Ranking**: Merges results from all providers using `RapidFuzz` fuzzy matching on title/author strings. Automatically ranks entries based on metadata completeness and direct download availability.
|
|
44
|
+
* **🔒 Safe & Legal Downloads**: Only downloads books that are explicitly public domain or marked as free by their host provider.
|
|
45
|
+
* **⏬ HTTP Range-Resume Downloads**: Supports HTTP Range headers for downloading larger books safely; auto-resumes interrupted connections with standard `Rich` progress displays.
|
|
46
|
+
* **📂 Direct OS File Integration**: Automatically launch downloaded books (EPUB, PDF, TXT) inside your default OS-registered reader using standard process controls.
|
|
47
|
+
* **💾 Local Caching & Offline State**: Backed by a local SQLite database using `aiosqlite`, providing fast offline retrieval of previously searched metadata, history logs, and favorites.
|
|
48
|
+
* **🛠️ Flexible Configurations**: Toggle providers, set custom cache TTLs, change client timeout constraints, and update default download pathways directly from the CLI or dashboard settings.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 🏛️ Clean Architecture
|
|
53
|
+
|
|
54
|
+
The codebase adheres strictly to Clean Architecture principles to separate core services, data layers, providers, and presentation:
|
|
55
|
+
|
|
56
|
+
```mermaid
|
|
57
|
+
graph TD
|
|
58
|
+
User[User] -->|Interact| CLI[cli.py / TUI Dashboard]
|
|
59
|
+
CLI -->|Execute commands/search| SearchService[services/search.py]
|
|
60
|
+
CLI -->|Manage settings| ConfigService[config.py / settings.py]
|
|
61
|
+
CLI -->|Track queries/favs| HistoryService[services/history.py]
|
|
62
|
+
CLI -->|Open files| Opener[opener.py]
|
|
63
|
+
CLI -->|Download files| Downloader[downloader.py]
|
|
64
|
+
|
|
65
|
+
SearchService -->|Rank/De-duplicate| RankingService[services/ranking.py]
|
|
66
|
+
SearchService -->|Cache lookup/write| CacheService[cache.py]
|
|
67
|
+
SearchService -->|Concurrent requests| Providers[Providers Layer]
|
|
68
|
+
|
|
69
|
+
CacheService -->|Local database| SQLite[(SQLite: bookcli.db)]
|
|
70
|
+
HistoryService -->|Local database| SQLite
|
|
71
|
+
|
|
72
|
+
Providers -->|API| GoogleBooks[Google Books Provider]
|
|
73
|
+
Providers -->|API| OpenLibrary[Open Library Provider]
|
|
74
|
+
Providers -->|Scrape/Download| Gutenberg[Project Gutenberg]
|
|
75
|
+
Providers -->|Search/Download| InternetArchive[Internet Archive]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Directory Layout
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
bookcli/
|
|
82
|
+
├── database/ # Database initialization and schema migrations
|
|
83
|
+
│ └── migrations.py
|
|
84
|
+
├── providers/ # Concretely implemented API / web providers
|
|
85
|
+
│ ├── base.py # Abstract base client provider
|
|
86
|
+
│ ├── google_books.py
|
|
87
|
+
│ ├── gutenberg.py
|
|
88
|
+
│ ├── internet_archive.py
|
|
89
|
+
│ └── openlibrary.py
|
|
90
|
+
├── services/ # Pure domain services (business rules)
|
|
91
|
+
│ ├── history.py # Query log tracking
|
|
92
|
+
│ ├── ranking.py # Metadata scoring and deduplication (RapidFuzz)
|
|
93
|
+
│ └── search.py # Orchestrates concurrent API querying & caching
|
|
94
|
+
├── cache.py # SQLite metadata cache mechanisms
|
|
95
|
+
├── cli.py # Typer/Rich CLI interface and main interactive loop
|
|
96
|
+
├── config.py # Pydantic models for configuration and serialization
|
|
97
|
+
├── downloader.py # Async downloader with range-resume & rich progress bars
|
|
98
|
+
├── exceptions.py # Domain-specific custom exception hierarchy
|
|
99
|
+
├── opener.py # Platform-specific document launcher
|
|
100
|
+
├── settings.py # Default constants and path configuration directories
|
|
101
|
+
└── utils.py # Clean utilities (unit formatting, filenames)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 🚀 Installation
|
|
107
|
+
|
|
108
|
+
Ensure you have **Python 3.12+** installed on your system.
|
|
109
|
+
|
|
110
|
+
1. **Clone the Repository**
|
|
111
|
+
```bash
|
|
112
|
+
git clone https://github.com/Greycode009/bookcli.git
|
|
113
|
+
cd bookcli
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
2. **Install in Editable Mode**
|
|
117
|
+
```bash
|
|
118
|
+
pip install -e .
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Command Execution wrappers
|
|
122
|
+
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:
|
|
123
|
+
* **Windows (PowerShell/CMD)**: `.\book.bat <command>`
|
|
124
|
+
* **Linux / macOS / Git Bash**: `./book <command>`
|
|
125
|
+
* **Python Direct Module**: `python -m bookcli.cli <command>`
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 🎮 How to Use
|
|
130
|
+
|
|
131
|
+
### 🖥️ 1. The Interactive Dashboard
|
|
132
|
+
Run `book` without arguments in an interactive terminal to enter the console dashboard:
|
|
133
|
+
```bash
|
|
134
|
+
book
|
|
135
|
+
```
|
|
136
|
+
This launches a complete navigation dashboard:
|
|
137
|
+
1. **🔍 Search Books**: Prompts for a search query and filters, then displays search results.
|
|
138
|
+
2. **📜 Search History**: Shows list of past queries. Includes an option to clear history.
|
|
139
|
+
3. **⭐ Favorite Books**: Displays all favorited items with quick options to download (`d <index>`), open in reader (`o <index>`), or remove (`r <index>`).
|
|
140
|
+
4. **⚡ Metadata Cache Stats**: Shows cache storage metadata sizes.
|
|
141
|
+
5. **🧹 Clear Metadata Cache**: Evicts database-cached search metadata.
|
|
142
|
+
6. **⚙️ Settings / Configuration**: Change active settings interactively (download path, client timeouts, toggling search providers).
|
|
143
|
+
7. **Exit Dashboard**.
|
|
144
|
+
|
|
145
|
+
#### Inline Search Explorer Actions
|
|
146
|
+
Inside the **Search Books** menu:
|
|
147
|
+
* Enter `<ID>` to download the book (e.g., `1`).
|
|
148
|
+
* Enter `<ID> -o <path>` or `<ID> --output <path>` to save to a custom path (e.g., `1 -o C:\downloads` or `1 -o book.epub`).
|
|
149
|
+
* Enter `i <ID>` to show complete details (description, pages, published year, publishers, ISBN).
|
|
150
|
+
* Enter `f <ID>` to add to favorites.
|
|
151
|
+
* Enter `o <ID>` to open a downloaded file in the OS default reader.
|
|
152
|
+
* Enter `q` to return to the main dashboard menu.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### ⚙️ 2. Direct CLI Command Reference
|
|
157
|
+
|
|
158
|
+
If you prefer to bypass the dashboard, you can invoke direct commands from your shell:
|
|
159
|
+
|
|
160
|
+
#### Concurrently Search Providers
|
|
161
|
+
```bash
|
|
162
|
+
book search "Clean Architecture"
|
|
163
|
+
```
|
|
164
|
+
Filter searches by specific parameters:
|
|
165
|
+
```bash
|
|
166
|
+
book search "Relativity" --subject "Physics"
|
|
167
|
+
book search "Refactoring" --author "Martin Fowler"
|
|
168
|
+
```
|
|
169
|
+
Export results directly to a structured file:
|
|
170
|
+
```bash
|
|
171
|
+
book search "Science" --export results.json
|
|
172
|
+
book search "History" --export history_books.csv
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### Get Detailed Information
|
|
176
|
+
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`):
|
|
177
|
+
```bash
|
|
178
|
+
book info 1
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
#### Download Books Legally
|
|
182
|
+
Download files with async resume support and live progress bars. Custom output paths automatically resolve folder hierarchies:
|
|
183
|
+
```bash
|
|
184
|
+
# Save to default downloads folder (~/.bookcli/downloads)
|
|
185
|
+
book download 1
|
|
186
|
+
|
|
187
|
+
# Save to custom directory
|
|
188
|
+
book download 1 --output "D:\Books"
|
|
189
|
+
|
|
190
|
+
# Save to custom file path
|
|
191
|
+
book download 1 -o "/Users/greycode/Desktop/design_patterns.epub"
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
#### Open Files Instantly
|
|
195
|
+
Fire up files inside the OS default viewer:
|
|
196
|
+
```bash
|
|
197
|
+
book open 1
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### Manage Favorites
|
|
201
|
+
```bash
|
|
202
|
+
book favorite add 1
|
|
203
|
+
book favorite list
|
|
204
|
+
book favorite remove gutenberg:1342
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
#### Manage Cache and History
|
|
208
|
+
```bash
|
|
209
|
+
# Show cache count and storage dates
|
|
210
|
+
book cache stats
|
|
211
|
+
|
|
212
|
+
# Remove all cached records
|
|
213
|
+
book cache clear
|
|
214
|
+
|
|
215
|
+
# List past search queries
|
|
216
|
+
book history
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
#### Modify Settings
|
|
220
|
+
Show settings or update values:
|
|
221
|
+
```bash
|
|
222
|
+
# Display settings
|
|
223
|
+
book config
|
|
224
|
+
|
|
225
|
+
# Set default downloads directory
|
|
226
|
+
book config set download-dir "C:\Users\Dipesh\Downloads"
|
|
227
|
+
|
|
228
|
+
# Adjust network client timeout
|
|
229
|
+
book config set timeout 20
|
|
230
|
+
|
|
231
|
+
# Disable Google Books search provider
|
|
232
|
+
book config set provider false google-books
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 🛠️ Development & Testing
|
|
238
|
+
|
|
239
|
+
### Running Tests
|
|
240
|
+
To run the project test suites (if `pytest` is installed in your python environment):
|
|
241
|
+
```bash
|
|
242
|
+
python -m pytest --cov=bookcli
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Data Storage Directories
|
|
246
|
+
By default, BookCLI stores its application databases and configurations in:
|
|
247
|
+
* **Default directory**: `~/.bookcli/` (resolves to `C:\Users\<User>\.bookcli` on Windows)
|
|
248
|
+
* **Database**: `~/.bookcli/bookcli.db`
|
|
249
|
+
* **Settings File**: `~/.bookcli/config.json`
|
|
250
|
+
* **Download Path**: `~/.bookcli/downloads/`
|
|
251
|
+
|
|
252
|
+
You can redirect the home directory by setting the `BOOKCLI_HOME` environment variable.
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## 👤 Author
|
|
257
|
+
|
|
258
|
+
* **Dipesh Malla**
|
|
259
|
+
* GitHub: [@greycode009](https://github.com/greycode009)
|
|
260
|
+
* Repository: [https://github.com/Greycode009/bookcli](https://github.com/Greycode009/bookcli)
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## 📄 License
|
|
265
|
+
|
|
266
|
+
This project is licensed under the MIT License - see the `LICENSE` file for details.
|
bookcli-0.2.2/README.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# 📚 BookCLI
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://github.com/greycode009)
|
|
6
|
+
[](https://github.com/greycode009)
|
|
7
|
+
|
|
8
|
+
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.
|
|
9
|
+
|
|
10
|
+
```text
|
|
11
|
+
██████╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗██╗ ██╗
|
|
12
|
+
██╔══██╗██╔═══██╗██╔═══██╗██║ ██╔╝██╔════╝██║ ██║
|
|
13
|
+
██████╔╝██║ ██║██║ ██║█████╔╝ ██║ ██║ ██║
|
|
14
|
+
██╔══██╗██║ ██║██║ ██║██╔═██╗ ██║ ██║ ██║
|
|
15
|
+
██████╔╝╚██████╔╝╚██████╔╝██║ ██╗╚██████╗███████╗██║
|
|
16
|
+
╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝
|
|
17
|
+
Search, inspect, and legally download books
|
|
18
|
+
Powered by Open Library & Gutenberg
|
|
19
|
+
Developer - Dipesh Malla
|
|
20
|
+
GitHub : greycode009
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 🌟 Key Features
|
|
26
|
+
|
|
27
|
+
* **⚡ Concurrent Multi-Provider Search**: Queries Google Books, Open Library, Project Gutenberg, and the Internet Archive concurrently using async/await handlers.
|
|
28
|
+
* **📊 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.
|
|
29
|
+
* **🧠 Intelligent Deduplication & Ranking**: Merges results from all providers using `RapidFuzz` fuzzy matching on title/author strings. Automatically ranks entries based on metadata completeness and direct download availability.
|
|
30
|
+
* **🔒 Safe & Legal Downloads**: Only downloads books that are explicitly public domain or marked as free by their host provider.
|
|
31
|
+
* **⏬ HTTP Range-Resume Downloads**: Supports HTTP Range headers for downloading larger books safely; auto-resumes interrupted connections with standard `Rich` progress displays.
|
|
32
|
+
* **📂 Direct OS File Integration**: Automatically launch downloaded books (EPUB, PDF, TXT) inside your default OS-registered reader using standard process controls.
|
|
33
|
+
* **💾 Local Caching & Offline State**: Backed by a local SQLite database using `aiosqlite`, providing fast offline retrieval of previously searched metadata, history logs, and favorites.
|
|
34
|
+
* **🛠️ Flexible Configurations**: Toggle providers, set custom cache TTLs, change client timeout constraints, and update default download pathways directly from the CLI or dashboard settings.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 🏛️ Clean Architecture
|
|
39
|
+
|
|
40
|
+
The codebase adheres strictly to Clean Architecture principles to separate core services, data layers, providers, and presentation:
|
|
41
|
+
|
|
42
|
+
```mermaid
|
|
43
|
+
graph TD
|
|
44
|
+
User[User] -->|Interact| CLI[cli.py / TUI Dashboard]
|
|
45
|
+
CLI -->|Execute commands/search| SearchService[services/search.py]
|
|
46
|
+
CLI -->|Manage settings| ConfigService[config.py / settings.py]
|
|
47
|
+
CLI -->|Track queries/favs| HistoryService[services/history.py]
|
|
48
|
+
CLI -->|Open files| Opener[opener.py]
|
|
49
|
+
CLI -->|Download files| Downloader[downloader.py]
|
|
50
|
+
|
|
51
|
+
SearchService -->|Rank/De-duplicate| RankingService[services/ranking.py]
|
|
52
|
+
SearchService -->|Cache lookup/write| CacheService[cache.py]
|
|
53
|
+
SearchService -->|Concurrent requests| Providers[Providers Layer]
|
|
54
|
+
|
|
55
|
+
CacheService -->|Local database| SQLite[(SQLite: bookcli.db)]
|
|
56
|
+
HistoryService -->|Local database| SQLite
|
|
57
|
+
|
|
58
|
+
Providers -->|API| GoogleBooks[Google Books Provider]
|
|
59
|
+
Providers -->|API| OpenLibrary[Open Library Provider]
|
|
60
|
+
Providers -->|Scrape/Download| Gutenberg[Project Gutenberg]
|
|
61
|
+
Providers -->|Search/Download| InternetArchive[Internet Archive]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Directory Layout
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
bookcli/
|
|
68
|
+
├── database/ # Database initialization and schema migrations
|
|
69
|
+
│ └── migrations.py
|
|
70
|
+
├── providers/ # Concretely implemented API / web providers
|
|
71
|
+
│ ├── base.py # Abstract base client provider
|
|
72
|
+
│ ├── google_books.py
|
|
73
|
+
│ ├── gutenberg.py
|
|
74
|
+
│ ├── internet_archive.py
|
|
75
|
+
│ └── openlibrary.py
|
|
76
|
+
├── services/ # Pure domain services (business rules)
|
|
77
|
+
│ ├── history.py # Query log tracking
|
|
78
|
+
│ ├── ranking.py # Metadata scoring and deduplication (RapidFuzz)
|
|
79
|
+
│ └── search.py # Orchestrates concurrent API querying & caching
|
|
80
|
+
├── cache.py # SQLite metadata cache mechanisms
|
|
81
|
+
├── cli.py # Typer/Rich CLI interface and main interactive loop
|
|
82
|
+
├── config.py # Pydantic models for configuration and serialization
|
|
83
|
+
├── downloader.py # Async downloader with range-resume & rich progress bars
|
|
84
|
+
├── exceptions.py # Domain-specific custom exception hierarchy
|
|
85
|
+
├── opener.py # Platform-specific document launcher
|
|
86
|
+
├── settings.py # Default constants and path configuration directories
|
|
87
|
+
└── utils.py # Clean utilities (unit formatting, filenames)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 🚀 Installation
|
|
93
|
+
|
|
94
|
+
Ensure you have **Python 3.12+** installed on your system.
|
|
95
|
+
|
|
96
|
+
1. **Clone the Repository**
|
|
97
|
+
```bash
|
|
98
|
+
git clone https://github.com/Greycode009/bookcli.git
|
|
99
|
+
cd bookcli
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
2. **Install in Editable Mode**
|
|
103
|
+
```bash
|
|
104
|
+
pip install -e .
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Command Execution wrappers
|
|
108
|
+
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:
|
|
109
|
+
* **Windows (PowerShell/CMD)**: `.\book.bat <command>`
|
|
110
|
+
* **Linux / macOS / Git Bash**: `./book <command>`
|
|
111
|
+
* **Python Direct Module**: `python -m bookcli.cli <command>`
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 🎮 How to Use
|
|
116
|
+
|
|
117
|
+
### 🖥️ 1. The Interactive Dashboard
|
|
118
|
+
Run `book` without arguments in an interactive terminal to enter the console dashboard:
|
|
119
|
+
```bash
|
|
120
|
+
book
|
|
121
|
+
```
|
|
122
|
+
This launches a complete navigation dashboard:
|
|
123
|
+
1. **🔍 Search Books**: Prompts for a search query and filters, then displays search results.
|
|
124
|
+
2. **📜 Search History**: Shows list of past queries. Includes an option to clear history.
|
|
125
|
+
3. **⭐ Favorite Books**: Displays all favorited items with quick options to download (`d <index>`), open in reader (`o <index>`), or remove (`r <index>`).
|
|
126
|
+
4. **⚡ Metadata Cache Stats**: Shows cache storage metadata sizes.
|
|
127
|
+
5. **🧹 Clear Metadata Cache**: Evicts database-cached search metadata.
|
|
128
|
+
6. **⚙️ Settings / Configuration**: Change active settings interactively (download path, client timeouts, toggling search providers).
|
|
129
|
+
7. **Exit Dashboard**.
|
|
130
|
+
|
|
131
|
+
#### Inline Search Explorer Actions
|
|
132
|
+
Inside the **Search Books** menu:
|
|
133
|
+
* Enter `<ID>` to download the book (e.g., `1`).
|
|
134
|
+
* Enter `<ID> -o <path>` or `<ID> --output <path>` to save to a custom path (e.g., `1 -o C:\downloads` or `1 -o book.epub`).
|
|
135
|
+
* Enter `i <ID>` to show complete details (description, pages, published year, publishers, ISBN).
|
|
136
|
+
* Enter `f <ID>` to add to favorites.
|
|
137
|
+
* Enter `o <ID>` to open a downloaded file in the OS default reader.
|
|
138
|
+
* Enter `q` to return to the main dashboard menu.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### ⚙️ 2. Direct CLI Command Reference
|
|
143
|
+
|
|
144
|
+
If you prefer to bypass the dashboard, you can invoke direct commands from your shell:
|
|
145
|
+
|
|
146
|
+
#### Concurrently Search Providers
|
|
147
|
+
```bash
|
|
148
|
+
book search "Clean Architecture"
|
|
149
|
+
```
|
|
150
|
+
Filter searches by specific parameters:
|
|
151
|
+
```bash
|
|
152
|
+
book search "Relativity" --subject "Physics"
|
|
153
|
+
book search "Refactoring" --author "Martin Fowler"
|
|
154
|
+
```
|
|
155
|
+
Export results directly to a structured file:
|
|
156
|
+
```bash
|
|
157
|
+
book search "Science" --export results.json
|
|
158
|
+
book search "History" --export history_books.csv
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
#### Get Detailed Information
|
|
162
|
+
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`):
|
|
163
|
+
```bash
|
|
164
|
+
book info 1
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### Download Books Legally
|
|
168
|
+
Download files with async resume support and live progress bars. Custom output paths automatically resolve folder hierarchies:
|
|
169
|
+
```bash
|
|
170
|
+
# Save to default downloads folder (~/.bookcli/downloads)
|
|
171
|
+
book download 1
|
|
172
|
+
|
|
173
|
+
# Save to custom directory
|
|
174
|
+
book download 1 --output "D:\Books"
|
|
175
|
+
|
|
176
|
+
# Save to custom file path
|
|
177
|
+
book download 1 -o "/Users/greycode/Desktop/design_patterns.epub"
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### Open Files Instantly
|
|
181
|
+
Fire up files inside the OS default viewer:
|
|
182
|
+
```bash
|
|
183
|
+
book open 1
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
#### Manage Favorites
|
|
187
|
+
```bash
|
|
188
|
+
book favorite add 1
|
|
189
|
+
book favorite list
|
|
190
|
+
book favorite remove gutenberg:1342
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### Manage Cache and History
|
|
194
|
+
```bash
|
|
195
|
+
# Show cache count and storage dates
|
|
196
|
+
book cache stats
|
|
197
|
+
|
|
198
|
+
# Remove all cached records
|
|
199
|
+
book cache clear
|
|
200
|
+
|
|
201
|
+
# List past search queries
|
|
202
|
+
book history
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
#### Modify Settings
|
|
206
|
+
Show settings or update values:
|
|
207
|
+
```bash
|
|
208
|
+
# Display settings
|
|
209
|
+
book config
|
|
210
|
+
|
|
211
|
+
# Set default downloads directory
|
|
212
|
+
book config set download-dir "C:\Users\Dipesh\Downloads"
|
|
213
|
+
|
|
214
|
+
# Adjust network client timeout
|
|
215
|
+
book config set timeout 20
|
|
216
|
+
|
|
217
|
+
# Disable Google Books search provider
|
|
218
|
+
book config set provider false google-books
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 🛠️ Development & Testing
|
|
224
|
+
|
|
225
|
+
### Running Tests
|
|
226
|
+
To run the project test suites (if `pytest` is installed in your python environment):
|
|
227
|
+
```bash
|
|
228
|
+
python -m pytest --cov=bookcli
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Data Storage Directories
|
|
232
|
+
By default, BookCLI stores its application databases and configurations in:
|
|
233
|
+
* **Default directory**: `~/.bookcli/` (resolves to `C:\Users\<User>\.bookcli` on Windows)
|
|
234
|
+
* **Database**: `~/.bookcli/bookcli.db`
|
|
235
|
+
* **Settings File**: `~/.bookcli/config.json`
|
|
236
|
+
* **Download Path**: `~/.bookcli/downloads/`
|
|
237
|
+
|
|
238
|
+
You can redirect the home directory by setting the `BOOKCLI_HOME` environment variable.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## 👤 Author
|
|
243
|
+
|
|
244
|
+
* **Dipesh Malla**
|
|
245
|
+
* GitHub: [@greycode009](https://github.com/greycode009)
|
|
246
|
+
* Repository: [https://github.com/Greycode009/bookcli](https://github.com/Greycode009/bookcli)
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## 📄 License
|
|
251
|
+
|
|
252
|
+
This project is licensed under the MIT License - see the `LICENSE` file for details.
|
|
@@ -303,8 +303,11 @@ def make_banner() -> Panel:
|
|
|
303
303
|
banner_text.append("██████╔╝╚██████╔╝╚██████╔╝██║ ██╗╚██████╗███████╗██║\n", style="bold yellow")
|
|
304
304
|
banner_text.append("╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝\n", style="bold yellow")
|
|
305
305
|
banner_text.append(" Search, inspect, and legally download books\n", style="italic dim white")
|
|
306
|
-
banner_text.append(" Powered by Open Library & Gutenberg", style="italic dim white")
|
|
306
|
+
banner_text.append(" Powered by Open Library & Gutenberg\n", style="italic dim white")
|
|
307
|
+
banner_text.append(" Developer - Dipesh Malla\n", style="italic dim white")
|
|
308
|
+
banner_text.append(" GitHub : greycode009 ", style="italic dim white")
|
|
307
309
|
|
|
310
|
+
|
|
308
311
|
from rich.box import ROUNDED
|
|
309
312
|
return Panel(
|
|
310
313
|
Align.center(banner_text),
|