@ctrl/qbittorrent 2.8.1 → 2.10.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 +1 -1
- package/dist/index.d.ts +37 -36
- package/dist/index.js +53 -44
- package/dist/types.d.ts +1 -1
- package/package.json +18 -18
package/README.md
CHANGED
@@ -28,7 +28,7 @@ async function main() {
|
|
28
28
|
### API
|
29
29
|
|
30
30
|
Docs: https://qbittorrent.vercel.app
|
31
|
-
qBittorrent Api Docs: https://github.com/qbittorrent/qBittorrent/wiki/
|
31
|
+
qBittorrent Api Docs: https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)
|
32
32
|
|
33
33
|
### Normalized API
|
34
34
|
|
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
import { Options as GotOptions, Response } from 'got';
|
3
3
|
import { AddTorrentOptions as NormalizedAddTorrentOptions, TorrentClient, TorrentSettings } from '@ctrl/shared-torrent';
|
4
|
-
import { AddMagnetOptions, AddTorrentOptions, AllClientDataQbittorrent, BuildInfo, Categories, NormalizedTorrentQbittorrent, Preferences, Torrent, TorrentFile, TorrentFilePriority, TorrentFilters, TorrentPieceState, TorrentProperties, TorrentTrackers, WebSeed } from './types';
|
4
|
+
import { AddMagnetOptions, AddTorrentOptions, AllClientDataQbittorrent, BuildInfo, Categories, NormalizedTorrentQbittorrent, Preferences, Torrent, TorrentFile, TorrentFilePriority, TorrentFilters, TorrentPieceState, TorrentProperties, TorrentState, TorrentTrackers, TorrentTrackerStatus, WebSeed } from './types';
|
5
|
+
export { TorrentState, TorrentTrackerStatus, TorrentFilePriority, TorrentPieceState };
|
5
6
|
export declare class QBittorrent implements TorrentClient {
|
6
7
|
config: TorrentSettings;
|
7
8
|
/**
|
@@ -19,21 +20,21 @@ export declare class QBittorrent implements TorrentClient {
|
|
19
20
|
version(): Promise<string>;
|
20
21
|
/**
|
21
22
|
* Get application version
|
22
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
23
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-application-version}
|
23
24
|
*/
|
24
25
|
getAppVersion(): Promise<string>;
|
25
26
|
getApiVersion(): Promise<string>;
|
26
27
|
/**
|
27
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
28
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-build-info}
|
28
29
|
*/
|
29
30
|
getBuildInfo(): Promise<BuildInfo>;
|
30
31
|
getTorrent(hash: string): Promise<NormalizedTorrentQbittorrent>;
|
31
32
|
/**
|
32
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
33
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-application-preferences}
|
33
34
|
*/
|
34
35
|
getPreferences(): Promise<Preferences>;
|
35
36
|
/**
|
36
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
37
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-application-preferences}
|
37
38
|
*/
|
38
39
|
setPreferences(preferences: Partial<Preferences>): Promise<boolean>;
|
39
40
|
/**
|
@@ -43,77 +44,77 @@ export declare class QBittorrent implements TorrentClient {
|
|
43
44
|
* @param category Get torrents with the given category (empty string means "without category"; no "category" parameter means "any category")
|
44
45
|
* @returns list of torrents
|
45
46
|
*/
|
46
|
-
listTorrents(hashes?: string | string[], filter?: TorrentFilters, category?: string, sort?: string, offset?: number, reverse?: boolean): Promise<Torrent[]>;
|
47
|
+
listTorrents(hashes?: string | string[], filter?: TorrentFilters, category?: string, sort?: string, offset?: number, reverse?: boolean, tag?: string): Promise<Torrent[]>;
|
47
48
|
getAllData(): Promise<AllClientDataQbittorrent>;
|
48
49
|
/**
|
49
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
50
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-generic-properties}
|
50
51
|
*/
|
51
52
|
torrentProperties(hash: string): Promise<TorrentProperties>;
|
52
53
|
/**
|
53
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
54
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-trackers}
|
54
55
|
*/
|
55
56
|
torrentTrackers(hash: string): Promise<TorrentTrackers[]>;
|
56
57
|
/**
|
57
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
58
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-web-seeds}
|
58
59
|
*/
|
59
60
|
torrentWebSeeds(hash: string): Promise<WebSeed[]>;
|
60
61
|
torrentFiles(hash: string): Promise<TorrentFile[]>;
|
61
62
|
setFilePriority(hash: string, fileIds: string | string[], priority: TorrentFilePriority): Promise<TorrentFile[]>;
|
62
63
|
/**
|
63
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
64
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-pieces-states}
|
64
65
|
*/
|
65
66
|
torrentPieceStates(hash: string): Promise<TorrentPieceState[]>;
|
66
67
|
/**
|
67
68
|
* Torrents piece hashes
|
68
69
|
* @returns an array of hashes (strings) of all pieces (in order) of a specific torrent
|
69
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
70
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-pieces-hashes}
|
70
71
|
*/
|
71
72
|
torrentPieceHashes(hash: string): Promise<string[]>;
|
72
73
|
/**
|
73
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
74
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-torrent-location}
|
74
75
|
*/
|
75
76
|
setTorrentLocation(hashes: string | string[] | 'all', location: string): Promise<boolean>;
|
76
77
|
/**
|
77
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
78
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-torrent-name}
|
78
79
|
*/
|
79
80
|
setTorrentName(hash: string, name: string): Promise<boolean>;
|
80
81
|
/**
|
81
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
82
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-all-tags}
|
82
83
|
*/
|
83
84
|
getTags(): Promise<string[]>;
|
84
85
|
/**
|
85
86
|
* @param tags comma separated list
|
86
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
87
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#create-tags}
|
87
88
|
*/
|
88
89
|
createTags(tags: string): Promise<boolean>;
|
89
90
|
/**
|
90
91
|
* @param tags comma separated list
|
91
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
92
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#delete-tags}
|
92
93
|
*/
|
93
94
|
deleteTags(tags: string): Promise<boolean>;
|
94
95
|
/**
|
95
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
96
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-all-categories}
|
96
97
|
*/
|
97
98
|
getCategories(): Promise<Categories>;
|
98
99
|
/**
|
99
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
100
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#add-new-category}
|
100
101
|
*/
|
101
102
|
createCategory(category: string, savePath?: string): Promise<boolean>;
|
102
103
|
/**
|
103
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
104
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#edit-category}
|
104
105
|
*/
|
105
106
|
editCategory(category: string, savePath?: string): Promise<boolean>;
|
106
107
|
/**
|
107
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
108
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#remove-categories}
|
108
109
|
*/
|
109
110
|
removeCategory(categories: string): Promise<boolean>;
|
110
111
|
/**
|
111
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
112
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#add-torrent-tags}
|
112
113
|
*/
|
113
114
|
addTorrentTags(hashes: string | string[] | 'all', tags: string): Promise<boolean>;
|
114
115
|
/**
|
115
116
|
* if tags are not passed, removes all tags
|
116
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
117
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#remove-torrent-tags}
|
117
118
|
*/
|
118
119
|
removeTorrentTags(hashes: string | string[] | 'all', tags?: string): Promise<boolean>;
|
119
120
|
/**
|
@@ -121,27 +122,27 @@ export declare class QBittorrent implements TorrentClient {
|
|
121
122
|
*/
|
122
123
|
resetTorrentCategory(hashes: string | string[] | 'all'): Promise<boolean>;
|
123
124
|
/**
|
124
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
125
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-torrent-category}
|
125
126
|
*/
|
126
127
|
setTorrentCategory(hashes: string | string[] | 'all', category?: string): Promise<boolean>;
|
127
128
|
/**
|
128
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
129
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#pause-torrents}
|
129
130
|
*/
|
130
131
|
pauseTorrent(hashes: string | string[] | 'all'): Promise<boolean>;
|
131
132
|
/**
|
132
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
133
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#resume-torrents}
|
133
134
|
*/
|
134
135
|
resumeTorrent(hashes: string | string[] | 'all'): Promise<boolean>;
|
135
136
|
/**
|
136
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
137
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#delete-torrents}
|
137
138
|
*/
|
138
139
|
removeTorrent(hashes: string | string[] | 'all', deleteFiles?: boolean): Promise<boolean>;
|
139
140
|
/**
|
140
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
141
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#recheck-torrents}
|
141
142
|
*/
|
142
143
|
recheckTorrent(hashes: string | string[] | 'all'): Promise<boolean>;
|
143
144
|
/**
|
144
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
145
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#reannounce-torrents}
|
145
146
|
*/
|
146
147
|
reannounceTorrent(hashes: string | string[] | 'all'): Promise<boolean>;
|
147
148
|
addTorrent(torrent: string | Buffer, options?: Partial<AddTorrentOptions>): Promise<boolean>;
|
@@ -158,35 +159,35 @@ export declare class QBittorrent implements TorrentClient {
|
|
158
159
|
*/
|
159
160
|
addMagnet(urls: string, options?: Partial<AddMagnetOptions>): Promise<boolean>;
|
160
161
|
/**
|
161
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
162
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#add-trackers-to-torrent}
|
162
163
|
*/
|
163
164
|
addTrackers(hash: string, urls: string): Promise<boolean>;
|
164
165
|
/**
|
165
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
166
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#edit-trackers}
|
166
167
|
*/
|
167
168
|
editTrackers(hash: string, origUrl: string, newUrl: string): Promise<boolean>;
|
168
169
|
/**
|
169
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
170
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#remove-trackers}
|
170
171
|
*/
|
171
172
|
removeTrackers(hash: string, urls: string): Promise<boolean>;
|
172
173
|
/**
|
173
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
174
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#increase-torrent-priority}
|
174
175
|
*/
|
175
176
|
queueUp(hashes: string | string[] | 'all'): Promise<boolean>;
|
176
177
|
/**
|
177
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
178
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#decrease-torrent-priority}
|
178
179
|
*/
|
179
180
|
queueDown(hashes: string | string[] | 'all'): Promise<boolean>;
|
180
181
|
/**
|
181
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
182
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#maximal-torrent-priority}
|
182
183
|
*/
|
183
184
|
topPriority(hashes: string | string[] | 'all'): Promise<boolean>;
|
184
185
|
/**
|
185
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
186
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#minimal-torrent-priority}
|
186
187
|
*/
|
187
188
|
bottomPriority(hashes: string | string[] | 'all'): Promise<boolean>;
|
188
189
|
/**
|
189
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
190
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#login}
|
190
191
|
*/
|
191
192
|
login(): Promise<boolean>;
|
192
193
|
logout(): boolean;
|
package/dist/index.js
CHANGED
@@ -3,17 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.QBittorrent = void 0;
|
6
|
+
exports.QBittorrent = exports.TorrentPieceState = exports.TorrentFilePriority = exports.TorrentTrackerStatus = exports.TorrentState = void 0;
|
7
7
|
/* eslint-disable @typescript-eslint/ban-types */
|
8
8
|
const fs_1 = require("fs");
|
9
9
|
const url_1 = require("url");
|
10
10
|
const form_data_1 = __importDefault(require("form-data"));
|
11
11
|
const got_1 = __importDefault(require("got"));
|
12
12
|
const tough_cookie_1 = require("tough-cookie");
|
13
|
-
const url_join_1 = require("@ctrl/url-join");
|
14
|
-
const torrent_file_1 = require("@ctrl/torrent-file");
|
15
13
|
const shared_torrent_1 = require("@ctrl/shared-torrent");
|
14
|
+
const torrent_file_1 = require("@ctrl/torrent-file");
|
15
|
+
const url_join_1 = require("@ctrl/url-join");
|
16
16
|
const types_1 = require("./types");
|
17
|
+
Object.defineProperty(exports, "TorrentFilePriority", { enumerable: true, get: function () { return types_1.TorrentFilePriority; } });
|
18
|
+
Object.defineProperty(exports, "TorrentPieceState", { enumerable: true, get: function () { return types_1.TorrentPieceState; } });
|
19
|
+
Object.defineProperty(exports, "TorrentState", { enumerable: true, get: function () { return types_1.TorrentState; } });
|
20
|
+
Object.defineProperty(exports, "TorrentTrackerStatus", { enumerable: true, get: function () { return types_1.TorrentTrackerStatus; } });
|
17
21
|
const defaults = {
|
18
22
|
baseUrl: 'http://localhost:9091/',
|
19
23
|
path: '/api/v2',
|
@@ -33,7 +37,7 @@ class QBittorrent {
|
|
33
37
|
}
|
34
38
|
/**
|
35
39
|
* Get application version
|
36
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
40
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-application-version}
|
37
41
|
*/
|
38
42
|
async getAppVersion() {
|
39
43
|
const res = await this.request('/app/version', 'GET', undefined, undefined, undefined, false);
|
@@ -44,7 +48,7 @@ class QBittorrent {
|
|
44
48
|
return res.body;
|
45
49
|
}
|
46
50
|
/**
|
47
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
51
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-build-info}
|
48
52
|
*/
|
49
53
|
async getBuildInfo() {
|
50
54
|
const res = await this.request('/app/buildInfo', 'GET');
|
@@ -59,14 +63,14 @@ class QBittorrent {
|
|
59
63
|
return this._normalizeTorrentData(torrentData);
|
60
64
|
}
|
61
65
|
/**
|
62
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
66
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-application-preferences}
|
63
67
|
*/
|
64
68
|
async getPreferences() {
|
65
69
|
const res = await this.request('/app/preferences', 'GET');
|
66
70
|
return res.body;
|
67
71
|
}
|
68
72
|
/**
|
69
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
73
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-application-preferences}
|
70
74
|
*/
|
71
75
|
async setPreferences(preferences) {
|
72
76
|
const form = new form_data_1.default();
|
@@ -82,7 +86,9 @@ class QBittorrent {
|
|
82
86
|
* @returns list of torrents
|
83
87
|
*/
|
84
88
|
// eslint-disable-next-line max-params
|
85
|
-
async listTorrents(hashes, filter, category, sort, offset, reverse
|
89
|
+
async listTorrents(hashes, filter, category, sort, offset, reverse,
|
90
|
+
// TODO: refactor filters into an object with optional properties
|
91
|
+
tag) {
|
86
92
|
const params = {};
|
87
93
|
if (hashes) {
|
88
94
|
params.hashes = this._normalizeHashes(hashes);
|
@@ -93,6 +99,9 @@ class QBittorrent {
|
|
93
99
|
if (category) {
|
94
100
|
params.category = category;
|
95
101
|
}
|
102
|
+
if (tag) {
|
103
|
+
params.tag = tag;
|
104
|
+
}
|
96
105
|
if (offset !== undefined) {
|
97
106
|
params.offset = `${offset}`;
|
98
107
|
}
|
@@ -132,21 +141,21 @@ class QBittorrent {
|
|
132
141
|
return results;
|
133
142
|
}
|
134
143
|
/**
|
135
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
144
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-generic-properties}
|
136
145
|
*/
|
137
146
|
async torrentProperties(hash) {
|
138
147
|
const res = await this.request('/torrents/properties', 'GET', { hash });
|
139
148
|
return res.body;
|
140
149
|
}
|
141
150
|
/**
|
142
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
151
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-trackers}
|
143
152
|
*/
|
144
153
|
async torrentTrackers(hash) {
|
145
154
|
const res = await this.request('/torrents/trackers', 'GET', { hash });
|
146
155
|
return res.body;
|
147
156
|
}
|
148
157
|
/**
|
149
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
158
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-web-seeds}
|
150
159
|
*/
|
151
160
|
async torrentWebSeeds(hash) {
|
152
161
|
const res = await this.request('/torrents/webseeds', 'GET', { hash });
|
@@ -165,7 +174,7 @@ class QBittorrent {
|
|
165
174
|
return res.body;
|
166
175
|
}
|
167
176
|
/**
|
168
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
177
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-pieces-states}
|
169
178
|
*/
|
170
179
|
async torrentPieceStates(hash) {
|
171
180
|
const res = await this.request('/torrents/pieceStates', 'GET', { hash });
|
@@ -174,14 +183,14 @@ class QBittorrent {
|
|
174
183
|
/**
|
175
184
|
* Torrents piece hashes
|
176
185
|
* @returns an array of hashes (strings) of all pieces (in order) of a specific torrent
|
177
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
186
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-pieces-hashes}
|
178
187
|
*/
|
179
188
|
async torrentPieceHashes(hash) {
|
180
189
|
const res = await this.request('/torrents/pieceHashes', 'GET', { hash });
|
181
190
|
return res.body;
|
182
191
|
}
|
183
192
|
/**
|
184
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
193
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-torrent-location}
|
185
194
|
*/
|
186
195
|
async setTorrentLocation(hashes, location) {
|
187
196
|
const form = new form_data_1.default();
|
@@ -191,7 +200,7 @@ class QBittorrent {
|
|
191
200
|
return true;
|
192
201
|
}
|
193
202
|
/**
|
194
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
203
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-torrent-name}
|
195
204
|
*/
|
196
205
|
async setTorrentName(hash, name) {
|
197
206
|
const form = new form_data_1.default();
|
@@ -201,7 +210,7 @@ class QBittorrent {
|
|
201
210
|
return true;
|
202
211
|
}
|
203
212
|
/**
|
204
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
213
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-all-tags}
|
205
214
|
*/
|
206
215
|
async getTags() {
|
207
216
|
const res = await this.request('/torrents/tags', 'get');
|
@@ -209,7 +218,7 @@ class QBittorrent {
|
|
209
218
|
}
|
210
219
|
/**
|
211
220
|
* @param tags comma separated list
|
212
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
221
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#create-tags}
|
213
222
|
*/
|
214
223
|
async createTags(tags) {
|
215
224
|
const form = new form_data_1.default();
|
@@ -219,7 +228,7 @@ class QBittorrent {
|
|
219
228
|
}
|
220
229
|
/**
|
221
230
|
* @param tags comma separated list
|
222
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
231
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#delete-tags}
|
223
232
|
*/
|
224
233
|
async deleteTags(tags) {
|
225
234
|
const form = new form_data_1.default();
|
@@ -228,14 +237,14 @@ class QBittorrent {
|
|
228
237
|
return true;
|
229
238
|
}
|
230
239
|
/**
|
231
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
240
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-all-categories}
|
232
241
|
*/
|
233
242
|
async getCategories() {
|
234
243
|
const res = await this.request('/torrents/categories', 'get');
|
235
244
|
return res.body;
|
236
245
|
}
|
237
246
|
/**
|
238
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
247
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#add-new-category}
|
239
248
|
*/
|
240
249
|
async createCategory(category, savePath = '') {
|
241
250
|
const form = new form_data_1.default();
|
@@ -245,7 +254,7 @@ class QBittorrent {
|
|
245
254
|
return true;
|
246
255
|
}
|
247
256
|
/**
|
248
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
257
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#edit-category}
|
249
258
|
*/
|
250
259
|
async editCategory(category, savePath = '') {
|
251
260
|
const form = new form_data_1.default();
|
@@ -255,7 +264,7 @@ class QBittorrent {
|
|
255
264
|
return true;
|
256
265
|
}
|
257
266
|
/**
|
258
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
267
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#remove-categories}
|
259
268
|
*/
|
260
269
|
async removeCategory(categories) {
|
261
270
|
const form = new form_data_1.default();
|
@@ -264,7 +273,7 @@ class QBittorrent {
|
|
264
273
|
return true;
|
265
274
|
}
|
266
275
|
/**
|
267
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
276
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#add-torrent-tags}
|
268
277
|
*/
|
269
278
|
async addTorrentTags(hashes, tags) {
|
270
279
|
const form = new form_data_1.default();
|
@@ -275,7 +284,7 @@ class QBittorrent {
|
|
275
284
|
}
|
276
285
|
/**
|
277
286
|
* if tags are not passed, removes all tags
|
278
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
287
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#remove-torrent-tags}
|
279
288
|
*/
|
280
289
|
async removeTorrentTags(hashes, tags) {
|
281
290
|
const form = new form_data_1.default();
|
@@ -293,7 +302,7 @@ class QBittorrent {
|
|
293
302
|
return this.setTorrentCategory(hashes);
|
294
303
|
}
|
295
304
|
/**
|
296
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
305
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-torrent-category}
|
297
306
|
*/
|
298
307
|
async setTorrentCategory(hashes, category = '') {
|
299
308
|
const form = new form_data_1.default();
|
@@ -303,7 +312,7 @@ class QBittorrent {
|
|
303
312
|
return true;
|
304
313
|
}
|
305
314
|
/**
|
306
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
315
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#pause-torrents}
|
307
316
|
*/
|
308
317
|
async pauseTorrent(hashes) {
|
309
318
|
const params = {
|
@@ -313,7 +322,7 @@ class QBittorrent {
|
|
313
322
|
return true;
|
314
323
|
}
|
315
324
|
/**
|
316
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
325
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#resume-torrents}
|
317
326
|
*/
|
318
327
|
async resumeTorrent(hashes) {
|
319
328
|
const params = {
|
@@ -323,7 +332,7 @@ class QBittorrent {
|
|
323
332
|
return true;
|
324
333
|
}
|
325
334
|
/**
|
326
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
335
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#delete-torrents}
|
327
336
|
*/
|
328
337
|
async removeTorrent(hashes, deleteFiles = true) {
|
329
338
|
const params = {
|
@@ -334,7 +343,7 @@ class QBittorrent {
|
|
334
343
|
return true;
|
335
344
|
}
|
336
345
|
/**
|
337
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
346
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#recheck-torrents}
|
338
347
|
*/
|
339
348
|
async recheckTorrent(hashes) {
|
340
349
|
const params = {
|
@@ -344,7 +353,7 @@ class QBittorrent {
|
|
344
353
|
return true;
|
345
354
|
}
|
346
355
|
/**
|
347
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
356
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#reannounce-torrents}
|
348
357
|
*/
|
349
358
|
async reannounceTorrent(hashes) {
|
350
359
|
const params = {
|
@@ -365,8 +374,8 @@ class QBittorrent {
|
|
365
374
|
delete options.filename;
|
366
375
|
}
|
367
376
|
if (typeof torrent === 'string') {
|
368
|
-
if (fs_1.existsSync(torrent)) {
|
369
|
-
form.append('file', Buffer.from(fs_1.readFileSync(torrent)), fileOptions);
|
377
|
+
if ((0, fs_1.existsSync)(torrent)) {
|
378
|
+
form.append('file', Buffer.from((0, fs_1.readFileSync)(torrent)), fileOptions);
|
370
379
|
}
|
371
380
|
else {
|
372
381
|
form.append('file', Buffer.from(torrent, 'base64'), fileOptions);
|
@@ -404,7 +413,7 @@ class QBittorrent {
|
|
404
413
|
if (!Buffer.isBuffer(torrent)) {
|
405
414
|
torrent = Buffer.from(torrent);
|
406
415
|
}
|
407
|
-
const torrentHash = await torrent_file_1.hash(torrent);
|
416
|
+
const torrentHash = await (0, torrent_file_1.hash)(torrent);
|
408
417
|
await this.addTorrent(torrent, torrentOptions);
|
409
418
|
return this.getTorrent(torrentHash);
|
410
419
|
}
|
@@ -447,7 +456,7 @@ class QBittorrent {
|
|
447
456
|
return true;
|
448
457
|
}
|
449
458
|
/**
|
450
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
459
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#add-trackers-to-torrent}
|
451
460
|
*/
|
452
461
|
async addTrackers(hash, urls) {
|
453
462
|
const params = { hash, urls };
|
@@ -455,7 +464,7 @@ class QBittorrent {
|
|
455
464
|
return true;
|
456
465
|
}
|
457
466
|
/**
|
458
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
467
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#edit-trackers}
|
459
468
|
*/
|
460
469
|
async editTrackers(hash, origUrl, newUrl) {
|
461
470
|
const params = { hash, origUrl, newUrl };
|
@@ -463,7 +472,7 @@ class QBittorrent {
|
|
463
472
|
return true;
|
464
473
|
}
|
465
474
|
/**
|
466
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
475
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#remove-trackers}
|
467
476
|
*/
|
468
477
|
async removeTrackers(hash, urls) {
|
469
478
|
const params = { hash, urls };
|
@@ -471,7 +480,7 @@ class QBittorrent {
|
|
471
480
|
return true;
|
472
481
|
}
|
473
482
|
/**
|
474
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
483
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#increase-torrent-priority}
|
475
484
|
*/
|
476
485
|
async queueUp(hashes) {
|
477
486
|
const params = {
|
@@ -481,7 +490,7 @@ class QBittorrent {
|
|
481
490
|
return true;
|
482
491
|
}
|
483
492
|
/**
|
484
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
493
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#decrease-torrent-priority}
|
485
494
|
*/
|
486
495
|
async queueDown(hashes) {
|
487
496
|
const params = {
|
@@ -491,7 +500,7 @@ class QBittorrent {
|
|
491
500
|
return true;
|
492
501
|
}
|
493
502
|
/**
|
494
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
503
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#maximal-torrent-priority}
|
495
504
|
*/
|
496
505
|
async topPriority(hashes) {
|
497
506
|
const params = {
|
@@ -501,7 +510,7 @@ class QBittorrent {
|
|
501
510
|
return true;
|
502
511
|
}
|
503
512
|
/**
|
504
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
513
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#minimal-torrent-priority}
|
505
514
|
*/
|
506
515
|
async bottomPriority(hashes) {
|
507
516
|
const params = {
|
@@ -511,10 +520,10 @@ class QBittorrent {
|
|
511
520
|
return true;
|
512
521
|
}
|
513
522
|
/**
|
514
|
-
* @link https://github.com/qbittorrent/qBittorrent/wiki/
|
523
|
+
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#login}
|
515
524
|
*/
|
516
525
|
async login() {
|
517
|
-
const url = url_join_1.urlJoin(this.config.baseUrl, this.config.path, '/auth/login');
|
526
|
+
const url = (0, url_join_1.urlJoin)(this.config.baseUrl, this.config.path, '/auth/login');
|
518
527
|
const form = new form_data_1.default();
|
519
528
|
form.append('username', this.config.username);
|
520
529
|
form.append('password', this.config.password);
|
@@ -552,8 +561,8 @@ class QBittorrent {
|
|
552
561
|
throw new Error('Auth Failed');
|
553
562
|
}
|
554
563
|
}
|
555
|
-
const url = url_join_1.urlJoin(this.config.baseUrl, this.config.path, path);
|
556
|
-
const res = await got_1.default(url, {
|
564
|
+
const url = (0, url_join_1.urlJoin)(this.config.baseUrl, this.config.path, path);
|
565
|
+
const res = await (0, got_1.default)(url, {
|
557
566
|
isStream: false,
|
558
567
|
resolveBodyOnly: false,
|
559
568
|
method,
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ctrl/qbittorrent",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.10.0",
|
4
4
|
"description": "TypeScript api wrapper for qbittorrent using got",
|
5
5
|
"author": "Scott Cooper <scttcper@gmail.com>",
|
6
6
|
"license": "MIT",
|
@@ -23,32 +23,32 @@
|
|
23
23
|
"lint:fix": "eslint --fix --ext .js,.ts, .",
|
24
24
|
"prepare": "npm run build",
|
25
25
|
"build": "tsc -p tsconfig.build.json",
|
26
|
-
"build:docs": "typedoc
|
26
|
+
"build:docs": "typedoc",
|
27
27
|
"test": "jest --runInBand",
|
28
28
|
"test:watch": "jest --watch --runInBand",
|
29
29
|
"test:ci": "jest --ci --reporters=default --reporters=jest-junit --runInBand --coverage"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@ctrl/shared-torrent": "^3.0.
|
33
|
-
"@ctrl/torrent-file": "^1.3.
|
34
|
-
"@ctrl/url-join": "^1.0.
|
35
|
-
"form-data": "^
|
36
|
-
"got": "^11.8.
|
32
|
+
"@ctrl/shared-torrent": "^3.0.5",
|
33
|
+
"@ctrl/torrent-file": "^1.3.3",
|
34
|
+
"@ctrl/url-join": "^1.0.4",
|
35
|
+
"form-data": "^4.0.0",
|
36
|
+
"got": "^11.8.2",
|
37
37
|
"tough-cookie": "^4.0.0"
|
38
38
|
},
|
39
39
|
"devDependencies": {
|
40
|
-
"@babel/plugin-transform-modules-commonjs": "7.
|
41
|
-
"@babel/preset-typescript": "7.
|
42
|
-
"@ctrl/eslint-config": "1.
|
43
|
-
"@jest/globals": "
|
40
|
+
"@babel/plugin-transform-modules-commonjs": "7.16.0",
|
41
|
+
"@babel/preset-typescript": "7.16.0",
|
42
|
+
"@ctrl/eslint-config": "3.1.1",
|
43
|
+
"@jest/globals": "27.3.1",
|
44
44
|
"@types/form-data": "2.5.0",
|
45
|
-
"@types/node": "
|
46
|
-
"@types/tough-cookie": "4.0.
|
47
|
-
"jest": "
|
48
|
-
"jest
|
49
|
-
"p-wait-for": "3.
|
50
|
-
"typedoc": "0.
|
51
|
-
"typescript": "4.
|
45
|
+
"@types/node": "16.11.6",
|
46
|
+
"@types/tough-cookie": "4.0.1",
|
47
|
+
"jest-junit": "13.0.0",
|
48
|
+
"jest": "27.3.1",
|
49
|
+
"p-wait-for": "3.2.0",
|
50
|
+
"typedoc": "0.22.8",
|
51
|
+
"typescript": "4.4.4"
|
52
52
|
},
|
53
53
|
"jest": {
|
54
54
|
"testEnvironment": "node"
|