@ctrl/qbittorrent 8.2.0 → 8.3.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/dist/src/qbittorrent.d.ts +5 -5
- package/dist/src/qbittorrent.js +22 -21
- package/package.json +7 -7
@@ -68,7 +68,7 @@ export declare class QBittorrent implements TorrentClient {
|
|
68
68
|
*/
|
69
69
|
torrentWebSeeds(hash: string): Promise<WebSeed[]>;
|
70
70
|
torrentFiles(hash: string): Promise<TorrentFile[]>;
|
71
|
-
setFilePriority(hash: string, fileIds: string | string[], priority: TorrentFilePriority): Promise<
|
71
|
+
setFilePriority(hash: string, fileIds: string | string[], priority: TorrentFilePriority): Promise<boolean>;
|
72
72
|
/**
|
73
73
|
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-pieces-states}
|
74
74
|
*/
|
@@ -158,10 +158,10 @@ export declare class QBittorrent implements TorrentClient {
|
|
158
158
|
normalizedAddTorrent(torrent: string | Uint8Array, options?: Partial<NormalizedAddTorrentOptions>): Promise<NormalizedTorrent>;
|
159
159
|
/**
|
160
160
|
* @param hash Hash for desired torrent
|
161
|
-
* @param
|
162
|
-
* @param
|
161
|
+
* @param oldPath id of the file to be renamed
|
162
|
+
* @param newPath new name to be assigned to the file
|
163
163
|
*/
|
164
|
-
renameFile(hash: string,
|
164
|
+
renameFile(hash: string, oldPath: string, newPath: string): Promise<boolean>;
|
165
165
|
/**
|
166
166
|
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#rename-folder}
|
167
167
|
*/
|
@@ -210,5 +210,5 @@ export declare class QBittorrent implements TorrentClient {
|
|
210
210
|
*/
|
211
211
|
login(): Promise<boolean>;
|
212
212
|
logout(): boolean;
|
213
|
-
request<T>(path: string, method: 'GET' | 'POST', params?: Record<string, string | number>, body?: URLSearchParams | FormData, headers?:
|
213
|
+
request<T>(path: string, method: 'GET' | 'POST', params?: Record<string, string | number>, body?: URLSearchParams | FormData, headers?: Record<string, string>, isJson?: boolean): Promise<T>;
|
214
214
|
}
|
package/dist/src/qbittorrent.js
CHANGED
@@ -168,12 +168,12 @@ export class QBittorrent {
|
|
168
168
|
return res;
|
169
169
|
}
|
170
170
|
async setFilePriority(hash, fileIds, priority) {
|
171
|
-
|
171
|
+
await this.request('/torrents/filePrio', 'POST', undefined, objToUrlSearchParams({
|
172
172
|
hash,
|
173
173
|
id: normalizeHashes(fileIds),
|
174
|
-
priority,
|
175
|
-
});
|
176
|
-
return
|
174
|
+
priority: priority.toString(),
|
175
|
+
}), undefined, false);
|
176
|
+
return true;
|
177
177
|
}
|
178
178
|
/**
|
179
179
|
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-pieces-states}
|
@@ -327,7 +327,7 @@ export class QBittorrent {
|
|
327
327
|
hashes: normalizeHashes(hashes),
|
328
328
|
deleteFiles,
|
329
329
|
};
|
330
|
-
await this.request('/torrents/delete', 'POST', undefined, objToUrlSearchParams(data));
|
330
|
+
await this.request('/torrents/delete', 'POST', undefined, objToUrlSearchParams(data), undefined, false);
|
331
331
|
return true;
|
332
332
|
}
|
333
333
|
/**
|
@@ -405,26 +405,26 @@ export class QBittorrent {
|
|
405
405
|
}
|
406
406
|
/**
|
407
407
|
* @param hash Hash for desired torrent
|
408
|
-
* @param
|
409
|
-
* @param
|
408
|
+
* @param oldPath id of the file to be renamed
|
409
|
+
* @param newPath new name to be assigned to the file
|
410
410
|
*/
|
411
|
-
async renameFile(hash,
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
411
|
+
async renameFile(hash, oldPath, newPath) {
|
412
|
+
await this.request('/torrents/renameFile', 'POST', undefined, objToUrlSearchParams({
|
413
|
+
hash,
|
414
|
+
oldPath,
|
415
|
+
newPath,
|
416
|
+
}), undefined, false);
|
417
417
|
return true;
|
418
418
|
}
|
419
419
|
/**
|
420
420
|
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#rename-folder}
|
421
421
|
*/
|
422
422
|
async renameFolder(hash, oldPath, newPath) {
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
423
|
+
await this.request('/torrents/renameFolder', 'POST', undefined, objToUrlSearchParams({
|
424
|
+
hash,
|
425
|
+
oldPath,
|
426
|
+
newPath,
|
427
|
+
}), undefined, false);
|
428
428
|
return true;
|
429
429
|
}
|
430
430
|
/**
|
@@ -566,7 +566,7 @@ export class QBittorrent {
|
|
566
566
|
return true;
|
567
567
|
}
|
568
568
|
// eslint-disable-next-line max-params
|
569
|
-
async request(path, method, params, body, headers = {},
|
569
|
+
async request(path, method, params, body, headers = {}, isJson = true) {
|
570
570
|
if (!this._sid || !this._exp || this._exp.getTime() < new Date().getTime()) {
|
571
571
|
const authed = await this.login();
|
572
572
|
if (!authed) {
|
@@ -582,10 +582,11 @@ export class QBittorrent {
|
|
582
582
|
},
|
583
583
|
body,
|
584
584
|
params,
|
585
|
-
// allow proxy agent
|
586
585
|
retry: 0,
|
587
586
|
timeout: this.config.timeout,
|
588
|
-
|
587
|
+
// casting to json to avoid type error
|
588
|
+
responseType: isJson ? 'json' : 'text',
|
589
|
+
// allow proxy agent
|
589
590
|
// @ts-expect-error for some reason agent is not in the type
|
590
591
|
agent: this.config.agent,
|
591
592
|
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ctrl/qbittorrent",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.3.0",
|
4
4
|
"description": "TypeScript api wrapper for qbittorrent using got",
|
5
5
|
"author": "Scott Cooper <scttcper@gmail.com>",
|
6
6
|
"license": "MIT",
|
@@ -47,16 +47,16 @@
|
|
47
47
|
},
|
48
48
|
"devDependencies": {
|
49
49
|
"@biomejs/biome": "1.8.3",
|
50
|
-
"@ctrl/eslint-config-biome": "
|
50
|
+
"@ctrl/eslint-config-biome": "4.1.4",
|
51
51
|
"@eslint/compat": "^1.1.1",
|
52
52
|
"@sindresorhus/tsconfig": "6.0.0",
|
53
53
|
"@types/cookie": "0.6.0",
|
54
|
-
"@types/node": "
|
55
|
-
"@vitest/coverage-v8": "2.0.
|
54
|
+
"@types/node": "22.5.0",
|
55
|
+
"@vitest/coverage-v8": "2.0.5",
|
56
56
|
"p-wait-for": "5.0.2",
|
57
|
-
"typedoc": "0.26.
|
58
|
-
"typescript": "5.5.
|
59
|
-
"vitest": "2.0.
|
57
|
+
"typedoc": "0.26.6",
|
58
|
+
"typescript": "5.5.4",
|
59
|
+
"vitest": "2.0.5"
|
60
60
|
},
|
61
61
|
"release": {
|
62
62
|
"branches": [
|