@remote-app/qbittorrent-client 0.22.0
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.
- package/README.md +121 -0
- package/dist/index.cjs +275 -0
- package/dist/index.d.cts +62 -0
- package/dist/index.d.mts +62 -0
- package/dist/index.mjs +271 -0
- package/dist/schemas.cjs +287 -0
- package/dist/schemas.d.cts +861 -0
- package/dist/schemas.d.mts +861 -0
- package/dist/schemas.mjs +274 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# @remote-app/qbittorrent-client
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
A lightweight [qBittorrent](https://www.qbittorrent.org/) WebUI API client for Node.js and React Native.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @remote-app/qbittorrent-client
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import QBittorrentClient from "@remote-app/qbittorrent-client";
|
|
17
|
+
|
|
18
|
+
const client = new QBittorrentClient({
|
|
19
|
+
url: "http://localhost:8080",
|
|
20
|
+
username: "admin",
|
|
21
|
+
password: "adminadmin",
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// List all torrents
|
|
25
|
+
const torrents = await client.info();
|
|
26
|
+
|
|
27
|
+
// List torrents with filters
|
|
28
|
+
const downloading = await client.info({ filter: "downloading" });
|
|
29
|
+
|
|
30
|
+
// Add a torrent by URL
|
|
31
|
+
await client.add({ urls: "magnet:?xt=urn:btih:..." });
|
|
32
|
+
|
|
33
|
+
// Start and stop torrents
|
|
34
|
+
await client.start(["<hash>"]);
|
|
35
|
+
await client.stop(["<hash>"]);
|
|
36
|
+
|
|
37
|
+
// Get transfer info
|
|
38
|
+
const transfer = await client.transferInfo();
|
|
39
|
+
console.log(transfer.dl_info_speed, transfer.up_info_speed);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The client handles cookie-based authentication automatically and re-authenticates on 403 responses.
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
### Torrents
|
|
47
|
+
|
|
48
|
+
| Method | Description |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `info(params?)` | List torrents (with optional filters, sorting, pagination) |
|
|
51
|
+
| `properties(hash)` | Get torrent properties |
|
|
52
|
+
| `files(hash)` | Get torrent files |
|
|
53
|
+
| `trackers(hash)` | Get torrent trackers |
|
|
54
|
+
| `pieceStates(hash)` | Get piece download states |
|
|
55
|
+
| `add(params)` | Add torrent (by URL or `.torrent` Blob) |
|
|
56
|
+
| `delete(hashes, deleteFiles?)` | Delete torrents |
|
|
57
|
+
| `start(hashes)` | Start torrents |
|
|
58
|
+
| `stop(hashes)` | Stop torrents |
|
|
59
|
+
| `recheck(hashes)` | Recheck torrents |
|
|
60
|
+
| `reannounce(hashes)` | Reannounce torrents |
|
|
61
|
+
| `setDownloadLimit(hashes, limit)` | Set per-torrent download limit (bytes/s) |
|
|
62
|
+
| `setUploadLimit(hashes, limit)` | Set per-torrent upload limit (bytes/s) |
|
|
63
|
+
| `setShareLimits(hashes, ratio, seedingTime, inactiveTime)` | Set share limits |
|
|
64
|
+
| `setLocation(hashes, location)` | Move torrents to a new location |
|
|
65
|
+
| `rename(hash, name)` | Rename a torrent |
|
|
66
|
+
| `filePrio(hash, fileIds, priority)` | Set file priority |
|
|
67
|
+
| `setForceStart(hashes, value)` | Force start torrents |
|
|
68
|
+
| `topPrio(hashes)` / `bottomPrio(hashes)` | Move to top/bottom of queue |
|
|
69
|
+
| `increasePrio(hashes)` / `decreasePrio(hashes)` | Move up/down in queue |
|
|
70
|
+
|
|
71
|
+
### Transfer
|
|
72
|
+
|
|
73
|
+
| Method | Description |
|
|
74
|
+
|---|---|
|
|
75
|
+
| `transferInfo()` | Get global transfer info |
|
|
76
|
+
| `speedLimitsMode()` | Get alternative speed limits mode (0 or 1) |
|
|
77
|
+
| `toggleSpeedLimitsMode()` | Toggle alternative speed limits |
|
|
78
|
+
| `setGlobalDownloadLimit(limit)` | Set global download limit (bytes/s) |
|
|
79
|
+
| `setGlobalUploadLimit(limit)` | Set global upload limit (bytes/s) |
|
|
80
|
+
|
|
81
|
+
### App
|
|
82
|
+
|
|
83
|
+
| Method | Description |
|
|
84
|
+
|---|---|
|
|
85
|
+
| `version()` | Get qBittorrent version |
|
|
86
|
+
| `webapiVersion()` | Get WebUI API version |
|
|
87
|
+
| `preferences()` | Get application preferences |
|
|
88
|
+
| `setPreferences(prefs)` | Set application preferences |
|
|
89
|
+
| `defaultSavePath()` | Get default save path |
|
|
90
|
+
| `shutdown()` | Shutdown qBittorrent |
|
|
91
|
+
|
|
92
|
+
### Peers
|
|
93
|
+
|
|
94
|
+
| Method | Description |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `torrentPeers(hash, rid?)` | Get torrent peers data |
|
|
97
|
+
|
|
98
|
+
## Error handling
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import QBittorrentClient, {
|
|
102
|
+
HTTPError,
|
|
103
|
+
QBittorrentError,
|
|
104
|
+
} from "@remote-app/qbittorrent-client";
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
await client.info();
|
|
108
|
+
} catch (error) {
|
|
109
|
+
if (error instanceof HTTPError) {
|
|
110
|
+
// Non-200 HTTP response (e.g. 403 Forbidden)
|
|
111
|
+
console.error(error.status, error.message);
|
|
112
|
+
} else if (error instanceof QBittorrentError) {
|
|
113
|
+
// API-level error (e.g. login failure, failed to add torrent)
|
|
114
|
+
console.error(error.message);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
|
|
3
|
+
//#region src/error.ts
|
|
4
|
+
var HTTPError = class extends Error {
|
|
5
|
+
constructor(status, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.name = "HTTPError";
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var QBittorrentError = class extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "QBittorrentError";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/client.ts
|
|
20
|
+
var QBittorrentClient = class {
|
|
21
|
+
constructor(config) {
|
|
22
|
+
this.config = config;
|
|
23
|
+
this.sid = null;
|
|
24
|
+
this.loggedIn = false;
|
|
25
|
+
this.loginPromise = null;
|
|
26
|
+
}
|
|
27
|
+
baseUrl() {
|
|
28
|
+
return this.config.url.replace(/\/+$/, "");
|
|
29
|
+
}
|
|
30
|
+
async login() {
|
|
31
|
+
if (this.loginPromise) return this.loginPromise;
|
|
32
|
+
this.loginPromise = this.doLogin();
|
|
33
|
+
try {
|
|
34
|
+
await this.loginPromise;
|
|
35
|
+
} finally {
|
|
36
|
+
this.loginPromise = null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async doLogin() {
|
|
40
|
+
const baseUrl = this.baseUrl();
|
|
41
|
+
const body = new URLSearchParams();
|
|
42
|
+
if (this.config.username) body.set("username", this.config.username);
|
|
43
|
+
if (this.config.password) body.set("password", this.config.password);
|
|
44
|
+
const response = await fetch(`${baseUrl}/api/v2/auth/login`, {
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: {
|
|
47
|
+
Referer: baseUrl,
|
|
48
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
49
|
+
},
|
|
50
|
+
credentials: "include",
|
|
51
|
+
body: body.toString()
|
|
52
|
+
});
|
|
53
|
+
if (!response.ok) throw new HTTPError(response.status, response.statusText);
|
|
54
|
+
if (await response.text() !== "Ok.") throw new QBittorrentError("Login failed: invalid credentials");
|
|
55
|
+
const cookie = response.headers.get("set-cookie");
|
|
56
|
+
if (cookie) {
|
|
57
|
+
const match = cookie.match(/SID=([^;]+)/);
|
|
58
|
+
if (match) this.sid = match[1];
|
|
59
|
+
}
|
|
60
|
+
this.loggedIn = true;
|
|
61
|
+
}
|
|
62
|
+
async get(path, params) {
|
|
63
|
+
return this.request("GET", path, params);
|
|
64
|
+
}
|
|
65
|
+
async post(path, body) {
|
|
66
|
+
return this.request("POST", path, void 0, body);
|
|
67
|
+
}
|
|
68
|
+
async request(method, path, params, body, retry = true) {
|
|
69
|
+
if (!this.loggedIn) await this.login();
|
|
70
|
+
const baseUrl = this.baseUrl();
|
|
71
|
+
let url = `${baseUrl}${path}`;
|
|
72
|
+
if (params) {
|
|
73
|
+
const qs = new URLSearchParams(params);
|
|
74
|
+
url += `?${qs.toString()}`;
|
|
75
|
+
}
|
|
76
|
+
const headers = { Referer: baseUrl };
|
|
77
|
+
if (this.sid) headers["Cookie"] = `SID=${this.sid}`;
|
|
78
|
+
let fetchBody;
|
|
79
|
+
if (body instanceof URLSearchParams) {
|
|
80
|
+
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
81
|
+
fetchBody = body.toString();
|
|
82
|
+
} else fetchBody = body;
|
|
83
|
+
const response = await fetch(url, {
|
|
84
|
+
method,
|
|
85
|
+
headers,
|
|
86
|
+
body: fetchBody,
|
|
87
|
+
credentials: "include"
|
|
88
|
+
});
|
|
89
|
+
if (response.status === 403 && retry) {
|
|
90
|
+
this.sid = null;
|
|
91
|
+
this.loggedIn = false;
|
|
92
|
+
return this.request(method, path, params, body, false);
|
|
93
|
+
}
|
|
94
|
+
if (!response.ok) throw new HTTPError(response.status, response.statusText);
|
|
95
|
+
const text = await response.text();
|
|
96
|
+
if (!text) return void 0;
|
|
97
|
+
try {
|
|
98
|
+
return JSON.parse(text);
|
|
99
|
+
} catch {
|
|
100
|
+
return text;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
hashes(hashes) {
|
|
104
|
+
return hashes.join("|");
|
|
105
|
+
}
|
|
106
|
+
async info(params) {
|
|
107
|
+
const qs = {};
|
|
108
|
+
if (params) {
|
|
109
|
+
for (const [key, value] of Object.entries(params)) if (value !== void 0) qs[key] = String(value);
|
|
110
|
+
}
|
|
111
|
+
return this.get("/api/v2/torrents/info", qs);
|
|
112
|
+
}
|
|
113
|
+
async properties(hash) {
|
|
114
|
+
return this.get("/api/v2/torrents/properties", { hash });
|
|
115
|
+
}
|
|
116
|
+
async files(hash) {
|
|
117
|
+
return this.get("/api/v2/torrents/files", { hash });
|
|
118
|
+
}
|
|
119
|
+
async trackers(hash) {
|
|
120
|
+
return this.get("/api/v2/torrents/trackers", { hash });
|
|
121
|
+
}
|
|
122
|
+
async pieceStates(hash) {
|
|
123
|
+
return this.get("/api/v2/torrents/pieceStates", { hash });
|
|
124
|
+
}
|
|
125
|
+
async add(params) {
|
|
126
|
+
const form = new FormData();
|
|
127
|
+
for (const [key, value] of Object.entries(params)) {
|
|
128
|
+
if (value === void 0) continue;
|
|
129
|
+
if (key === "torrents") form.append("torrents", value, "torrent");
|
|
130
|
+
else form.append(key, String(value));
|
|
131
|
+
}
|
|
132
|
+
if (await this.post("/api/v2/torrents/add", form) === "Fails.") throw new QBittorrentError("Failed to add torrent");
|
|
133
|
+
}
|
|
134
|
+
async delete(hashes, deleteFiles = false) {
|
|
135
|
+
const body = new URLSearchParams();
|
|
136
|
+
body.set("hashes", this.hashes(hashes));
|
|
137
|
+
body.set("deleteFiles", String(deleteFiles));
|
|
138
|
+
await this.post("/api/v2/torrents/delete", body);
|
|
139
|
+
}
|
|
140
|
+
async start(hashes) {
|
|
141
|
+
const body = new URLSearchParams();
|
|
142
|
+
body.set("hashes", this.hashes(hashes));
|
|
143
|
+
await this.post("/api/v2/torrents/start", body);
|
|
144
|
+
}
|
|
145
|
+
async stop(hashes) {
|
|
146
|
+
const body = new URLSearchParams();
|
|
147
|
+
body.set("hashes", this.hashes(hashes));
|
|
148
|
+
await this.post("/api/v2/torrents/stop", body);
|
|
149
|
+
}
|
|
150
|
+
async recheck(hashes) {
|
|
151
|
+
const body = new URLSearchParams();
|
|
152
|
+
body.set("hashes", this.hashes(hashes));
|
|
153
|
+
await this.post("/api/v2/torrents/recheck", body);
|
|
154
|
+
}
|
|
155
|
+
async reannounce(hashes) {
|
|
156
|
+
const body = new URLSearchParams();
|
|
157
|
+
body.set("hashes", this.hashes(hashes));
|
|
158
|
+
await this.post("/api/v2/torrents/reannounce", body);
|
|
159
|
+
}
|
|
160
|
+
async setDownloadLimit(hashes, limit) {
|
|
161
|
+
const body = new URLSearchParams();
|
|
162
|
+
body.set("hashes", this.hashes(hashes));
|
|
163
|
+
body.set("limit", String(limit));
|
|
164
|
+
await this.post("/api/v2/torrents/setDownloadLimit", body);
|
|
165
|
+
}
|
|
166
|
+
async setUploadLimit(hashes, limit) {
|
|
167
|
+
const body = new URLSearchParams();
|
|
168
|
+
body.set("hashes", this.hashes(hashes));
|
|
169
|
+
body.set("limit", String(limit));
|
|
170
|
+
await this.post("/api/v2/torrents/setUploadLimit", body);
|
|
171
|
+
}
|
|
172
|
+
async setShareLimits(hashes, ratioLimit, seedingTimeLimit, inactiveSeedingTimeLimit) {
|
|
173
|
+
const body = new URLSearchParams();
|
|
174
|
+
body.set("hashes", this.hashes(hashes));
|
|
175
|
+
body.set("ratioLimit", String(ratioLimit));
|
|
176
|
+
body.set("seedingTimeLimit", String(seedingTimeLimit));
|
|
177
|
+
body.set("inactiveSeedingTimeLimit", String(inactiveSeedingTimeLimit));
|
|
178
|
+
await this.post("/api/v2/torrents/setShareLimits", body);
|
|
179
|
+
}
|
|
180
|
+
async setLocation(hashes, location) {
|
|
181
|
+
const body = new URLSearchParams();
|
|
182
|
+
body.set("hashes", this.hashes(hashes));
|
|
183
|
+
body.set("location", location);
|
|
184
|
+
await this.post("/api/v2/torrents/setLocation", body);
|
|
185
|
+
}
|
|
186
|
+
async rename(hash, name) {
|
|
187
|
+
const body = new URLSearchParams();
|
|
188
|
+
body.set("hash", hash);
|
|
189
|
+
body.set("name", name);
|
|
190
|
+
await this.post("/api/v2/torrents/rename", body);
|
|
191
|
+
}
|
|
192
|
+
async filePrio(hash, fileIds, priority) {
|
|
193
|
+
const body = new URLSearchParams();
|
|
194
|
+
body.set("hash", hash);
|
|
195
|
+
body.set("id", fileIds.join("|"));
|
|
196
|
+
body.set("priority", String(priority));
|
|
197
|
+
await this.post("/api/v2/torrents/filePrio", body);
|
|
198
|
+
}
|
|
199
|
+
async topPrio(hashes) {
|
|
200
|
+
const body = new URLSearchParams();
|
|
201
|
+
body.set("hashes", this.hashes(hashes));
|
|
202
|
+
await this.post("/api/v2/torrents/topPrio", body);
|
|
203
|
+
}
|
|
204
|
+
async increasePrio(hashes) {
|
|
205
|
+
const body = new URLSearchParams();
|
|
206
|
+
body.set("hashes", this.hashes(hashes));
|
|
207
|
+
await this.post("/api/v2/torrents/increasePrio", body);
|
|
208
|
+
}
|
|
209
|
+
async decreasePrio(hashes) {
|
|
210
|
+
const body = new URLSearchParams();
|
|
211
|
+
body.set("hashes", this.hashes(hashes));
|
|
212
|
+
await this.post("/api/v2/torrents/decreasePrio", body);
|
|
213
|
+
}
|
|
214
|
+
async bottomPrio(hashes) {
|
|
215
|
+
const body = new URLSearchParams();
|
|
216
|
+
body.set("hashes", this.hashes(hashes));
|
|
217
|
+
await this.post("/api/v2/torrents/bottomPrio", body);
|
|
218
|
+
}
|
|
219
|
+
async setForceStart(hashes, value) {
|
|
220
|
+
const body = new URLSearchParams();
|
|
221
|
+
body.set("hashes", this.hashes(hashes));
|
|
222
|
+
body.set("value", String(value));
|
|
223
|
+
await this.post("/api/v2/torrents/setForceStart", body);
|
|
224
|
+
}
|
|
225
|
+
async torrentPeers(hash, rid) {
|
|
226
|
+
const params = { hash };
|
|
227
|
+
if (rid !== void 0) params.rid = String(rid);
|
|
228
|
+
return this.get("/api/v2/sync/torrentPeers", params);
|
|
229
|
+
}
|
|
230
|
+
async transferInfo() {
|
|
231
|
+
return this.get("/api/v2/transfer/info");
|
|
232
|
+
}
|
|
233
|
+
async speedLimitsMode() {
|
|
234
|
+
const result = await this.get("/api/v2/transfer/speedLimitsMode");
|
|
235
|
+
return Number(result);
|
|
236
|
+
}
|
|
237
|
+
async toggleSpeedLimitsMode() {
|
|
238
|
+
await this.post("/api/v2/transfer/toggleSpeedLimitsMode");
|
|
239
|
+
}
|
|
240
|
+
async setGlobalDownloadLimit(limit) {
|
|
241
|
+
const body = new URLSearchParams();
|
|
242
|
+
body.set("limit", String(limit));
|
|
243
|
+
await this.post("/api/v2/transfer/setDownloadLimit", body);
|
|
244
|
+
}
|
|
245
|
+
async setGlobalUploadLimit(limit) {
|
|
246
|
+
const body = new URLSearchParams();
|
|
247
|
+
body.set("limit", String(limit));
|
|
248
|
+
await this.post("/api/v2/transfer/setUploadLimit", body);
|
|
249
|
+
}
|
|
250
|
+
async version() {
|
|
251
|
+
return this.get("/api/v2/app/version");
|
|
252
|
+
}
|
|
253
|
+
async webapiVersion() {
|
|
254
|
+
return this.get("/api/v2/app/webapiVersion");
|
|
255
|
+
}
|
|
256
|
+
async preferences() {
|
|
257
|
+
return this.get("/api/v2/app/preferences");
|
|
258
|
+
}
|
|
259
|
+
async setPreferences(prefs) {
|
|
260
|
+
const body = new URLSearchParams();
|
|
261
|
+
body.set("json", JSON.stringify(prefs));
|
|
262
|
+
await this.post("/api/v2/app/setPreferences", body);
|
|
263
|
+
}
|
|
264
|
+
async defaultSavePath() {
|
|
265
|
+
return this.get("/api/v2/app/defaultSavePath");
|
|
266
|
+
}
|
|
267
|
+
async shutdown() {
|
|
268
|
+
await this.post("/api/v2/app/shutdown");
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
//#endregion
|
|
273
|
+
exports.HTTPError = HTTPError;
|
|
274
|
+
exports.QBittorrentError = QBittorrentError;
|
|
275
|
+
exports.default = QBittorrentClient;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { AddTorrentParams, Preferences, QBittorrentConfig, TorrentFile, TorrentFileInput, TorrentInfo, TorrentInfoParams, TorrentPeer, TorrentPeersResponse, TorrentProperties, TorrentState, TorrentTracker, TransferInfo } from "./schemas.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/client.d.ts
|
|
4
|
+
declare class QBittorrentClient {
|
|
5
|
+
private config;
|
|
6
|
+
private sid;
|
|
7
|
+
private loggedIn;
|
|
8
|
+
private loginPromise;
|
|
9
|
+
constructor(config: QBittorrentConfig);
|
|
10
|
+
private baseUrl;
|
|
11
|
+
private login;
|
|
12
|
+
private doLogin;
|
|
13
|
+
private get;
|
|
14
|
+
private post;
|
|
15
|
+
private request;
|
|
16
|
+
private hashes;
|
|
17
|
+
info(params?: TorrentInfoParams): Promise<TorrentInfo[]>;
|
|
18
|
+
properties(hash: string): Promise<TorrentProperties>;
|
|
19
|
+
files(hash: string): Promise<TorrentFile[]>;
|
|
20
|
+
trackers(hash: string): Promise<TorrentTracker[]>;
|
|
21
|
+
pieceStates(hash: string): Promise<number[]>;
|
|
22
|
+
add(params: AddTorrentParams): Promise<void>;
|
|
23
|
+
delete(hashes: string[], deleteFiles?: boolean): Promise<void>;
|
|
24
|
+
start(hashes: string[]): Promise<void>;
|
|
25
|
+
stop(hashes: string[]): Promise<void>;
|
|
26
|
+
recheck(hashes: string[]): Promise<void>;
|
|
27
|
+
reannounce(hashes: string[]): Promise<void>;
|
|
28
|
+
setDownloadLimit(hashes: string[], limit: number): Promise<void>;
|
|
29
|
+
setUploadLimit(hashes: string[], limit: number): Promise<void>;
|
|
30
|
+
setShareLimits(hashes: string[], ratioLimit: number, seedingTimeLimit: number, inactiveSeedingTimeLimit: number): Promise<void>;
|
|
31
|
+
setLocation(hashes: string[], location: string): Promise<void>;
|
|
32
|
+
rename(hash: string, name: string): Promise<void>;
|
|
33
|
+
filePrio(hash: string, fileIds: number[], priority: number): Promise<void>;
|
|
34
|
+
topPrio(hashes: string[]): Promise<void>;
|
|
35
|
+
increasePrio(hashes: string[]): Promise<void>;
|
|
36
|
+
decreasePrio(hashes: string[]): Promise<void>;
|
|
37
|
+
bottomPrio(hashes: string[]): Promise<void>;
|
|
38
|
+
setForceStart(hashes: string[], value: boolean): Promise<void>;
|
|
39
|
+
torrentPeers(hash: string, rid?: number): Promise<TorrentPeersResponse>;
|
|
40
|
+
transferInfo(): Promise<TransferInfo>;
|
|
41
|
+
speedLimitsMode(): Promise<number>;
|
|
42
|
+
toggleSpeedLimitsMode(): Promise<void>;
|
|
43
|
+
setGlobalDownloadLimit(limit: number): Promise<void>;
|
|
44
|
+
setGlobalUploadLimit(limit: number): Promise<void>;
|
|
45
|
+
version(): Promise<string>;
|
|
46
|
+
webapiVersion(): Promise<string>;
|
|
47
|
+
preferences(): Promise<Preferences>;
|
|
48
|
+
setPreferences(prefs: Partial<Preferences>): Promise<void>;
|
|
49
|
+
defaultSavePath(): Promise<string>;
|
|
50
|
+
shutdown(): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/error.d.ts
|
|
54
|
+
declare class HTTPError extends Error {
|
|
55
|
+
readonly status: number;
|
|
56
|
+
constructor(status: number, message: string);
|
|
57
|
+
}
|
|
58
|
+
declare class QBittorrentError extends Error {
|
|
59
|
+
constructor(message: string);
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { type AddTorrentParams, HTTPError, type Preferences, type QBittorrentConfig, QBittorrentError, type TorrentFile, type TorrentFileInput, type TorrentInfo, type TorrentInfoParams, type TorrentPeer, type TorrentPeersResponse, type TorrentProperties, type TorrentState, type TorrentTracker, type TransferInfo, QBittorrentClient as default };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { AddTorrentParams, Preferences, QBittorrentConfig, TorrentFile, TorrentFileInput, TorrentInfo, TorrentInfoParams, TorrentPeer, TorrentPeersResponse, TorrentProperties, TorrentState, TorrentTracker, TransferInfo } from "./schemas.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/client.d.ts
|
|
4
|
+
declare class QBittorrentClient {
|
|
5
|
+
private config;
|
|
6
|
+
private sid;
|
|
7
|
+
private loggedIn;
|
|
8
|
+
private loginPromise;
|
|
9
|
+
constructor(config: QBittorrentConfig);
|
|
10
|
+
private baseUrl;
|
|
11
|
+
private login;
|
|
12
|
+
private doLogin;
|
|
13
|
+
private get;
|
|
14
|
+
private post;
|
|
15
|
+
private request;
|
|
16
|
+
private hashes;
|
|
17
|
+
info(params?: TorrentInfoParams): Promise<TorrentInfo[]>;
|
|
18
|
+
properties(hash: string): Promise<TorrentProperties>;
|
|
19
|
+
files(hash: string): Promise<TorrentFile[]>;
|
|
20
|
+
trackers(hash: string): Promise<TorrentTracker[]>;
|
|
21
|
+
pieceStates(hash: string): Promise<number[]>;
|
|
22
|
+
add(params: AddTorrentParams): Promise<void>;
|
|
23
|
+
delete(hashes: string[], deleteFiles?: boolean): Promise<void>;
|
|
24
|
+
start(hashes: string[]): Promise<void>;
|
|
25
|
+
stop(hashes: string[]): Promise<void>;
|
|
26
|
+
recheck(hashes: string[]): Promise<void>;
|
|
27
|
+
reannounce(hashes: string[]): Promise<void>;
|
|
28
|
+
setDownloadLimit(hashes: string[], limit: number): Promise<void>;
|
|
29
|
+
setUploadLimit(hashes: string[], limit: number): Promise<void>;
|
|
30
|
+
setShareLimits(hashes: string[], ratioLimit: number, seedingTimeLimit: number, inactiveSeedingTimeLimit: number): Promise<void>;
|
|
31
|
+
setLocation(hashes: string[], location: string): Promise<void>;
|
|
32
|
+
rename(hash: string, name: string): Promise<void>;
|
|
33
|
+
filePrio(hash: string, fileIds: number[], priority: number): Promise<void>;
|
|
34
|
+
topPrio(hashes: string[]): Promise<void>;
|
|
35
|
+
increasePrio(hashes: string[]): Promise<void>;
|
|
36
|
+
decreasePrio(hashes: string[]): Promise<void>;
|
|
37
|
+
bottomPrio(hashes: string[]): Promise<void>;
|
|
38
|
+
setForceStart(hashes: string[], value: boolean): Promise<void>;
|
|
39
|
+
torrentPeers(hash: string, rid?: number): Promise<TorrentPeersResponse>;
|
|
40
|
+
transferInfo(): Promise<TransferInfo>;
|
|
41
|
+
speedLimitsMode(): Promise<number>;
|
|
42
|
+
toggleSpeedLimitsMode(): Promise<void>;
|
|
43
|
+
setGlobalDownloadLimit(limit: number): Promise<void>;
|
|
44
|
+
setGlobalUploadLimit(limit: number): Promise<void>;
|
|
45
|
+
version(): Promise<string>;
|
|
46
|
+
webapiVersion(): Promise<string>;
|
|
47
|
+
preferences(): Promise<Preferences>;
|
|
48
|
+
setPreferences(prefs: Partial<Preferences>): Promise<void>;
|
|
49
|
+
defaultSavePath(): Promise<string>;
|
|
50
|
+
shutdown(): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/error.d.ts
|
|
54
|
+
declare class HTTPError extends Error {
|
|
55
|
+
readonly status: number;
|
|
56
|
+
constructor(status: number, message: string);
|
|
57
|
+
}
|
|
58
|
+
declare class QBittorrentError extends Error {
|
|
59
|
+
constructor(message: string);
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { type AddTorrentParams, HTTPError, type Preferences, type QBittorrentConfig, QBittorrentError, type TorrentFile, type TorrentFileInput, type TorrentInfo, type TorrentInfoParams, type TorrentPeer, type TorrentPeersResponse, type TorrentProperties, type TorrentState, type TorrentTracker, type TransferInfo, QBittorrentClient as default };
|