@ctrl/qbittorrent 3.0.0 → 4.0.1

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.
@@ -1,4 +1,4 @@
1
- /// <reference types="node" />
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  import { Options as GotOptions, Response } from 'got';
3
3
  import { AddTorrentOptions as NormalizedAddTorrentOptions, AllClientData, NormalizedTorrent, TorrentClient, TorrentSettings } from '@ctrl/shared-torrent';
4
4
  import { AddMagnetOptions, AddTorrentOptions, BuildInfo, Preferences, Torrent, TorrentCategories, TorrentFile, TorrentFilePriority, TorrentFilters, TorrentPieceState, TorrentProperties, TorrentTrackers, WebSeed } from './types.js';
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-redundant-type-constituents */
1
2
  /* eslint-disable @typescript-eslint/ban-types */
2
3
  import { existsSync } from 'fs';
3
4
  import { URLSearchParams } from 'url';
@@ -373,7 +374,6 @@ export class QBittorrent {
373
374
  return true;
374
375
  }
375
376
  async addTorrent(torrent, options = {}) {
376
- var _a, _b;
377
377
  const form = new FormData();
378
378
  // remove options.filename, not used in form
379
379
  if (options.filename) {
@@ -382,7 +382,7 @@ export class QBittorrent {
382
382
  const type = { type: 'application/x-bittorrent' };
383
383
  if (typeof torrent === 'string') {
384
384
  if (existsSync(torrent)) {
385
- const file = await fileFromPath(torrent, (_a = options.filename) !== null && _a !== void 0 ? _a : 'torrent', type);
385
+ const file = await fileFromPath(torrent, options.filename ?? 'torrent', type);
386
386
  form.set('file', file);
387
387
  }
388
388
  else {
@@ -390,7 +390,7 @@ export class QBittorrent {
390
390
  }
391
391
  }
392
392
  else {
393
- const file = new File([torrent], (_b = options.filename) !== null && _b !== void 0 ? _b : 'torrent', type);
393
+ const file = new File([torrent], options.filename ?? 'torrent', type);
394
394
  form.set('file', file);
395
395
  }
396
396
  if (options) {
@@ -542,14 +542,13 @@ export class QBittorrent {
542
542
  * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#login}
543
543
  */
544
544
  async login() {
545
- var _a, _b;
546
545
  const url = urlJoin(this.config.baseUrl, this.config.path, '/auth/login');
547
546
  const res = await got({
548
547
  url,
549
548
  method: 'POST',
550
549
  form: {
551
- username: (_a = this.config.username) !== null && _a !== void 0 ? _a : '',
552
- password: (_b = this.config.password) !== null && _b !== void 0 ? _b : '',
550
+ username: this.config.username ?? '',
551
+ password: this.config.password ?? '',
553
552
  },
554
553
  followRedirect: false,
555
554
  retry: { limit: 0 },
@@ -575,7 +574,6 @@ export class QBittorrent {
575
574
  }
576
575
  // eslint-disable-next-line max-params
577
576
  async request(path, method, params = {}, body, form, headers = {}, json = true) {
578
- var _a;
579
577
  if (!this._sid || !this._exp || this._exp.getTime() < new Date().getTime()) {
580
578
  const authed = await this.login();
581
579
  if (!authed) {
@@ -588,7 +586,7 @@ export class QBittorrent {
588
586
  resolveBodyOnly: false,
589
587
  method,
590
588
  headers: {
591
- Cookie: `SID=${(_a = this._sid) !== null && _a !== void 0 ? _a : ''}`,
589
+ Cookie: `SID=${this._sid ?? ''}`,
592
590
  ...headers,
593
591
  },
594
592
  retry: { limit: 0 },
@@ -1,22 +1,22 @@
1
1
  export interface BuildInfo {
2
2
  /**
3
- * QT version
3
+ * QT version
4
4
  */
5
5
  qt: string;
6
6
  /**
7
- * libtorrent version
7
+ * libtorrent version
8
8
  */
9
9
  libtorrent: string;
10
10
  /**
11
- * Boost version
11
+ * Boost version
12
12
  */
13
13
  boost: string;
14
14
  /**
15
- * OpenSSL version
15
+ * OpenSSL version
16
16
  */
17
17
  openssl: string;
18
18
  /**
19
- * Application bitness (e.g. 64-bit)
19
+ * Application bitness (e.g. 64-bit)
20
20
  */
21
21
  bitness: string;
22
22
  }
@@ -534,9 +534,10 @@ export interface AddTorrentOptions {
534
534
  */
535
535
  paused: TrueFalseStr;
536
536
  /**
537
- * Create the root folder. Possible values are true, false, unset (default)
537
+ * Control filesystem structure for content (added in Web API v2.7)
538
+ * Migrating from rootFolder example rootFolder ? 'Original' : 'NoSubfolder'
538
539
  */
539
- root_folder: TrueFalseStr;
540
+ contentLayout: 'Original' | 'Subfolder' | 'NoSubfolder';
540
541
  /**
541
542
  * Rename torrent
542
543
  */
@@ -549,6 +550,14 @@ export interface AddTorrentOptions {
549
550
  * Set torrent download speed limit. Unit in bytes/second
550
551
  */
551
552
  dlLimit: number;
553
+ /**
554
+ * Set torrent share ratio limit
555
+ */
556
+ ratioLimit: number;
557
+ /**
558
+ * Set torrent seeding time limit. Unit in seconds
559
+ */
560
+ seedingTimeLimit: number;
552
561
  /**
553
562
  * Whether Automatic Torrent Management should be used, disables use of savepath
554
563
  */
@@ -660,9 +669,13 @@ export interface Preferences {
660
669
  */
661
670
  temp_path: string;
662
671
  /**
663
- * Property: directory to watch for torrent files, value: where torrents loaded from this directory should be downloaded to (see list of possible values below). Slashes are used as path separators; multiple key/value pairs can be specified
672
+ * Directory to watch for torrent files, value: where torrents loaded from this directory should be downloaded to (see list of possible values below). Slashes are used as path separators; multiple key/value pairs can be specified
673
+ * Possible values of scan_dirs:
674
+ * 0 Download to the monitored folder
675
+ * 1 Download to the default save path
676
+ * "/path/to/download/to" Download to this path
664
677
  */
665
- scan_dirs: Record<string, unknown>;
678
+ scan_dirs: Record<string, 0 | 1 | string>;
666
679
  /**
667
680
  * Path to directory to copy .torrent files to. Slashes are used as path separators
668
681
  */
@@ -798,11 +811,14 @@ export interface Preferences {
798
811
  /**
799
812
  * True if the advanced libtorrent option piece_extent_affinity is enabled
800
813
  */
801
- piece_extent_affinity: boolean;
814
+ enable_piece_extent_affinity: boolean;
802
815
  /**
803
- * True if uTP protocol should be enabled; this option is only available in qBittorent built against libtorrent version 0.16.X and higher
816
+ * Bittorrent Protocol to use
817
+ * 0 TCP and μTP
818
+ * 1 TCP
819
+ * 2 μTP
804
820
  */
805
- enable_utp: boolean;
821
+ bittorrent_protocol: 0 | 1 | 2;
806
822
  /**
807
823
  * True if [du]l_limit should be applied to uTP connections; this option is only available in qBittorent built against libtorrent version 0.16.X and higher
808
824
  */
@@ -845,20 +861,22 @@ export interface Preferences {
845
861
  schedule_to_min: number;
846
862
  /**
847
863
  * Scheduler days. See possible values here below
848
- */
849
- scheduler_days: number;
864
+ * 0 Every day
865
+ * 1 Every weekday
866
+ * 2 Every weekend
867
+ * 3 Every Monday
868
+ * 4 Every Tuesday
869
+ * 5 Every Wednesday
870
+ * 6 Every Thursday
871
+ * 7 Every Friday
872
+ * 8 Every Saturday
873
+ * 9 Every Sunday
874
+ */
875
+ scheduler_days: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
850
876
  /**
851
877
  * True if DHT is enabled
852
878
  */
853
879
  dht: boolean;
854
- /**
855
- * True if DHT port should match TCP port
856
- */
857
- dhtSameAsBT: boolean;
858
- /**
859
- * DHT port if dhtSameAsBT is false
860
- */
861
- dht_port: number;
862
880
  /**
863
881
  * True if PeX is enabled
864
882
  */
@@ -869,10 +887,13 @@ export interface Preferences {
869
887
  lsd: boolean;
870
888
  /**
871
889
  * See list of possible values here below
890
+ * 0 Prefer encryption
891
+ * 1 Force encryption on
892
+ * 2 Force encryption off
872
893
  */
873
- encryption: number;
894
+ encryption: 0 | 1 | 2;
874
895
  /**
875
- * If true anonymous mode will be enabled; read more [here](Anonymous-Mode); this option is only available in qBittorent built against libtorrent version 0.16.X and higher
896
+ * If true anonymous mode will be enabled; read more [here](https://github.com/qbittorrent/qBittorrent/wiki/Anonymous-Mode); this option is only available in qBittorent built against libtorrent version 0.16.X and higher
876
897
  */
877
898
  anonymous_mode: boolean;
878
899
  /**
@@ -891,10 +912,6 @@ export interface Preferences {
891
912
  * True if peer and web seed connections should be proxified; this option will have any effect only in qBittorent built against libtorrent version 0.16.X and higher
892
913
  */
893
914
  proxy_peer_connections: boolean;
894
- /**
895
- * True if the connections not supported by the proxy are disabled
896
- */
897
- force_proxy: boolean;
898
915
  /**
899
916
  * True proxy requires authentication; doesn't apply to SOCKS4 proxies
900
917
  */
@@ -907,6 +924,10 @@ export interface Preferences {
907
924
  * Password for proxy authentication
908
925
  */
909
926
  proxy_password: string;
927
+ /**
928
+ * True if proxy is only used for torrents
929
+ */
930
+ proxy_torrents_only: boolean;
910
931
  /**
911
932
  * True if external IP filter should be enabled
912
933
  */
@@ -963,6 +984,14 @@ export interface Preferences {
963
984
  * WebUI access ban duration in seconds
964
985
  */
965
986
  web_ui_ban_duration: number;
987
+ /**
988
+ * Seconds until WebUI is automatically signed off
989
+ */
990
+ web_ui_session_timeout: number;
991
+ /**
992
+ * True if WebUI host header validation is enabled
993
+ */
994
+ web_ui_host_header_validation_enabled: boolean;
966
995
  /**
967
996
  * True if authentication challenge for loopback address (127.0.0.1) should be disabled
968
997
  */
@@ -995,6 +1024,14 @@ export interface Preferences {
995
1024
  * SSL certificate contents (this is a not a path)
996
1025
  */
997
1026
  ssl_cert: string;
1027
+ /**
1028
+ * For API ≥ v2.0.1: Path to SSL keyfile
1029
+ */
1030
+ web_ui_https_key_path: string;
1031
+ /**
1032
+ * For API ≥ v2.0.1: Path to SSL certificate
1033
+ */
1034
+ web_ui_https_cert_path: string;
998
1035
  /**
999
1036
  * True if server DNS should be updated dynamically
1000
1037
  */
@@ -1031,5 +1068,157 @@ export interface Preferences {
1031
1068
  * Enable auto-downloading of torrents from the RSS feeds
1032
1069
  */
1033
1070
  rss_auto_downloading_enabled: boolean;
1071
+ /**
1072
+ * For API ≥ v2.5.1: Enable downloading of repack/proper Episodes
1073
+ */
1074
+ rss_download_repack_proper_episodes: boolean;
1075
+ /**
1076
+ * For API ≥ v2.5.1: List of RSS Smart Episode Filters
1077
+ */
1078
+ rss_smart_episode_filters: string;
1079
+ /**
1080
+ * Enable automatic adding of trackers to new torrents
1081
+ */
1082
+ add_trackers_enabled: boolean;
1083
+ /**
1084
+ * List of trackers to add to new torrent
1085
+ */
1086
+ add_trackers: string;
1087
+ /**
1088
+ * For API ≥ v2.5.1: Enable custom http headers
1089
+ */
1090
+ web_ui_use_custom_http_headers_enabled: boolean;
1091
+ /**
1092
+ * For API ≥ v2.5.1: List of custom http headers
1093
+ */
1094
+ web_ui_custom_http_headers: string;
1095
+ /**
1096
+ * True enables max seeding time
1097
+ */
1098
+ max_seeding_time_enabled: boolean;
1099
+ /**
1100
+ * Number of minutes to seed a torrent
1101
+ */
1102
+ max_seeding_time: number;
1103
+ /**
1104
+ * TODO
1105
+ */
1106
+ announce_ip: string;
1107
+ /**
1108
+ * True always announce to all tiers
1109
+ */
1110
+ announce_to_all_tiers: boolean;
1111
+ /**
1112
+ * True always announce to all trackers in a tier
1113
+ */
1114
+ announce_to_all_trackers: boolean;
1115
+ /**
1116
+ * Number of asynchronous I/O threads
1117
+ */
1118
+ async_io_threads: number;
1119
+ /**
1120
+ * List of banned IPs
1121
+ */
1122
+ banned_IPs: string;
1123
+ /**
1124
+ * Outstanding memory when checking torrents in MiB
1125
+ */
1126
+ checking_memory_use: number;
1127
+ /**
1128
+ * IP Address to bind to. Empty String means All addresses
1129
+ */
1130
+ current_interface_address: string;
1131
+ /**
1132
+ * Network Interface used
1133
+ */
1134
+ current_network_interface: string;
1135
+ /**
1136
+ * Disk cache used in MiB
1137
+ */
1138
+ disk_cache: number;
1139
+ /**
1140
+ * Disk cache expiry interval in seconds
1141
+ */
1142
+ disk_cache_ttl: number;
1143
+ /**
1144
+ * Port used for embedded tracker
1145
+ */
1146
+ embedded_tracker_port: number;
1147
+ /**
1148
+ * True enables coalesce reads & writes
1149
+ */
1150
+ enable_coalesce_read_write: boolean;
1151
+ /**
1152
+ * True enables embedded tracker
1153
+ */
1154
+ enable_embedded_tracker: boolean;
1155
+ /**
1156
+ * True allows multiple connections from the same IP address
1157
+ */
1158
+ enable_multi_connections_from_same_ip: boolean;
1159
+ /**
1160
+ * True enables os cache
1161
+ */
1162
+ enable_os_cache: boolean;
1163
+ /**
1164
+ * True enables sending of upload piece suggestions
1165
+ */
1166
+ enable_upload_suggestions: boolean;
1167
+ /**
1168
+ * File pool size
1169
+ */
1170
+ file_pool_size: number;
1171
+ /**
1172
+ * Maximal outgoing port (0: Disabled)
1173
+ */
1174
+ outgoing_ports_max: number;
1175
+ /**
1176
+ * Minimal outgoing port (0: Disabled)
1177
+ */
1178
+ outgoing_ports_min: number;
1179
+ /**
1180
+ * True rechecks torrents on completion
1181
+ */
1182
+ recheck_completed_torrents: boolean;
1183
+ /**
1184
+ * True resolves peer countries
1185
+ */
1186
+ resolve_peer_countries: boolean;
1187
+ /**
1188
+ * Save resume data interval in min
1189
+ */
1190
+ save_resume_data_interval: number;
1191
+ /**
1192
+ * Send buffer low watermark in KiB
1193
+ */
1194
+ send_buffer_low_watermark: number;
1195
+ /**
1196
+ * Send buffer watermark in KiB
1197
+ */
1198
+ send_buffer_watermark: number;
1199
+ /**
1200
+ * Send buffer watermark factor in percent
1201
+ */
1202
+ send_buffer_watermark_factor: number;
1203
+ /**
1204
+ * Socket backlog size
1205
+ */
1206
+ socket_backlog_size: number;
1207
+ /**
1208
+ * Upload choking algorithm used (see list of possible values below)
1209
+ */
1210
+ upload_choking_algorithm: number;
1211
+ /**
1212
+ * Upload slots behavior used (see list of possible values below)
1213
+ */
1214
+ upload_slots_behavior: number;
1215
+ /**
1216
+ * UPnP lease duration (0: Permanent lease)
1217
+ */
1218
+ upnp_lease_duration: number;
1219
+ /**
1220
+ * μTP-TCP mixed mode algorithm (see list of possible values below)
1221
+ */
1222
+ utp_tcp_mixed_mode: number;
1034
1223
  }
1035
1224
  export {};
package/dist/src/types.js CHANGED
@@ -77,7 +77,7 @@ export var TorrentState;
77
77
  * Torrent data files is missing
78
78
  */
79
79
  TorrentState["MissingFiles"] = "missingFiles";
80
- })(TorrentState || (TorrentState = {}));
80
+ })(TorrentState = TorrentState || (TorrentState = {}));
81
81
  export var TorrentTrackerStatus;
82
82
  (function (TorrentTrackerStatus) {
83
83
  /**
@@ -100,7 +100,7 @@ export var TorrentTrackerStatus;
100
100
  * Tracker has not been contacted yet
101
101
  */
102
102
  TorrentTrackerStatus[TorrentTrackerStatus["Waiting"] = 4] = "Waiting";
103
- })(TorrentTrackerStatus || (TorrentTrackerStatus = {}));
103
+ })(TorrentTrackerStatus = TorrentTrackerStatus || (TorrentTrackerStatus = {}));
104
104
  export var TorrentFilePriority;
105
105
  (function (TorrentFilePriority) {
106
106
  /**
@@ -119,7 +119,7 @@ export var TorrentFilePriority;
119
119
  * Maximal priority
120
120
  */
121
121
  TorrentFilePriority[TorrentFilePriority["MaxPriority"] = 7] = "MaxPriority";
122
- })(TorrentFilePriority || (TorrentFilePriority = {}));
122
+ })(TorrentFilePriority = TorrentFilePriority || (TorrentFilePriority = {}));
123
123
  export var TorrentPieceState;
124
124
  (function (TorrentPieceState) {
125
125
  /**
@@ -134,4 +134,4 @@ export var TorrentPieceState;
134
134
  * Already downloaded
135
135
  */
136
136
  TorrentPieceState[TorrentPieceState["Downloaded"] = 2] = "Downloaded";
137
- })(TorrentPieceState || (TorrentPieceState = {}));
137
+ })(TorrentPieceState = TorrentPieceState || (TorrentPieceState = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/qbittorrent",
3
- "version": "3.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "TypeScript api wrapper for qbittorrent using got",
5
5
  "author": "Scott Cooper <scttcper@gmail.com>",
6
6
  "license": "MIT",
@@ -8,7 +8,7 @@
8
8
  "homepage": "https://qbittorrent.vercel.app",
9
9
  "type": "module",
10
10
  "main": "./dist/src/index.js",
11
- "typings": "./dist/src/index.d.ts",
11
+ "types": "./dist/src/index.d.ts",
12
12
  "files": [
13
13
  "dist/src"
14
14
  ],
@@ -26,44 +26,34 @@
26
26
  "prepare": "npm run build",
27
27
  "build": "tsc",
28
28
  "build:docs": "typedoc",
29
- "test": "ava",
30
- "test:watch": "ava --watch",
31
- "test:ci": "c8 --reporter=text --reporter=lcov ava"
29
+ "test": "vitest run",
30
+ "test:watch": "vitest",
31
+ "test:ci": "vitest run --coverage --reporter=junit --outputFile=./junit.xml"
32
32
  },
33
33
  "dependencies": {
34
- "@ctrl/magnet-link": "^3.1.0",
35
- "@ctrl/shared-torrent": "^4.1.0",
34
+ "@ctrl/magnet-link": "^3.1.1",
35
+ "@ctrl/shared-torrent": "^4.1.1",
36
36
  "@ctrl/torrent-file": "^2.0.1",
37
37
  "@ctrl/url-join": "^2.0.0",
38
38
  "formdata-node": "^4.3.2",
39
- "got": "^12.0.1",
39
+ "got": "^12.1.0",
40
40
  "tough-cookie": "^4.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@ctrl/eslint-config": "3.3.1",
44
- "@sindresorhus/tsconfig": "2.0.0",
45
- "@types/node": "17.0.21",
46
- "@types/tough-cookie": "4.0.1",
47
- "ava": "4.0.1",
48
- "c8": "7.11.0",
43
+ "@ctrl/eslint-config": "3.4.4",
44
+ "@sindresorhus/tsconfig": "3.0.1",
45
+ "@types/node": "17.0.40",
46
+ "@types/tough-cookie": "4.0.2",
47
+ "c8": "7.11.3",
49
48
  "p-wait-for": "4.1.0",
50
- "ts-node": "10.5.0",
51
- "typedoc": "0.22.12",
52
- "typescript": "4.5.5"
53
- },
54
- "ava": {
55
- "files": [
56
- "test/**/*.spec.ts"
57
- ],
58
- "extensions": {
59
- "ts": "module"
60
- },
61
- "nodeArguments": [
62
- "--loader=ts-node/esm"
63
- ]
49
+ "typedoc": "0.22.17",
50
+ "typescript": "4.7.3",
51
+ "vitest": "0.14.0"
64
52
  },
65
53
  "release": {
66
- "branch": "master"
54
+ "branches": [
55
+ "master"
56
+ ]
67
57
  },
68
58
  "engines": {
69
59
  "node": ">=14.16"