@ctrl/qbittorrent 4.1.0 → 5.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/dist/src/qbittorrent.d.ts +3 -3
- package/dist/src/qbittorrent.js +40 -20
- package/dist/src/types.d.ts +4 -0
- package/dist/src/types.js +4 -0
- package/package.json +13 -12
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
2
|
-
import { Options as GotOptions, Response } from 'got';
|
3
|
-
import { AddTorrentOptions as NormalizedAddTorrentOptions, AllClientData, NormalizedTorrent, TorrentClient, TorrentSettings } from '@ctrl/shared-torrent';
|
4
|
-
import { AddMagnetOptions, AddTorrentOptions, BuildInfo, Preferences, Torrent, TorrentCategories, TorrentFile, TorrentFilePriority, TorrentFilters, TorrentPieceState, TorrentProperties, TorrentTrackers, WebSeed } from './types.js';
|
2
|
+
import type { Options as GotOptions, Response } from 'got';
|
3
|
+
import type { AddTorrentOptions as NormalizedAddTorrentOptions, AllClientData, NormalizedTorrent, TorrentClient, TorrentSettings } from '@ctrl/shared-torrent';
|
4
|
+
import type { AddMagnetOptions, AddTorrentOptions, BuildInfo, Preferences, Torrent, TorrentCategories, TorrentFile, TorrentFilePriority, TorrentFilters, TorrentPieceState, TorrentProperties, TorrentTrackers, WebSeed } from './types.js';
|
5
5
|
export declare class QBittorrent implements TorrentClient {
|
6
6
|
config: TorrentSettings;
|
7
7
|
/**
|
package/dist/src/qbittorrent.js
CHANGED
@@ -7,10 +7,10 @@ import { fileFromPath } from 'formdata-node/file-from-path';
|
|
7
7
|
import got from 'got';
|
8
8
|
import { Cookie } from 'tough-cookie';
|
9
9
|
import { magnetDecode } from '@ctrl/magnet-link';
|
10
|
-
import { TorrentState as NormalizedTorrentState
|
10
|
+
import { TorrentState as NormalizedTorrentState } from '@ctrl/shared-torrent';
|
11
11
|
import { hash } from '@ctrl/torrent-file';
|
12
12
|
import { urlJoin } from '@ctrl/url-join';
|
13
|
-
import { TorrentState
|
13
|
+
import { TorrentState } from './types.js';
|
14
14
|
const defaults = {
|
15
15
|
baseUrl: 'http://localhost:9091/',
|
16
16
|
path: '/api/v2',
|
@@ -623,39 +623,59 @@ export class QBittorrent {
|
|
623
623
|
}
|
624
624
|
_normalizeTorrentData(torrent) {
|
625
625
|
let state = NormalizedTorrentState.unknown;
|
626
|
+
let stateMessage = '';
|
627
|
+
let { eta } = torrent;
|
628
|
+
/**
|
629
|
+
* Good references https://github.com/qbittorrent/qBittorrent/blob/master/src/webui/www/private/scripts/dynamicTable.js#L933
|
630
|
+
* https://github.com/Radarr/Radarr/blob/develop/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs#L242
|
631
|
+
*/
|
626
632
|
switch (torrent.state) {
|
627
|
-
case TorrentState.
|
628
|
-
|
633
|
+
case TorrentState.Error:
|
634
|
+
state = NormalizedTorrentState.warning;
|
635
|
+
stateMessage = 'qBittorrent is reporting an error';
|
636
|
+
break;
|
637
|
+
case TorrentState.PausedDL:
|
638
|
+
state = NormalizedTorrentState.paused;
|
639
|
+
break;
|
640
|
+
case TorrentState.QueuedDL: // queuing is enabled and torrent is queued for download
|
641
|
+
case TorrentState.CheckingDL: // same as checkingUP, but torrent has NOT finished downloading
|
642
|
+
case TorrentState.CheckingUP: // torrent has finished downloading and is being checked. Set when `recheck torrent on completion` is enabled. In the event the check fails we shouldn't treat it as completed.
|
643
|
+
state = NormalizedTorrentState.queued;
|
644
|
+
break;
|
645
|
+
case TorrentState.MetaDL: // Metadl could be an error if DHT is not enabled
|
646
|
+
case TorrentState.ForcedDL: // torrent is being downloaded, and was forced started
|
647
|
+
case TorrentState.ForcedMetaDL: // torrent metadata is being forcibly downloaded
|
648
|
+
case TorrentState.Downloading: // torrent is being downloaded and data is being transferred
|
629
649
|
state = NormalizedTorrentState.downloading;
|
630
650
|
break;
|
631
651
|
case TorrentState.Allocating:
|
632
652
|
// state = 'stalledDL';
|
633
653
|
state = NormalizedTorrentState.queued;
|
634
654
|
break;
|
635
|
-
case TorrentState.
|
636
|
-
state = NormalizedTorrentState.
|
637
|
-
|
638
|
-
case TorrentState.PausedDL:
|
639
|
-
state = NormalizedTorrentState.paused;
|
655
|
+
case TorrentState.StalledDL:
|
656
|
+
state = NormalizedTorrentState.warning;
|
657
|
+
stateMessage = 'The download is stalled with no connection';
|
640
658
|
break;
|
641
|
-
case TorrentState.PausedUP:
|
659
|
+
case TorrentState.PausedUP: // torrent is paused and has finished downloading:
|
660
|
+
case TorrentState.Uploading: // torrent is being seeded and data is being transferred
|
661
|
+
case TorrentState.StalledUP: // torrent is being seeded, but no connection were made
|
662
|
+
case TorrentState.QueuedUP: // queuing is enabled and torrent is queued for upload
|
663
|
+
case TorrentState.ForcedUP: // torrent has finished downloading and is being forcibly seeded
|
642
664
|
// state = 'completed';
|
643
|
-
state = NormalizedTorrentState.
|
644
|
-
|
645
|
-
case TorrentState.QueuedDL:
|
646
|
-
case TorrentState.QueuedUP:
|
647
|
-
state = NormalizedTorrentState.queued;
|
665
|
+
state = NormalizedTorrentState.seeding;
|
666
|
+
eta = 0; // qBittorrent sends eta=8640000 for completed torrents
|
648
667
|
break;
|
649
|
-
case TorrentState.
|
650
|
-
case TorrentState.CheckingUP:
|
668
|
+
case TorrentState.Moving: // torrent is being moved from a folder
|
651
669
|
case TorrentState.QueuedForChecking:
|
652
670
|
case TorrentState.CheckingResumeData:
|
653
|
-
case TorrentState.Moving:
|
654
671
|
state = NormalizedTorrentState.checking;
|
655
672
|
break;
|
656
673
|
case TorrentState.Unknown:
|
674
|
+
state = NormalizedTorrentState.error;
|
675
|
+
break;
|
657
676
|
case TorrentState.MissingFiles:
|
658
677
|
state = NormalizedTorrentState.error;
|
678
|
+
stateMessage = 'The download is missing files';
|
659
679
|
break;
|
660
680
|
default:
|
661
681
|
break;
|
@@ -664,8 +684,9 @@ export class QBittorrent {
|
|
664
684
|
const result = {
|
665
685
|
id: torrent.hash,
|
666
686
|
name: torrent.name,
|
667
|
-
stateMessage
|
687
|
+
stateMessage,
|
668
688
|
state,
|
689
|
+
eta,
|
669
690
|
dateAdded: new Date(torrent.added_on * 1000).toISOString(),
|
670
691
|
isCompleted,
|
671
692
|
progress: torrent.progress,
|
@@ -674,7 +695,6 @@ export class QBittorrent {
|
|
674
695
|
savePath: torrent.save_path,
|
675
696
|
uploadSpeed: torrent.upspeed,
|
676
697
|
downloadSpeed: torrent.dlspeed,
|
677
|
-
eta: torrent.eta,
|
678
698
|
queuePosition: torrent.priority,
|
679
699
|
connectedPeers: torrent.num_leechs,
|
680
700
|
connectedSeeds: torrent.num_seeds,
|
package/dist/src/types.d.ts
CHANGED
@@ -220,6 +220,10 @@ export declare enum TorrentState {
|
|
220
220
|
* Torrent is forced to downloading to ignore queue limit
|
221
221
|
*/
|
222
222
|
ForcedDL = "forcedDL",
|
223
|
+
/**
|
224
|
+
* Forced Downloading Metadata
|
225
|
+
*/
|
226
|
+
ForcedMetaDL = "ForcedMetaDL",
|
223
227
|
/**
|
224
228
|
* Torrent is forced to uploading and ignore queue limit
|
225
229
|
*/
|
package/dist/src/types.js
CHANGED
@@ -48,6 +48,10 @@ export var TorrentState;
|
|
48
48
|
* Torrent is forced to downloading to ignore queue limit
|
49
49
|
*/
|
50
50
|
TorrentState["ForcedDL"] = "forcedDL";
|
51
|
+
/**
|
52
|
+
* Forced Downloading Metadata
|
53
|
+
*/
|
54
|
+
TorrentState["ForcedMetaDL"] = "ForcedMetaDL";
|
51
55
|
/**
|
52
56
|
* Torrent is forced to uploading and ignore queue limit
|
53
57
|
*/
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ctrl/qbittorrent",
|
3
|
-
"version": "
|
3
|
+
"version": "5.0.0",
|
4
4
|
"description": "TypeScript api wrapper for qbittorrent using got",
|
5
5
|
"author": "Scott Cooper <scttcper@gmail.com>",
|
6
6
|
"license": "MIT",
|
@@ -32,23 +32,24 @@
|
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
34
|
"@ctrl/magnet-link": "^3.1.1",
|
35
|
-
"@ctrl/shared-torrent": "^4.
|
35
|
+
"@ctrl/shared-torrent": "^4.2.0",
|
36
36
|
"@ctrl/torrent-file": "^2.0.2",
|
37
37
|
"@ctrl/url-join": "^2.0.2",
|
38
|
-
"formdata-node": "^
|
39
|
-
"got": "^12.1
|
40
|
-
"tough-cookie": "^4.
|
38
|
+
"formdata-node": "^5.0.0",
|
39
|
+
"got": "^12.3.1",
|
40
|
+
"tough-cookie": "^4.1.2"
|
41
41
|
},
|
42
42
|
"devDependencies": {
|
43
|
-
"@ctrl/eslint-config": "3.4.
|
43
|
+
"@ctrl/eslint-config": "3.4.10",
|
44
44
|
"@sindresorhus/tsconfig": "3.0.1",
|
45
|
-
"@types/node": "18.
|
45
|
+
"@types/node": "18.7.14",
|
46
46
|
"@types/tough-cookie": "4.0.2",
|
47
|
-
"c8": "
|
48
|
-
"
|
49
|
-
"
|
50
|
-
"
|
51
|
-
"
|
47
|
+
"@vitest/coverage-c8": "0.22.1",
|
48
|
+
"c8": "7.12.0",
|
49
|
+
"p-wait-for": "5.0.0",
|
50
|
+
"typedoc": "0.23.11",
|
51
|
+
"typescript": "4.8.2",
|
52
|
+
"vitest": "0.22.1"
|
52
53
|
},
|
53
54
|
"release": {
|
54
55
|
"branches": [
|