@ctrl/qbittorrent 7.0.0 → 7.1.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/src/qbittorrent.js +12 -8
- package/package.json +13 -13
package/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# qBittorrent [](https://www.npmjs.com/package/@ctrl/qbittorrent) [](https://codecov.io/gh/scttcper/qbittorrent)
|
2
2
|
|
3
|
-
> TypeScript api wrapper for [qBittorrent](https://www.qbittorrent.org/) using [
|
3
|
+
> TypeScript api wrapper for [qBittorrent](https://www.qbittorrent.org/) using [ofetch](https://github.com/unjs/ofetch)
|
4
4
|
|
5
5
|
### Install
|
6
6
|
|
package/dist/src/qbittorrent.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
+
import { parse as cookieParse } from 'cookie';
|
1
2
|
import { FormData } from 'node-fetch-native';
|
2
3
|
import { ofetch } from 'ofetch';
|
3
|
-
import { Cookie } from 'tough-cookie';
|
4
4
|
import { joinURL } from 'ufo';
|
5
5
|
import { magnetDecode } from '@ctrl/magnet-link';
|
6
6
|
import { hash } from '@ctrl/torrent-file';
|
@@ -187,10 +187,11 @@ export class QBittorrent {
|
|
187
187
|
* {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#set-torrent-location}
|
188
188
|
*/
|
189
189
|
async setTorrentLocation(hashes, location) {
|
190
|
-
|
190
|
+
const data = {
|
191
191
|
location,
|
192
192
|
hashes: normalizeHashes(hashes),
|
193
|
-
}
|
193
|
+
};
|
194
|
+
await this.request('/torrents/setLocation', 'POST', undefined, objToUrlSearchParams(data));
|
194
195
|
return true;
|
195
196
|
}
|
196
197
|
/**
|
@@ -529,17 +530,20 @@ export class QBittorrent {
|
|
529
530
|
redirect: 'manual',
|
530
531
|
retry: false,
|
531
532
|
timeout: this.config.timeout,
|
532
|
-
|
533
|
+
...(this.config.agent ? { agent: this.config.agent } : {}),
|
533
534
|
});
|
534
535
|
if (!res.headers.get('set-cookie')?.length) {
|
535
536
|
throw new Error('Cookie not found. Auth Failed.');
|
536
537
|
}
|
537
|
-
const cookie =
|
538
|
-
if (!cookie
|
538
|
+
const cookie = cookieParse(res.headers.get('set-cookie'));
|
539
|
+
if (!cookie.SID) {
|
539
540
|
throw new Error('Invalid cookie');
|
540
541
|
}
|
541
|
-
this._sid = cookie.
|
542
|
-
|
542
|
+
this._sid = cookie.SID;
|
543
|
+
// Not sure if it might be lowercase
|
544
|
+
const expires = cookie.Expires ?? cookie.expires;
|
545
|
+
// Default expiration is expected to be 1 hour
|
546
|
+
this._exp = expires ? new Date(expires) : new Date(Date.now() + 3600000);
|
543
547
|
return true;
|
544
548
|
}
|
545
549
|
logout() {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ctrl/qbittorrent",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.1.0",
|
4
4
|
"description": "TypeScript api wrapper for qbittorrent using got",
|
5
5
|
"author": "Scott Cooper <scttcper@gmail.com>",
|
6
6
|
"license": "MIT",
|
@@ -32,24 +32,24 @@
|
|
32
32
|
"test:ci": "vitest run --coverage --reporter=default --reporter=junit --outputFile=./junit.xml"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
|
-
"@ctrl/magnet-link": "^
|
35
|
+
"@ctrl/magnet-link": "^4.0.1",
|
36
36
|
"@ctrl/shared-torrent": "^5.0.0",
|
37
37
|
"@ctrl/torrent-file": "^3.0.0",
|
38
|
-
"
|
38
|
+
"cookie": "^0.6.0",
|
39
|
+
"node-fetch-native": "^1.6.1",
|
39
40
|
"ofetch": "^1.3.3",
|
40
|
-
"
|
41
|
-
"ufo": "^1.3.0"
|
41
|
+
"ufo": "^1.3.2"
|
42
42
|
},
|
43
43
|
"devDependencies": {
|
44
|
-
"@ctrl/eslint-config": "4.0.
|
45
|
-
"@sindresorhus/tsconfig": "
|
46
|
-
"@types/
|
47
|
-
"@types/
|
48
|
-
"@vitest/coverage-v8": "
|
44
|
+
"@ctrl/eslint-config": "4.0.12",
|
45
|
+
"@sindresorhus/tsconfig": "5.0.0",
|
46
|
+
"@types/cookie": "0.6.0",
|
47
|
+
"@types/node": "20.10.5",
|
48
|
+
"@vitest/coverage-v8": "1.1.0",
|
49
49
|
"p-wait-for": "5.0.2",
|
50
|
-
"typedoc": "0.25.
|
51
|
-
"typescript": "5.
|
52
|
-
"vitest": "
|
50
|
+
"typedoc": "0.25.4",
|
51
|
+
"typescript": "5.3.3",
|
52
|
+
"vitest": "1.1.0"
|
53
53
|
},
|
54
54
|
"release": {
|
55
55
|
"branches": [
|