@ctrl/rqbit 1.0.0 → 2.0.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 +8 -10
- package/dist/src/normalizeTorrentData.js +1 -1
- package/dist/src/rqbit.d.ts +6 -5
- package/dist/src/rqbit.js +10 -3
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
npm install @ctrl/rqbit
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
Requires Node.js 24 or newer.
|
|
12
|
+
|
|
11
13
|
### Use
|
|
12
14
|
|
|
13
15
|
```ts
|
|
@@ -66,27 +68,23 @@ console.log(data);
|
|
|
66
68
|
|
|
67
69
|
##### pauseTorrent and resumeTorrent
|
|
68
70
|
|
|
69
|
-
Pause or resume
|
|
71
|
+
Pause or resume one or more torrents
|
|
70
72
|
|
|
71
73
|
```ts
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const resumed = await client.resumeTorrent('torrent-hash');
|
|
75
|
-
console.log(resumed);
|
|
74
|
+
await client.pauseTorrent('torrent-hash');
|
|
75
|
+
await client.resumeTorrent(['torrent-hash', 'other-torrent-hash']);
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
##### removeTorrent
|
|
79
79
|
|
|
80
|
-
Remove a torrent. Does not remove data on disk by default.
|
|
80
|
+
Remove one or more torrents, throws if a torrent doesn't exist. Does not remove data on disk by default.
|
|
81
81
|
|
|
82
82
|
```ts
|
|
83
83
|
// does not remove data on disk
|
|
84
|
-
|
|
85
|
-
console.log(result);
|
|
84
|
+
await client.removeTorrent('torrent-hash', false);
|
|
86
85
|
|
|
87
86
|
// remove data on disk
|
|
88
|
-
|
|
89
|
-
console.log(res);
|
|
87
|
+
await client.removeTorrent(['torrent-hash', 'other-torrent-hash'], true);
|
|
90
88
|
```
|
|
91
89
|
|
|
92
90
|
##### addTorrent
|
|
@@ -48,7 +48,7 @@ export function normalizeTorrentData(torrent, files) {
|
|
|
48
48
|
savePath: torrent.output_folder,
|
|
49
49
|
uploadSpeed: live ? Math.round(live.upload_speed.mbps * MIB) : 0,
|
|
50
50
|
downloadSpeed: live ? Math.round(live.download_speed.mbps * MIB) : 0,
|
|
51
|
-
eta: live?.time_remaining?.duration.secs ??
|
|
51
|
+
eta: stats.finished ? 0 : (live?.time_remaining?.duration.secs ?? -1),
|
|
52
52
|
// rqbit has no queue
|
|
53
53
|
queuePosition: 0,
|
|
54
54
|
// rqbit does not report seeds separately from peers
|
package/dist/src/rqbit.d.ts
CHANGED
|
@@ -89,13 +89,14 @@ export declare class Rqbit implements TorrentClient {
|
|
|
89
89
|
* rqbit requires basic auth on this url when it is enabled.
|
|
90
90
|
*/
|
|
91
91
|
getPlaylistUrl(id?: TorrentIdOrHash): string;
|
|
92
|
-
pauseTorrent(id: TorrentIdOrHash): Promise<
|
|
93
|
-
resumeTorrent(id: TorrentIdOrHash): Promise<
|
|
92
|
+
pauseTorrent(id: TorrentIdOrHash | TorrentIdOrHash[]): Promise<void>;
|
|
93
|
+
resumeTorrent(id: TorrentIdOrHash | TorrentIdOrHash[]): Promise<void>;
|
|
94
94
|
/**
|
|
95
95
|
* Remove a torrent
|
|
96
96
|
* @param removeData (default: false) If true, remove the downloaded files.
|
|
97
|
+
* @throws {RqbitApiError} when a torrent doesn't exist
|
|
97
98
|
*/
|
|
98
|
-
removeTorrent(id: TorrentIdOrHash, removeData?: boolean): Promise<
|
|
99
|
+
removeTorrent(id: TorrentIdOrHash | TorrentIdOrHash[], removeData?: boolean): Promise<void>;
|
|
99
100
|
/**
|
|
100
101
|
* Change which files are downloaded
|
|
101
102
|
* @param fileIds indexes into the torrent's file list
|
|
@@ -111,11 +112,11 @@ export declare class Rqbit implements TorrentClient {
|
|
|
111
112
|
/**
|
|
112
113
|
* rqbit does not support queueing
|
|
113
114
|
*/
|
|
114
|
-
queueUp(_id: TorrentIdOrHash): Promise<never>;
|
|
115
|
+
queueUp(_id: TorrentIdOrHash | TorrentIdOrHash[]): Promise<never>;
|
|
115
116
|
/**
|
|
116
117
|
* rqbit does not support queueing
|
|
117
118
|
*/
|
|
118
|
-
queueDown(_id: TorrentIdOrHash): Promise<never>;
|
|
119
|
+
queueDown(_id: TorrentIdOrHash | TorrentIdOrHash[]): Promise<never>;
|
|
119
120
|
/**
|
|
120
121
|
* Add a magnet link or a url to a .torrent file.
|
|
121
122
|
* rqbit resolves magnet metadata from peers before it responds, so this can take a while, see {@link RqbitConfig.addTimeout}
|
package/dist/src/rqbit.js
CHANGED
|
@@ -126,18 +126,25 @@ export class Rqbit {
|
|
|
126
126
|
return this.url(id === undefined ? '/torrents/playlist' : `/torrents/${id}/playlist`);
|
|
127
127
|
}
|
|
128
128
|
async pauseTorrent(id) {
|
|
129
|
-
|
|
129
|
+
for (const i of Array.isArray(id) ? id : [id]) {
|
|
130
|
+
await this.request(`/torrents/${i}/pause`, { method: 'POST' });
|
|
131
|
+
}
|
|
130
132
|
}
|
|
131
133
|
async resumeTorrent(id) {
|
|
132
|
-
|
|
134
|
+
for (const i of Array.isArray(id) ? id : [id]) {
|
|
135
|
+
await this.request(`/torrents/${i}/start`, { method: 'POST' });
|
|
136
|
+
}
|
|
133
137
|
}
|
|
134
138
|
/**
|
|
135
139
|
* Remove a torrent
|
|
136
140
|
* @param removeData (default: false) If true, remove the downloaded files.
|
|
141
|
+
* @throws {RqbitApiError} when a torrent doesn't exist
|
|
137
142
|
*/
|
|
138
143
|
async removeTorrent(id, removeData = false) {
|
|
139
144
|
const action = removeData ? 'delete' : 'forget';
|
|
140
|
-
|
|
145
|
+
for (const i of Array.isArray(id) ? id : [id]) {
|
|
146
|
+
await this.request(`/torrents/${i}/${action}`, { method: 'POST' });
|
|
147
|
+
}
|
|
141
148
|
}
|
|
142
149
|
/**
|
|
143
150
|
* Change which files are downloaded
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctrl/rqbit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "TypeScript api wrapper for rqbit using ofetch",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rqbit",
|
|
@@ -21,6 +21,13 @@
|
|
|
21
21
|
"sideEffects": false,
|
|
22
22
|
"main": "./dist/src/index.js",
|
|
23
23
|
"types": "./dist/src/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/src/index.d.ts",
|
|
27
|
+
"default": "./dist/src/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
24
31
|
"publishConfig": {
|
|
25
32
|
"access": "public",
|
|
26
33
|
"provenance": true
|
|
@@ -35,7 +42,7 @@
|
|
|
35
42
|
"test:watch": "vitest"
|
|
36
43
|
},
|
|
37
44
|
"dependencies": {
|
|
38
|
-
"@ctrl/shared-torrent": "^6.5.
|
|
45
|
+
"@ctrl/shared-torrent": "^6.5.4",
|
|
39
46
|
"ofetch": "^1.5.1",
|
|
40
47
|
"type-fest": "^5.10.0",
|
|
41
48
|
"ufo": "^1.6.4",
|
|
@@ -59,7 +66,7 @@
|
|
|
59
66
|
]
|
|
60
67
|
},
|
|
61
68
|
"engines": {
|
|
62
|
-
"node": ">=
|
|
69
|
+
"node": ">=24"
|
|
63
70
|
},
|
|
64
71
|
"packageManager": "pnpm@12.9.1"
|
|
65
72
|
}
|