@ctrl/qbittorrent 9.2.0 → 9.4.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.
@@ -14,6 +14,7 @@ export function normalizeTorrentData(torrent) {
14
14
  stateMessage = 'qBittorrent is reporting an error';
15
15
  break;
16
16
  case TorrentState.PausedDL:
17
+ case TorrentState.StoppedDL:
17
18
  state = NormalizedTorrentState.paused;
18
19
  break;
19
20
  case TorrentState.QueuedDL: // queuing is enabled and torrent is queued for download
@@ -35,7 +36,8 @@ export function normalizeTorrentData(torrent) {
35
36
  state = NormalizedTorrentState.warning;
36
37
  stateMessage = 'The download is stalled with no connection';
37
38
  break;
38
- case TorrentState.PausedUP: // torrent is paused and has finished downloading:
39
+ case TorrentState.StoppedUP: // torrent is paused and has finished downloading
40
+ case TorrentState.PausedUP: // torrent is paused and has finished downloading
39
41
  case TorrentState.Uploading: // torrent is being seeded and data is being transferred
40
42
  case TorrentState.StalledUP: // torrent is being seeded, but no connection were made
41
43
  case TorrentState.QueuedUP: // queuing is enabled and torrent is queued for upload
@@ -1,6 +1,6 @@
1
1
  import type { Jsonify } from 'type-fest';
2
2
  import type { AddTorrentOptions as NormalizedAddTorrentOptions, AllClientData, NormalizedTorrent, TorrentClient, TorrentClientConfig, TorrentClientState } from '@ctrl/shared-torrent';
3
- import type { AddMagnetOptions, AddTorrentOptions, BuildInfo, Preferences, Torrent, TorrentCategories, TorrentFile, TorrentFilePriority, TorrentFilters, TorrentPeersResponse, TorrentPieceState, TorrentProperties, TorrentTrackers, WebSeed } from './types.js';
3
+ import type { AddMagnetOptions, AddTorrentOptions, BuildInfo, DownloadSpeed, Preferences, Torrent, TorrentCategories, TorrentFile, TorrentFilePriority, TorrentFilters, TorrentPeersResponse, TorrentPieceState, TorrentProperties, TorrentTrackers, UploadSpeed, WebSeed } from './types.js';
4
4
  interface QBittorrentState extends TorrentClientState {
5
5
  auth?: {
6
6
  /**
@@ -48,6 +48,22 @@ export declare class QBittorrent implements TorrentClient {
48
48
  */
49
49
  getBuildInfo(): Promise<BuildInfo>;
50
50
  getTorrent(hash: string): Promise<NormalizedTorrent>;
51
+ /**
52
+ * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-download-limit}
53
+ */
54
+ getTorrentDownloadLimit(hash: string | string[]): Promise<DownloadSpeed>;
55
+ /**
56
+ * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-torrent-download-limit}
57
+ */
58
+ setTorrentDownloadLimit(hash: string | string[], limitBytesPerSecond: number): Promise<boolean>;
59
+ /**
60
+ * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-upload-limit}
61
+ */
62
+ getTorrentUploadLimit(hash: string | string[]): Promise<UploadSpeed>;
63
+ /**
64
+ * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-torrent-upload-limit}
65
+ */
66
+ setTorrentUploadLimit(hash: string | string[], limitBytesPerSecond: number): Promise<boolean>;
51
67
  /**
52
68
  * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-application-preferences}
53
69
  */
@@ -76,6 +76,46 @@ export class QBittorrent {
76
76
  }
77
77
  return normalizeTorrentData(torrentData);
78
78
  }
79
+ /**
80
+ * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-download-limit}
81
+ */
82
+ async getTorrentDownloadLimit(hash) {
83
+ const downloadLimit = await this.request('/torrents/downloadLimit', 'POST', undefined, objToUrlSearchParams({
84
+ hashes: normalizeHashes(hash),
85
+ }), undefined);
86
+ return downloadLimit;
87
+ }
88
+ /**
89
+ * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-torrent-download-limit}
90
+ */
91
+ async setTorrentDownloadLimit(hash, limitBytesPerSecond) {
92
+ const data = {
93
+ limit: limitBytesPerSecond.toString(),
94
+ hashes: normalizeHashes(hash),
95
+ };
96
+ await this.request('/torrents/setDownloadLimit', 'POST', undefined, objToUrlSearchParams(data));
97
+ return true;
98
+ }
99
+ /**
100
+ * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-upload-limit}
101
+ */
102
+ async getTorrentUploadLimit(hash) {
103
+ const UploadLimit = await this.request('/torrents/uploadLimit', 'POST', undefined, objToUrlSearchParams({
104
+ hashes: normalizeHashes(hash),
105
+ }), undefined);
106
+ return UploadLimit;
107
+ }
108
+ /**
109
+ * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-torrent-upload-limit}
110
+ */
111
+ async setTorrentUploadLimit(hash, limitBytesPerSecond) {
112
+ const data = {
113
+ limit: limitBytesPerSecond.toString(),
114
+ hashes: normalizeHashes(hash),
115
+ };
116
+ await this.request('/torrents/setUploadLimit', 'POST', undefined, objToUrlSearchParams(data));
117
+ return true;
118
+ }
79
119
  /**
80
120
  * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-application-preferences}
81
121
  */
@@ -187,10 +187,12 @@ export declare enum TorrentState {
187
187
  Error = "error",
188
188
  /**
189
189
  * Torrent is paused and has finished downloading
190
+ * ``pausedUP`` was renamed to ``stoppedUP`` in Web API v2.11.0
190
191
  */
191
192
  PausedUP = "pausedUP",
192
193
  /**
193
194
  * Torrent is paused and has NOT finished downloading
195
+ * ``pausedDL`` was renamed to ``stoppedDL`` in Web API v2.11.0
194
196
  */
195
197
  PausedDL = "pausedDL",
196
198
  /**
@@ -221,6 +223,14 @@ export declare enum TorrentState {
221
223
  * Torrent is being downloaded and data is being transferred
222
224
  */
223
225
  Downloading = "downloading",
226
+ /**
227
+ * Torrent has been stopped while downloading
228
+ */
229
+ StoppedDL = "stoppedDL",
230
+ /**
231
+ * Torrent has been stopped while downloading
232
+ */
233
+ StoppedUP = "stoppedUP",
224
234
  /**
225
235
  * Torrent is being downloaded, but no connection were made
226
236
  */
@@ -1268,4 +1278,6 @@ export interface TorrentPeer {
1268
1278
  up_speed?: number;
1269
1279
  uploaded?: number;
1270
1280
  }
1281
+ export type DownloadSpeed = Record<string, number>;
1282
+ export type UploadSpeed = Record<string, number>;
1271
1283
  export {};
package/dist/src/types.js CHANGED
@@ -6,10 +6,12 @@ export var TorrentState;
6
6
  TorrentState["Error"] = "error";
7
7
  /**
8
8
  * Torrent is paused and has finished downloading
9
+ * ``pausedUP`` was renamed to ``stoppedUP`` in Web API v2.11.0
9
10
  */
10
11
  TorrentState["PausedUP"] = "pausedUP";
11
12
  /**
12
13
  * Torrent is paused and has NOT finished downloading
14
+ * ``pausedDL`` was renamed to ``stoppedDL`` in Web API v2.11.0
13
15
  */
14
16
  TorrentState["PausedDL"] = "pausedDL";
15
17
  /**
@@ -40,6 +42,14 @@ export var TorrentState;
40
42
  * Torrent is being downloaded and data is being transferred
41
43
  */
42
44
  TorrentState["Downloading"] = "downloading";
45
+ /**
46
+ * Torrent has been stopped while downloading
47
+ */
48
+ TorrentState["StoppedDL"] = "stoppedDL";
49
+ /**
50
+ * Torrent has been stopped while downloading
51
+ */
52
+ TorrentState["StoppedUP"] = "stoppedUP";
43
53
  /**
44
54
  * Torrent is being downloaded, but no connection were made
45
55
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/qbittorrent",
3
- "version": "9.2.0",
3
+ "version": "9.4.0",
4
4
  "description": "TypeScript api wrapper for qbittorrent using got",
5
5
  "author": "Scott Cooper <scttcper@gmail.com>",
6
6
  "license": "MIT",
@@ -40,24 +40,25 @@
40
40
  "@ctrl/shared-torrent": "^6.2.1",
41
41
  "@ctrl/torrent-file": "^4.1.0",
42
42
  "cookie": "^1.0.2",
43
- "node-fetch-native": "^1.6.4",
43
+ "node-fetch-native": "^1.6.6",
44
44
  "ofetch": "^1.4.1",
45
- "type-fest": "^4.30.2",
45
+ "type-fest": "^4.34.1",
46
46
  "ufo": "^1.5.4",
47
47
  "uint8array-extras": "^1.4.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@biomejs/biome": "1.9.4",
51
- "@ctrl/eslint-config-biome": "4.3.1",
52
- "@eslint/compat": "^1.2.4",
51
+ "@ctrl/eslint-config-biome": "4.3.2",
52
+ "@eslint/compat": "^1.2.6",
53
53
  "@sindresorhus/tsconfig": "7.0.0",
54
54
  "@types/cookie": "1.0.0",
55
- "@types/node": "22.10.2",
56
- "@vitest/coverage-v8": "2.1.8",
55
+ "@types/node": "22.13.1",
56
+ "@vitest/coverage-v8": "3.0.5",
57
+ "eslint": "^9.20.1",
57
58
  "p-wait-for": "5.0.2",
58
- "typedoc": "0.27.5",
59
- "typescript": "5.7.2",
60
- "vitest": "2.1.8"
59
+ "typedoc": "0.27.7",
60
+ "typescript": "5.7.3",
61
+ "vitest": "3.0.5"
61
62
  },
62
63
  "release": {
63
64
  "branches": [