boltdown 0.1.0__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.
boltdown-0.1.0/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ MIT License
2
+
3
+ <<<<<<< HEAD
4
+ Copyright (c) 2026 Muhammad Ameen
5
+ =======
6
+ Copyright (c) 2026 Mohammad Ameen Barech
7
+ >>>>>>> bb54ff8a147eedf48004b00d45786b9b874d1b30
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
@@ -0,0 +1,217 @@
1
+ Metadata-Version: 2.4
2
+ Name: boltdown
3
+ Version: 0.1.0
4
+ Summary: Python torrent download manager wrapping aria2c via JSON-RPC
5
+ Author: Mohammad Ameen Barech
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/mohammadameenbarech/boltdown-lib
8
+ Project-URL: Repository, https://github.com/mohammadameenbarech/boltdown-lib
9
+ Project-URL: Issues, https://github.com/mohammadameenbarech/boltdown-lib/issues
10
+ Keywords: torrent,aria2,bittorrent,download,magnet
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Provides-Extra: torrent
15
+ Requires-Dist: bencodepy>=0.9.5; extra == "torrent"
16
+ Provides-Extra: dev
17
+ Requires-Dist: pytest>=7; extra == "dev"
18
+ Requires-Dist: pytest-cov; extra == "dev"
19
+ Requires-Dist: bencodepy>=0.9.5; extra == "dev"
20
+ Dynamic: license-file
21
+
22
+ # boltdown
23
+
24
+ A Python library for managing torrent downloads, powered by [aria2c](https://aria2.github.io/).
25
+
26
+ [![PyPI](https://img.shields.io/pypi/v/boltdown.svg)](https://pypi.org/project/boltdown/)
27
+ [![Python](https://img.shields.io/badge/Python-3.9+-blue.svg)](https://pypi.org/project/boltdown/)
28
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
29
+
30
+ **boltdown** wraps `aria2c` via JSON-RPC to provide a clean, dependency-free Python API for
31
+ torrent and magnet link downloads. No Django. No heavy HTTP frameworks. Just Python and aria2c.
32
+
33
+ ---
34
+
35
+ ## Features
36
+
37
+ - **Zero external HTTP dependencies** — uses stdlib `urllib` only
38
+ - **Magnet links** — full validation, hash extraction, DHT support
39
+ - **.torrent files** — optional `bencodepy` extra
40
+ - **SQLite state** — stdlib `sqlite3`, no ORM required
41
+ - **Background monitoring** — auto-syncs progress from aria2c
42
+ - **Typed and documented** — full type hints, Python 3.9+
43
+ - **PyPI-ready** — `pip install boltdown`
44
+
45
+ ---
46
+
47
+ ## Quick Start
48
+
49
+ ### 1. Install
50
+
51
+ ```bash
52
+ pip install boltdown
53
+ # For .torrent file support:
54
+ pip install boltdown[torrent]
55
+ ```
56
+
57
+ ### 2. Download a Magnet Link
58
+
59
+ ```python
60
+ from boltdown import BoltdownClient
61
+
62
+ with BoltdownClient(download_dir="./downloads") as client:
63
+ task = client.add_magnet("magnet:?xt=urn:btih:...")
64
+ print(task)
65
+ # <DownloadTask id=1 name='My File' status='downloading' progress=0.0%>
66
+ ```
67
+
68
+ ### 3. Download a .torrent File
69
+
70
+ ```python
71
+ from boltdown import BoltdownClient
72
+
73
+ with BoltdownClient(download_dir="./downloads") as client:
74
+ task = client.add_torrent_file("/path/to/file.torrent")
75
+ ```
76
+
77
+ ### 4. Manage Downloads
78
+
79
+ ```python
80
+ client = BoltdownClient(download_dir="./downloads")
81
+
82
+ # List all tasks
83
+ tasks = client.list_tasks()
84
+ for t in tasks:
85
+ print(t.to_dict())
86
+
87
+ # Pause and resume
88
+ client.pause(task.id)
89
+ client.resume(task.id)
90
+
91
+ # Remove (and optionally delete files from disk)
92
+ client.remove(task.id, delete_files=True)
93
+
94
+ # Always shut down cleanly
95
+ client.shutdown()
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Configuration
101
+
102
+ ```python
103
+ client = BoltdownClient(
104
+ download_dir = "./downloads", # Directory where files are saved
105
+ db_path = "./boltdown.db", # SQLite database (default: inside download_dir)
106
+ aria2c_path = None, # Auto-detect, or pass "/usr/bin/aria2c"
107
+ aria2_secret = "mysecret", # aria2 RPC token (optional but recommended)
108
+ rpc_port = 6800, # aria2 RPC listen port
109
+ monitor_interval = 2.0, # Seconds between status sync polls
110
+ )
111
+ ```
112
+
113
+ ### Prerequisites
114
+
115
+ - Python 3.9 or later
116
+ - `aria2c` available on your PATH, or placed in your working directory
117
+ - **Windows**: [Download from the aria2 GitHub releases page](https://github.com/aria2/aria2/releases)
118
+ - **Linux**: `sudo apt install aria2`
119
+ - **macOS**: `brew install aria2`
120
+
121
+ ---
122
+
123
+ ## API Reference
124
+
125
+ ### BoltdownClient
126
+
127
+ | Method | Returns | Description |
128
+ |--------|---------|-------------|
129
+ | `add_magnet(magnet_link)` | `DownloadTask` | Add a magnet URI and start downloading |
130
+ | `add_torrent_file(path)` | `DownloadTask` | Add a `.torrent` file and start downloading |
131
+ | `pause(task_id)` | `bool` | Pause a download |
132
+ | `resume(task_id)` | `bool` | Resume a paused download |
133
+ | `remove(task_id, delete_files=False)` | `None` | Remove a download, optionally deleting files |
134
+ | `get_task(task_id)` | `DownloadTask` | Retrieve a single task by ID |
135
+ | `list_tasks()` | `list[DownloadTask]` | List all tasks, ordered by ID |
136
+ | `shutdown()` | `None` | Stop monitoring and terminate aria2c |
137
+
138
+ ### DownloadTask
139
+
140
+ | Field | Type | Description |
141
+ |-------|------|-------------|
142
+ | `id` | `int` | Auto-assigned integer ID |
143
+ | `info_hash` | `str` | 40-character hex SHA-1 info hash |
144
+ | `name` | `str` | Display name |
145
+ | `status` | `str` | One of: `queued`, `downloading`, `paused`, `completed`, `error` |
146
+ | `progress` | `float` | Completion percentage (0.0 to 100.0) |
147
+ | `download_speed` | `int` | Current download speed in bytes per second |
148
+ | `upload_speed` | `int` | Current upload speed in bytes per second |
149
+ | `total_size` | `int` | Total file size in bytes |
150
+ | `eta` | `int` | Estimated seconds remaining |
151
+ | `save_path` | `str` | Directory where files are saved |
152
+ | `added_at` | `datetime` | UTC datetime when the task was created |
153
+ | `completed_at` | `datetime or None` | UTC datetime when the download finished |
154
+ | `error_message` | `str or None` | Description of the last error, if any |
155
+
156
+ ### Exceptions
157
+
158
+ | Exception | When raised |
159
+ |-----------|-------------|
160
+ | `BoltdownError` | Base class for all library errors |
161
+ | `Aria2NotFoundError` | The aria2c binary could not be located |
162
+ | `Aria2RpcError` | aria2 returned an error or refused the RPC call |
163
+ | `InvalidMagnetError` | The supplied string is not a valid magnet link |
164
+ | `TaskNotFoundError` | No task exists with the given ID |
165
+ | `StorageError` | A database or persistence error occurred |
166
+
167
+ ---
168
+
169
+ ## Architecture
170
+
171
+ ```
172
+ boltdown/
173
+ client.py BoltdownClient — main entry point
174
+ aria2.py aria2c process management and JSON-RPC client (stdlib urllib)
175
+ storage.py SQLite state persistence (stdlib sqlite3)
176
+ models.py DownloadTask dataclass
177
+ magnet.py Magnet URI parsing utilities
178
+ exceptions.py Custom exception hierarchy
179
+ _version.py Version string
180
+ ```
181
+
182
+ ---
183
+
184
+ ## Running Tests
185
+
186
+ ```bash
187
+ cd boltdown-lib
188
+ pip install -e ".[dev]"
189
+ pytest
190
+ ```
191
+
192
+ ---
193
+
194
+ ## Publishing to PyPI
195
+
196
+ ```bash
197
+ pip install build twine
198
+ python -m build
199
+ twine upload dist/*
200
+ ```
201
+
202
+ To test on TestPyPI first:
203
+
204
+ ```bash
205
+ twine upload --repository testpypi dist/*
206
+ pip install --index-url https://test.pypi.org/simple/ boltdown
207
+ ```
208
+
209
+ ---
210
+
211
+ ## License
212
+
213
+ MIT — see [LICENSE](LICENSE).
214
+
215
+ ---
216
+
217
+ By Mohammad Ameen Barech
@@ -0,0 +1,196 @@
1
+ # boltdown
2
+
3
+ A Python library for managing torrent downloads, powered by [aria2c](https://aria2.github.io/).
4
+
5
+ [![PyPI](https://img.shields.io/pypi/v/boltdown.svg)](https://pypi.org/project/boltdown/)
6
+ [![Python](https://img.shields.io/badge/Python-3.9+-blue.svg)](https://pypi.org/project/boltdown/)
7
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
8
+
9
+ **boltdown** wraps `aria2c` via JSON-RPC to provide a clean, dependency-free Python API for
10
+ torrent and magnet link downloads. No Django. No heavy HTTP frameworks. Just Python and aria2c.
11
+
12
+ ---
13
+
14
+ ## Features
15
+
16
+ - **Zero external HTTP dependencies** — uses stdlib `urllib` only
17
+ - **Magnet links** — full validation, hash extraction, DHT support
18
+ - **.torrent files** — optional `bencodepy` extra
19
+ - **SQLite state** — stdlib `sqlite3`, no ORM required
20
+ - **Background monitoring** — auto-syncs progress from aria2c
21
+ - **Typed and documented** — full type hints, Python 3.9+
22
+ - **PyPI-ready** — `pip install boltdown`
23
+
24
+ ---
25
+
26
+ ## Quick Start
27
+
28
+ ### 1. Install
29
+
30
+ ```bash
31
+ pip install boltdown
32
+ # For .torrent file support:
33
+ pip install boltdown[torrent]
34
+ ```
35
+
36
+ ### 2. Download a Magnet Link
37
+
38
+ ```python
39
+ from boltdown import BoltdownClient
40
+
41
+ with BoltdownClient(download_dir="./downloads") as client:
42
+ task = client.add_magnet("magnet:?xt=urn:btih:...")
43
+ print(task)
44
+ # <DownloadTask id=1 name='My File' status='downloading' progress=0.0%>
45
+ ```
46
+
47
+ ### 3. Download a .torrent File
48
+
49
+ ```python
50
+ from boltdown import BoltdownClient
51
+
52
+ with BoltdownClient(download_dir="./downloads") as client:
53
+ task = client.add_torrent_file("/path/to/file.torrent")
54
+ ```
55
+
56
+ ### 4. Manage Downloads
57
+
58
+ ```python
59
+ client = BoltdownClient(download_dir="./downloads")
60
+
61
+ # List all tasks
62
+ tasks = client.list_tasks()
63
+ for t in tasks:
64
+ print(t.to_dict())
65
+
66
+ # Pause and resume
67
+ client.pause(task.id)
68
+ client.resume(task.id)
69
+
70
+ # Remove (and optionally delete files from disk)
71
+ client.remove(task.id, delete_files=True)
72
+
73
+ # Always shut down cleanly
74
+ client.shutdown()
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Configuration
80
+
81
+ ```python
82
+ client = BoltdownClient(
83
+ download_dir = "./downloads", # Directory where files are saved
84
+ db_path = "./boltdown.db", # SQLite database (default: inside download_dir)
85
+ aria2c_path = None, # Auto-detect, or pass "/usr/bin/aria2c"
86
+ aria2_secret = "mysecret", # aria2 RPC token (optional but recommended)
87
+ rpc_port = 6800, # aria2 RPC listen port
88
+ monitor_interval = 2.0, # Seconds between status sync polls
89
+ )
90
+ ```
91
+
92
+ ### Prerequisites
93
+
94
+ - Python 3.9 or later
95
+ - `aria2c` available on your PATH, or placed in your working directory
96
+ - **Windows**: [Download from the aria2 GitHub releases page](https://github.com/aria2/aria2/releases)
97
+ - **Linux**: `sudo apt install aria2`
98
+ - **macOS**: `brew install aria2`
99
+
100
+ ---
101
+
102
+ ## API Reference
103
+
104
+ ### BoltdownClient
105
+
106
+ | Method | Returns | Description |
107
+ |--------|---------|-------------|
108
+ | `add_magnet(magnet_link)` | `DownloadTask` | Add a magnet URI and start downloading |
109
+ | `add_torrent_file(path)` | `DownloadTask` | Add a `.torrent` file and start downloading |
110
+ | `pause(task_id)` | `bool` | Pause a download |
111
+ | `resume(task_id)` | `bool` | Resume a paused download |
112
+ | `remove(task_id, delete_files=False)` | `None` | Remove a download, optionally deleting files |
113
+ | `get_task(task_id)` | `DownloadTask` | Retrieve a single task by ID |
114
+ | `list_tasks()` | `list[DownloadTask]` | List all tasks, ordered by ID |
115
+ | `shutdown()` | `None` | Stop monitoring and terminate aria2c |
116
+
117
+ ### DownloadTask
118
+
119
+ | Field | Type | Description |
120
+ |-------|------|-------------|
121
+ | `id` | `int` | Auto-assigned integer ID |
122
+ | `info_hash` | `str` | 40-character hex SHA-1 info hash |
123
+ | `name` | `str` | Display name |
124
+ | `status` | `str` | One of: `queued`, `downloading`, `paused`, `completed`, `error` |
125
+ | `progress` | `float` | Completion percentage (0.0 to 100.0) |
126
+ | `download_speed` | `int` | Current download speed in bytes per second |
127
+ | `upload_speed` | `int` | Current upload speed in bytes per second |
128
+ | `total_size` | `int` | Total file size in bytes |
129
+ | `eta` | `int` | Estimated seconds remaining |
130
+ | `save_path` | `str` | Directory where files are saved |
131
+ | `added_at` | `datetime` | UTC datetime when the task was created |
132
+ | `completed_at` | `datetime or None` | UTC datetime when the download finished |
133
+ | `error_message` | `str or None` | Description of the last error, if any |
134
+
135
+ ### Exceptions
136
+
137
+ | Exception | When raised |
138
+ |-----------|-------------|
139
+ | `BoltdownError` | Base class for all library errors |
140
+ | `Aria2NotFoundError` | The aria2c binary could not be located |
141
+ | `Aria2RpcError` | aria2 returned an error or refused the RPC call |
142
+ | `InvalidMagnetError` | The supplied string is not a valid magnet link |
143
+ | `TaskNotFoundError` | No task exists with the given ID |
144
+ | `StorageError` | A database or persistence error occurred |
145
+
146
+ ---
147
+
148
+ ## Architecture
149
+
150
+ ```
151
+ boltdown/
152
+ client.py BoltdownClient — main entry point
153
+ aria2.py aria2c process management and JSON-RPC client (stdlib urllib)
154
+ storage.py SQLite state persistence (stdlib sqlite3)
155
+ models.py DownloadTask dataclass
156
+ magnet.py Magnet URI parsing utilities
157
+ exceptions.py Custom exception hierarchy
158
+ _version.py Version string
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Running Tests
164
+
165
+ ```bash
166
+ cd boltdown-lib
167
+ pip install -e ".[dev]"
168
+ pytest
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Publishing to PyPI
174
+
175
+ ```bash
176
+ pip install build twine
177
+ python -m build
178
+ twine upload dist/*
179
+ ```
180
+
181
+ To test on TestPyPI first:
182
+
183
+ ```bash
184
+ twine upload --repository testpypi dist/*
185
+ pip install --index-url https://test.pypi.org/simple/ boltdown
186
+ ```
187
+
188
+ ---
189
+
190
+ ## License
191
+
192
+ MIT — see [LICENSE](LICENSE).
193
+
194
+ ---
195
+
196
+ By Mohammad Ameen Barech
@@ -0,0 +1,47 @@
1
+ """
2
+ boltdown -- Lightning-fast torrent download manager for Python.
3
+
4
+ Public API surface::
5
+
6
+ from boltdown import BoltdownClient, DownloadTask
7
+ from boltdown.exceptions import (
8
+ BoltdownError, Aria2NotFoundError, Aria2RpcError,
9
+ InvalidMagnetError, TaskNotFoundError, StorageError,
10
+ )
11
+
12
+ Basic usage::
13
+
14
+ with BoltdownClient(download_dir="./downloads") as client:
15
+ task = client.add_magnet("magnet:?xt=urn:btih:...")
16
+ print(task.status) # 'downloading'
17
+
18
+ tasks = client.list_tasks()
19
+ client.pause(task.id)
20
+ client.resume(task.id)
21
+ client.remove(task.id, delete_files=False)
22
+ """
23
+
24
+ from ._version import __version__
25
+ from .client import BoltdownClient
26
+ from .exceptions import (
27
+ Aria2NotFoundError,
28
+ Aria2RpcError,
29
+ BoltdownError,
30
+ InvalidMagnetError,
31
+ StorageError,
32
+ TaskNotFoundError,
33
+ )
34
+ from .models import DownloadTask
35
+
36
+ __all__ = [
37
+ "__version__",
38
+ "BoltdownClient",
39
+ "DownloadTask",
40
+ # Exceptions
41
+ "BoltdownError",
42
+ "Aria2NotFoundError",
43
+ "Aria2RpcError",
44
+ "InvalidMagnetError",
45
+ "TaskNotFoundError",
46
+ "StorageError",
47
+ ]
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"