@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/dist/index.mjs
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
//#region src/error.ts
|
|
2
|
+
var HTTPError = class extends Error {
|
|
3
|
+
constructor(status, message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.status = status;
|
|
6
|
+
this.name = "HTTPError";
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
var QBittorrentError = class extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "QBittorrentError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/client.ts
|
|
18
|
+
var QBittorrentClient = class {
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.config = config;
|
|
21
|
+
this.sid = null;
|
|
22
|
+
this.loggedIn = false;
|
|
23
|
+
this.loginPromise = null;
|
|
24
|
+
}
|
|
25
|
+
baseUrl() {
|
|
26
|
+
return this.config.url.replace(/\/+$/, "");
|
|
27
|
+
}
|
|
28
|
+
async login() {
|
|
29
|
+
if (this.loginPromise) return this.loginPromise;
|
|
30
|
+
this.loginPromise = this.doLogin();
|
|
31
|
+
try {
|
|
32
|
+
await this.loginPromise;
|
|
33
|
+
} finally {
|
|
34
|
+
this.loginPromise = null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async doLogin() {
|
|
38
|
+
const baseUrl = this.baseUrl();
|
|
39
|
+
const body = new URLSearchParams();
|
|
40
|
+
if (this.config.username) body.set("username", this.config.username);
|
|
41
|
+
if (this.config.password) body.set("password", this.config.password);
|
|
42
|
+
const response = await fetch(`${baseUrl}/api/v2/auth/login`, {
|
|
43
|
+
method: "POST",
|
|
44
|
+
headers: {
|
|
45
|
+
Referer: baseUrl,
|
|
46
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
47
|
+
},
|
|
48
|
+
credentials: "include",
|
|
49
|
+
body: body.toString()
|
|
50
|
+
});
|
|
51
|
+
if (!response.ok) throw new HTTPError(response.status, response.statusText);
|
|
52
|
+
if (await response.text() !== "Ok.") throw new QBittorrentError("Login failed: invalid credentials");
|
|
53
|
+
const cookie = response.headers.get("set-cookie");
|
|
54
|
+
if (cookie) {
|
|
55
|
+
const match = cookie.match(/SID=([^;]+)/);
|
|
56
|
+
if (match) this.sid = match[1];
|
|
57
|
+
}
|
|
58
|
+
this.loggedIn = true;
|
|
59
|
+
}
|
|
60
|
+
async get(path, params) {
|
|
61
|
+
return this.request("GET", path, params);
|
|
62
|
+
}
|
|
63
|
+
async post(path, body) {
|
|
64
|
+
return this.request("POST", path, void 0, body);
|
|
65
|
+
}
|
|
66
|
+
async request(method, path, params, body, retry = true) {
|
|
67
|
+
if (!this.loggedIn) await this.login();
|
|
68
|
+
const baseUrl = this.baseUrl();
|
|
69
|
+
let url = `${baseUrl}${path}`;
|
|
70
|
+
if (params) {
|
|
71
|
+
const qs = new URLSearchParams(params);
|
|
72
|
+
url += `?${qs.toString()}`;
|
|
73
|
+
}
|
|
74
|
+
const headers = { Referer: baseUrl };
|
|
75
|
+
if (this.sid) headers["Cookie"] = `SID=${this.sid}`;
|
|
76
|
+
let fetchBody;
|
|
77
|
+
if (body instanceof URLSearchParams) {
|
|
78
|
+
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
79
|
+
fetchBody = body.toString();
|
|
80
|
+
} else fetchBody = body;
|
|
81
|
+
const response = await fetch(url, {
|
|
82
|
+
method,
|
|
83
|
+
headers,
|
|
84
|
+
body: fetchBody,
|
|
85
|
+
credentials: "include"
|
|
86
|
+
});
|
|
87
|
+
if (response.status === 403 && retry) {
|
|
88
|
+
this.sid = null;
|
|
89
|
+
this.loggedIn = false;
|
|
90
|
+
return this.request(method, path, params, body, false);
|
|
91
|
+
}
|
|
92
|
+
if (!response.ok) throw new HTTPError(response.status, response.statusText);
|
|
93
|
+
const text = await response.text();
|
|
94
|
+
if (!text) return void 0;
|
|
95
|
+
try {
|
|
96
|
+
return JSON.parse(text);
|
|
97
|
+
} catch {
|
|
98
|
+
return text;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
hashes(hashes) {
|
|
102
|
+
return hashes.join("|");
|
|
103
|
+
}
|
|
104
|
+
async info(params) {
|
|
105
|
+
const qs = {};
|
|
106
|
+
if (params) {
|
|
107
|
+
for (const [key, value] of Object.entries(params)) if (value !== void 0) qs[key] = String(value);
|
|
108
|
+
}
|
|
109
|
+
return this.get("/api/v2/torrents/info", qs);
|
|
110
|
+
}
|
|
111
|
+
async properties(hash) {
|
|
112
|
+
return this.get("/api/v2/torrents/properties", { hash });
|
|
113
|
+
}
|
|
114
|
+
async files(hash) {
|
|
115
|
+
return this.get("/api/v2/torrents/files", { hash });
|
|
116
|
+
}
|
|
117
|
+
async trackers(hash) {
|
|
118
|
+
return this.get("/api/v2/torrents/trackers", { hash });
|
|
119
|
+
}
|
|
120
|
+
async pieceStates(hash) {
|
|
121
|
+
return this.get("/api/v2/torrents/pieceStates", { hash });
|
|
122
|
+
}
|
|
123
|
+
async add(params) {
|
|
124
|
+
const form = new FormData();
|
|
125
|
+
for (const [key, value] of Object.entries(params)) {
|
|
126
|
+
if (value === void 0) continue;
|
|
127
|
+
if (key === "torrents") form.append("torrents", value, "torrent");
|
|
128
|
+
else form.append(key, String(value));
|
|
129
|
+
}
|
|
130
|
+
if (await this.post("/api/v2/torrents/add", form) === "Fails.") throw new QBittorrentError("Failed to add torrent");
|
|
131
|
+
}
|
|
132
|
+
async delete(hashes, deleteFiles = false) {
|
|
133
|
+
const body = new URLSearchParams();
|
|
134
|
+
body.set("hashes", this.hashes(hashes));
|
|
135
|
+
body.set("deleteFiles", String(deleteFiles));
|
|
136
|
+
await this.post("/api/v2/torrents/delete", body);
|
|
137
|
+
}
|
|
138
|
+
async start(hashes) {
|
|
139
|
+
const body = new URLSearchParams();
|
|
140
|
+
body.set("hashes", this.hashes(hashes));
|
|
141
|
+
await this.post("/api/v2/torrents/start", body);
|
|
142
|
+
}
|
|
143
|
+
async stop(hashes) {
|
|
144
|
+
const body = new URLSearchParams();
|
|
145
|
+
body.set("hashes", this.hashes(hashes));
|
|
146
|
+
await this.post("/api/v2/torrents/stop", body);
|
|
147
|
+
}
|
|
148
|
+
async recheck(hashes) {
|
|
149
|
+
const body = new URLSearchParams();
|
|
150
|
+
body.set("hashes", this.hashes(hashes));
|
|
151
|
+
await this.post("/api/v2/torrents/recheck", body);
|
|
152
|
+
}
|
|
153
|
+
async reannounce(hashes) {
|
|
154
|
+
const body = new URLSearchParams();
|
|
155
|
+
body.set("hashes", this.hashes(hashes));
|
|
156
|
+
await this.post("/api/v2/torrents/reannounce", body);
|
|
157
|
+
}
|
|
158
|
+
async setDownloadLimit(hashes, limit) {
|
|
159
|
+
const body = new URLSearchParams();
|
|
160
|
+
body.set("hashes", this.hashes(hashes));
|
|
161
|
+
body.set("limit", String(limit));
|
|
162
|
+
await this.post("/api/v2/torrents/setDownloadLimit", body);
|
|
163
|
+
}
|
|
164
|
+
async setUploadLimit(hashes, limit) {
|
|
165
|
+
const body = new URLSearchParams();
|
|
166
|
+
body.set("hashes", this.hashes(hashes));
|
|
167
|
+
body.set("limit", String(limit));
|
|
168
|
+
await this.post("/api/v2/torrents/setUploadLimit", body);
|
|
169
|
+
}
|
|
170
|
+
async setShareLimits(hashes, ratioLimit, seedingTimeLimit, inactiveSeedingTimeLimit) {
|
|
171
|
+
const body = new URLSearchParams();
|
|
172
|
+
body.set("hashes", this.hashes(hashes));
|
|
173
|
+
body.set("ratioLimit", String(ratioLimit));
|
|
174
|
+
body.set("seedingTimeLimit", String(seedingTimeLimit));
|
|
175
|
+
body.set("inactiveSeedingTimeLimit", String(inactiveSeedingTimeLimit));
|
|
176
|
+
await this.post("/api/v2/torrents/setShareLimits", body);
|
|
177
|
+
}
|
|
178
|
+
async setLocation(hashes, location) {
|
|
179
|
+
const body = new URLSearchParams();
|
|
180
|
+
body.set("hashes", this.hashes(hashes));
|
|
181
|
+
body.set("location", location);
|
|
182
|
+
await this.post("/api/v2/torrents/setLocation", body);
|
|
183
|
+
}
|
|
184
|
+
async rename(hash, name) {
|
|
185
|
+
const body = new URLSearchParams();
|
|
186
|
+
body.set("hash", hash);
|
|
187
|
+
body.set("name", name);
|
|
188
|
+
await this.post("/api/v2/torrents/rename", body);
|
|
189
|
+
}
|
|
190
|
+
async filePrio(hash, fileIds, priority) {
|
|
191
|
+
const body = new URLSearchParams();
|
|
192
|
+
body.set("hash", hash);
|
|
193
|
+
body.set("id", fileIds.join("|"));
|
|
194
|
+
body.set("priority", String(priority));
|
|
195
|
+
await this.post("/api/v2/torrents/filePrio", body);
|
|
196
|
+
}
|
|
197
|
+
async topPrio(hashes) {
|
|
198
|
+
const body = new URLSearchParams();
|
|
199
|
+
body.set("hashes", this.hashes(hashes));
|
|
200
|
+
await this.post("/api/v2/torrents/topPrio", body);
|
|
201
|
+
}
|
|
202
|
+
async increasePrio(hashes) {
|
|
203
|
+
const body = new URLSearchParams();
|
|
204
|
+
body.set("hashes", this.hashes(hashes));
|
|
205
|
+
await this.post("/api/v2/torrents/increasePrio", body);
|
|
206
|
+
}
|
|
207
|
+
async decreasePrio(hashes) {
|
|
208
|
+
const body = new URLSearchParams();
|
|
209
|
+
body.set("hashes", this.hashes(hashes));
|
|
210
|
+
await this.post("/api/v2/torrents/decreasePrio", body);
|
|
211
|
+
}
|
|
212
|
+
async bottomPrio(hashes) {
|
|
213
|
+
const body = new URLSearchParams();
|
|
214
|
+
body.set("hashes", this.hashes(hashes));
|
|
215
|
+
await this.post("/api/v2/torrents/bottomPrio", body);
|
|
216
|
+
}
|
|
217
|
+
async setForceStart(hashes, value) {
|
|
218
|
+
const body = new URLSearchParams();
|
|
219
|
+
body.set("hashes", this.hashes(hashes));
|
|
220
|
+
body.set("value", String(value));
|
|
221
|
+
await this.post("/api/v2/torrents/setForceStart", body);
|
|
222
|
+
}
|
|
223
|
+
async torrentPeers(hash, rid) {
|
|
224
|
+
const params = { hash };
|
|
225
|
+
if (rid !== void 0) params.rid = String(rid);
|
|
226
|
+
return this.get("/api/v2/sync/torrentPeers", params);
|
|
227
|
+
}
|
|
228
|
+
async transferInfo() {
|
|
229
|
+
return this.get("/api/v2/transfer/info");
|
|
230
|
+
}
|
|
231
|
+
async speedLimitsMode() {
|
|
232
|
+
const result = await this.get("/api/v2/transfer/speedLimitsMode");
|
|
233
|
+
return Number(result);
|
|
234
|
+
}
|
|
235
|
+
async toggleSpeedLimitsMode() {
|
|
236
|
+
await this.post("/api/v2/transfer/toggleSpeedLimitsMode");
|
|
237
|
+
}
|
|
238
|
+
async setGlobalDownloadLimit(limit) {
|
|
239
|
+
const body = new URLSearchParams();
|
|
240
|
+
body.set("limit", String(limit));
|
|
241
|
+
await this.post("/api/v2/transfer/setDownloadLimit", body);
|
|
242
|
+
}
|
|
243
|
+
async setGlobalUploadLimit(limit) {
|
|
244
|
+
const body = new URLSearchParams();
|
|
245
|
+
body.set("limit", String(limit));
|
|
246
|
+
await this.post("/api/v2/transfer/setUploadLimit", body);
|
|
247
|
+
}
|
|
248
|
+
async version() {
|
|
249
|
+
return this.get("/api/v2/app/version");
|
|
250
|
+
}
|
|
251
|
+
async webapiVersion() {
|
|
252
|
+
return this.get("/api/v2/app/webapiVersion");
|
|
253
|
+
}
|
|
254
|
+
async preferences() {
|
|
255
|
+
return this.get("/api/v2/app/preferences");
|
|
256
|
+
}
|
|
257
|
+
async setPreferences(prefs) {
|
|
258
|
+
const body = new URLSearchParams();
|
|
259
|
+
body.set("json", JSON.stringify(prefs));
|
|
260
|
+
await this.post("/api/v2/app/setPreferences", body);
|
|
261
|
+
}
|
|
262
|
+
async defaultSavePath() {
|
|
263
|
+
return this.get("/api/v2/app/defaultSavePath");
|
|
264
|
+
}
|
|
265
|
+
async shutdown() {
|
|
266
|
+
await this.post("/api/v2/app/shutdown");
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
//#endregion
|
|
271
|
+
export { HTTPError, QBittorrentError, QBittorrentClient as default };
|
package/dist/schemas.cjs
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
|
|
4
|
+
//#region src/schemas.ts
|
|
5
|
+
const QBittorrentConfigSchema = zod.z.object({
|
|
6
|
+
url: zod.z.string(),
|
|
7
|
+
username: zod.z.string().optional(),
|
|
8
|
+
password: zod.z.string().optional()
|
|
9
|
+
});
|
|
10
|
+
const TorrentStateSchema = zod.z.enum([
|
|
11
|
+
"error",
|
|
12
|
+
"missingFiles",
|
|
13
|
+
"uploading",
|
|
14
|
+
"stoppedUP",
|
|
15
|
+
"queuedUP",
|
|
16
|
+
"stalledUP",
|
|
17
|
+
"checkingUP",
|
|
18
|
+
"forcedUP",
|
|
19
|
+
"allocating",
|
|
20
|
+
"downloading",
|
|
21
|
+
"metaDL",
|
|
22
|
+
"forcedMetaDL",
|
|
23
|
+
"stoppedDL",
|
|
24
|
+
"queuedDL",
|
|
25
|
+
"stalledDL",
|
|
26
|
+
"checkingDL",
|
|
27
|
+
"forcedDL",
|
|
28
|
+
"checkingResumeData",
|
|
29
|
+
"moving",
|
|
30
|
+
"unknown"
|
|
31
|
+
]);
|
|
32
|
+
const TorrentInfoSchema = zod.z.object({
|
|
33
|
+
hash: zod.z.string(),
|
|
34
|
+
infohash_v1: zod.z.string(),
|
|
35
|
+
infohash_v2: zod.z.string(),
|
|
36
|
+
name: zod.z.string(),
|
|
37
|
+
magnet_uri: zod.z.string(),
|
|
38
|
+
size: zod.z.number(),
|
|
39
|
+
total_size: zod.z.number(),
|
|
40
|
+
progress: zod.z.number(),
|
|
41
|
+
dlspeed: zod.z.number(),
|
|
42
|
+
upspeed: zod.z.number(),
|
|
43
|
+
priority: zod.z.number(),
|
|
44
|
+
num_seeds: zod.z.number(),
|
|
45
|
+
num_complete: zod.z.number(),
|
|
46
|
+
num_leechs: zod.z.number(),
|
|
47
|
+
num_incomplete: zod.z.number(),
|
|
48
|
+
ratio: zod.z.number(),
|
|
49
|
+
eta: zod.z.number(),
|
|
50
|
+
state: TorrentStateSchema,
|
|
51
|
+
seq_dl: zod.z.boolean(),
|
|
52
|
+
f_l_piece_prio: zod.z.boolean(),
|
|
53
|
+
category: zod.z.string(),
|
|
54
|
+
tags: zod.z.string(),
|
|
55
|
+
super_seeding: zod.z.boolean(),
|
|
56
|
+
force_start: zod.z.boolean(),
|
|
57
|
+
save_path: zod.z.string(),
|
|
58
|
+
download_path: zod.z.string(),
|
|
59
|
+
content_path: zod.z.string(),
|
|
60
|
+
added_on: zod.z.number(),
|
|
61
|
+
completion_on: zod.z.number(),
|
|
62
|
+
tracker: zod.z.string(),
|
|
63
|
+
trackers_count: zod.z.number(),
|
|
64
|
+
dl_limit: zod.z.number(),
|
|
65
|
+
up_limit: zod.z.number(),
|
|
66
|
+
downloaded: zod.z.number(),
|
|
67
|
+
uploaded: zod.z.number(),
|
|
68
|
+
downloaded_session: zod.z.number(),
|
|
69
|
+
uploaded_session: zod.z.number(),
|
|
70
|
+
amount_left: zod.z.number(),
|
|
71
|
+
completed: zod.z.number(),
|
|
72
|
+
max_ratio: zod.z.number(),
|
|
73
|
+
max_seeding_time: zod.z.number(),
|
|
74
|
+
max_inactive_seeding_time: zod.z.number(),
|
|
75
|
+
ratio_limit: zod.z.number(),
|
|
76
|
+
seeding_time_limit: zod.z.number(),
|
|
77
|
+
inactive_seeding_time_limit: zod.z.number(),
|
|
78
|
+
seen_complete: zod.z.number(),
|
|
79
|
+
last_activity: zod.z.number(),
|
|
80
|
+
auto_tmm: zod.z.boolean(),
|
|
81
|
+
time_active: zod.z.number(),
|
|
82
|
+
seeding_time: zod.z.number(),
|
|
83
|
+
availability: zod.z.number(),
|
|
84
|
+
reannounce: zod.z.number(),
|
|
85
|
+
comment: zod.z.string(),
|
|
86
|
+
popularity: zod.z.number()
|
|
87
|
+
}).passthrough();
|
|
88
|
+
const TorrentInfoParamsSchema = zod.z.object({
|
|
89
|
+
filter: zod.z.enum([
|
|
90
|
+
"all",
|
|
91
|
+
"downloading",
|
|
92
|
+
"seeding",
|
|
93
|
+
"completed",
|
|
94
|
+
"stopped",
|
|
95
|
+
"active",
|
|
96
|
+
"inactive",
|
|
97
|
+
"running",
|
|
98
|
+
"stalled",
|
|
99
|
+
"stalled_uploading",
|
|
100
|
+
"stalled_downloading",
|
|
101
|
+
"errored"
|
|
102
|
+
]).optional(),
|
|
103
|
+
category: zod.z.string().optional(),
|
|
104
|
+
tag: zod.z.string().optional(),
|
|
105
|
+
sort: zod.z.string().optional(),
|
|
106
|
+
reverse: zod.z.boolean().optional(),
|
|
107
|
+
limit: zod.z.number().optional(),
|
|
108
|
+
offset: zod.z.number().optional(),
|
|
109
|
+
hashes: zod.z.string().optional()
|
|
110
|
+
});
|
|
111
|
+
const TorrentPropertiesSchema = zod.z.object({
|
|
112
|
+
addition_date: zod.z.number(),
|
|
113
|
+
comment: zod.z.string(),
|
|
114
|
+
completion_date: zod.z.number(),
|
|
115
|
+
created_by: zod.z.string(),
|
|
116
|
+
creation_date: zod.z.number(),
|
|
117
|
+
dl_limit: zod.z.number(),
|
|
118
|
+
dl_speed: zod.z.number(),
|
|
119
|
+
dl_speed_avg: zod.z.number(),
|
|
120
|
+
eta: zod.z.number(),
|
|
121
|
+
isPrivate: zod.z.boolean().optional(),
|
|
122
|
+
last_seen: zod.z.number(),
|
|
123
|
+
nb_connections: zod.z.number(),
|
|
124
|
+
nb_connections_limit: zod.z.number(),
|
|
125
|
+
peers: zod.z.number(),
|
|
126
|
+
peers_total: zod.z.number(),
|
|
127
|
+
piece_size: zod.z.number(),
|
|
128
|
+
pieces_have: zod.z.number(),
|
|
129
|
+
pieces_num: zod.z.number(),
|
|
130
|
+
reannounce: zod.z.number(),
|
|
131
|
+
save_path: zod.z.string(),
|
|
132
|
+
seeding_time: zod.z.number(),
|
|
133
|
+
seeds: zod.z.number(),
|
|
134
|
+
seeds_total: zod.z.number(),
|
|
135
|
+
share_ratio: zod.z.number(),
|
|
136
|
+
time_elapsed: zod.z.number(),
|
|
137
|
+
total_downloaded: zod.z.number(),
|
|
138
|
+
total_downloaded_session: zod.z.number(),
|
|
139
|
+
total_size: zod.z.number(),
|
|
140
|
+
total_uploaded: zod.z.number(),
|
|
141
|
+
total_uploaded_session: zod.z.number(),
|
|
142
|
+
total_wasted: zod.z.number(),
|
|
143
|
+
up_limit: zod.z.number(),
|
|
144
|
+
up_speed: zod.z.number(),
|
|
145
|
+
up_speed_avg: zod.z.number()
|
|
146
|
+
}).passthrough();
|
|
147
|
+
const TorrentFileSchema = zod.z.object({
|
|
148
|
+
index: zod.z.number(),
|
|
149
|
+
name: zod.z.string(),
|
|
150
|
+
size: zod.z.number(),
|
|
151
|
+
progress: zod.z.number(),
|
|
152
|
+
priority: zod.z.number(),
|
|
153
|
+
is_seed: zod.z.boolean(),
|
|
154
|
+
piece_range: zod.z.array(zod.z.number()),
|
|
155
|
+
availability: zod.z.number()
|
|
156
|
+
}).passthrough();
|
|
157
|
+
const TorrentTrackerSchema = zod.z.object({
|
|
158
|
+
url: zod.z.string(),
|
|
159
|
+
status: zod.z.number(),
|
|
160
|
+
tier: zod.z.number(),
|
|
161
|
+
num_peers: zod.z.number(),
|
|
162
|
+
num_seeds: zod.z.number(),
|
|
163
|
+
num_leeches: zod.z.number(),
|
|
164
|
+
num_downloaded: zod.z.number(),
|
|
165
|
+
msg: zod.z.string()
|
|
166
|
+
}).passthrough();
|
|
167
|
+
const TorrentPeerSchema = zod.z.object({
|
|
168
|
+
ip: zod.z.string(),
|
|
169
|
+
port: zod.z.number(),
|
|
170
|
+
client: zod.z.string(),
|
|
171
|
+
peer_id_client: zod.z.string(),
|
|
172
|
+
progress: zod.z.number(),
|
|
173
|
+
dl_speed: zod.z.number(),
|
|
174
|
+
up_speed: zod.z.number(),
|
|
175
|
+
downloaded: zod.z.number(),
|
|
176
|
+
uploaded: zod.z.number(),
|
|
177
|
+
connection: zod.z.string(),
|
|
178
|
+
flags: zod.z.string(),
|
|
179
|
+
flags_desc: zod.z.string(),
|
|
180
|
+
country: zod.z.string(),
|
|
181
|
+
country_code: zod.z.string(),
|
|
182
|
+
relevance: zod.z.number(),
|
|
183
|
+
files: zod.z.string()
|
|
184
|
+
}).passthrough();
|
|
185
|
+
const TorrentPeersResponseSchema = zod.z.object({
|
|
186
|
+
rid: zod.z.number(),
|
|
187
|
+
peers: zod.z.record(zod.z.string(), TorrentPeerSchema),
|
|
188
|
+
peers_removed: zod.z.array(zod.z.string()).optional(),
|
|
189
|
+
full_update: zod.z.boolean().optional()
|
|
190
|
+
}).passthrough();
|
|
191
|
+
const TransferInfoSchema = zod.z.object({
|
|
192
|
+
dl_info_speed: zod.z.number(),
|
|
193
|
+
dl_info_data: zod.z.number(),
|
|
194
|
+
up_info_speed: zod.z.number(),
|
|
195
|
+
up_info_data: zod.z.number(),
|
|
196
|
+
dl_rate_limit: zod.z.number(),
|
|
197
|
+
up_rate_limit: zod.z.number(),
|
|
198
|
+
dht_nodes: zod.z.number(),
|
|
199
|
+
connection_status: zod.z.string()
|
|
200
|
+
}).passthrough();
|
|
201
|
+
const PreferencesSchema = zod.z.object({
|
|
202
|
+
save_path: zod.z.string(),
|
|
203
|
+
temp_path_enabled: zod.z.boolean(),
|
|
204
|
+
temp_path: zod.z.string(),
|
|
205
|
+
start_paused_enabled: zod.z.boolean().optional(),
|
|
206
|
+
preallocate_all: zod.z.boolean(),
|
|
207
|
+
auto_tmm_enabled: zod.z.boolean(),
|
|
208
|
+
dl_limit: zod.z.number(),
|
|
209
|
+
up_limit: zod.z.number(),
|
|
210
|
+
alt_dl_limit: zod.z.number(),
|
|
211
|
+
alt_up_limit: zod.z.number(),
|
|
212
|
+
scheduler_enabled: zod.z.boolean(),
|
|
213
|
+
schedule_from_hour: zod.z.number(),
|
|
214
|
+
schedule_from_min: zod.z.number(),
|
|
215
|
+
schedule_to_hour: zod.z.number(),
|
|
216
|
+
schedule_to_min: zod.z.number(),
|
|
217
|
+
scheduler_days: zod.z.number(),
|
|
218
|
+
listen_port: zod.z.number(),
|
|
219
|
+
upnp: zod.z.boolean(),
|
|
220
|
+
random_port: zod.z.boolean(),
|
|
221
|
+
max_connec: zod.z.number(),
|
|
222
|
+
max_connec_per_torrent: zod.z.number(),
|
|
223
|
+
max_uploads: zod.z.number(),
|
|
224
|
+
max_uploads_per_torrent: zod.z.number(),
|
|
225
|
+
dht: zod.z.boolean(),
|
|
226
|
+
pex: zod.z.boolean(),
|
|
227
|
+
lsd: zod.z.boolean(),
|
|
228
|
+
encryption: zod.z.number(),
|
|
229
|
+
anonymous_mode: zod.z.boolean(),
|
|
230
|
+
max_ratio_enabled: zod.z.boolean(),
|
|
231
|
+
max_ratio: zod.z.number(),
|
|
232
|
+
max_ratio_act: zod.z.number(),
|
|
233
|
+
max_seeding_time_enabled: zod.z.boolean(),
|
|
234
|
+
max_seeding_time: zod.z.number(),
|
|
235
|
+
max_inactive_seeding_time_enabled: zod.z.boolean().optional(),
|
|
236
|
+
max_inactive_seeding_time: zod.z.number().optional(),
|
|
237
|
+
queueing_enabled: zod.z.boolean(),
|
|
238
|
+
max_active_downloads: zod.z.number(),
|
|
239
|
+
max_active_torrents: zod.z.number(),
|
|
240
|
+
max_active_uploads: zod.z.number(),
|
|
241
|
+
dont_count_slow_torrents: zod.z.boolean(),
|
|
242
|
+
slow_torrent_dl_rate_threshold: zod.z.number(),
|
|
243
|
+
slow_torrent_ul_rate_threshold: zod.z.number(),
|
|
244
|
+
slow_torrent_inactive_timer: zod.z.number(),
|
|
245
|
+
web_ui_port: zod.z.number()
|
|
246
|
+
}).passthrough();
|
|
247
|
+
const TorrentFileInputBlobSchema = zod.z.custom((value) => typeof Blob !== "undefined" && value instanceof Blob, "Expected Blob");
|
|
248
|
+
const TorrentFileInputObjectSchema = zod.z.object({
|
|
249
|
+
uri: zod.z.string(),
|
|
250
|
+
type: zod.z.string(),
|
|
251
|
+
name: zod.z.string()
|
|
252
|
+
});
|
|
253
|
+
const TorrentFileInputSchema = zod.z.union([TorrentFileInputBlobSchema, TorrentFileInputObjectSchema]);
|
|
254
|
+
const AddTorrentParamsSchema = zod.z.object({
|
|
255
|
+
urls: zod.z.string().optional(),
|
|
256
|
+
torrents: TorrentFileInputSchema.optional(),
|
|
257
|
+
savepath: zod.z.string().optional(),
|
|
258
|
+
cookie: zod.z.string().optional(),
|
|
259
|
+
category: zod.z.string().optional(),
|
|
260
|
+
tags: zod.z.string().optional(),
|
|
261
|
+
skip_checking: zod.z.boolean().optional(),
|
|
262
|
+
paused: zod.z.boolean().optional(),
|
|
263
|
+
root_folder: zod.z.boolean().optional(),
|
|
264
|
+
rename: zod.z.string().optional(),
|
|
265
|
+
upLimit: zod.z.number().optional(),
|
|
266
|
+
dlLimit: zod.z.number().optional(),
|
|
267
|
+
ratioLimit: zod.z.number().optional(),
|
|
268
|
+
seedingTimeLimit: zod.z.number().optional(),
|
|
269
|
+
autoTMM: zod.z.boolean().optional(),
|
|
270
|
+
sequentialDownload: zod.z.boolean().optional(),
|
|
271
|
+
firstLastPiecePrio: zod.z.boolean().optional()
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
//#endregion
|
|
275
|
+
exports.AddTorrentParamsSchema = AddTorrentParamsSchema;
|
|
276
|
+
exports.PreferencesSchema = PreferencesSchema;
|
|
277
|
+
exports.QBittorrentConfigSchema = QBittorrentConfigSchema;
|
|
278
|
+
exports.TorrentFileInputSchema = TorrentFileInputSchema;
|
|
279
|
+
exports.TorrentFileSchema = TorrentFileSchema;
|
|
280
|
+
exports.TorrentInfoParamsSchema = TorrentInfoParamsSchema;
|
|
281
|
+
exports.TorrentInfoSchema = TorrentInfoSchema;
|
|
282
|
+
exports.TorrentPeerSchema = TorrentPeerSchema;
|
|
283
|
+
exports.TorrentPeersResponseSchema = TorrentPeersResponseSchema;
|
|
284
|
+
exports.TorrentPropertiesSchema = TorrentPropertiesSchema;
|
|
285
|
+
exports.TorrentStateSchema = TorrentStateSchema;
|
|
286
|
+
exports.TorrentTrackerSchema = TorrentTrackerSchema;
|
|
287
|
+
exports.TransferInfoSchema = TransferInfoSchema;
|