@ctrl/qbittorrent
Advanced tools
Comparing version 8.2.0 to 8.3.0
@@ -71,3 +71,3 @@ import type { AddTorrentOptions as NormalizedAddTorrentOptions, AllClientData, NormalizedTorrent, TorrentClient, TorrentSettings } from '@ctrl/shared-torrent'; | ||
torrentFiles(hash: string): Promise<TorrentFile[]>; | ||
setFilePriority(hash: string, fileIds: string | string[], priority: TorrentFilePriority): Promise<TorrentFile[]>; | ||
setFilePriority(hash: string, fileIds: string | string[], priority: TorrentFilePriority): Promise<boolean>; | ||
/** | ||
@@ -162,6 +162,6 @@ * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#get-torrent-pieces-states} | ||
* @param hash Hash for desired torrent | ||
* @param id id of the file to be renamed | ||
* @param name new name to be assigned to the file | ||
* @param oldPath id of the file to be renamed | ||
* @param newPath new name to be assigned to the file | ||
*/ | ||
renameFile(hash: string, id: number, name: string): Promise<boolean>; | ||
renameFile(hash: string, oldPath: string, newPath: string): Promise<boolean>; | ||
/** | ||
@@ -215,3 +215,3 @@ * {@link https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#rename-folder} | ||
logout(): boolean; | ||
request<T>(path: string, method: 'GET' | 'POST', params?: Record<string, string | number>, body?: URLSearchParams | FormData, headers?: any, json?: boolean): Promise<T>; | ||
request<T>(path: string, method: 'GET' | 'POST', params?: Record<string, string | number>, body?: URLSearchParams | FormData, headers?: Record<string, string>, isJson?: boolean): Promise<T>; | ||
} |
@@ -171,8 +171,8 @@ import { parse as cookieParse } from 'cookie'; | ||
async setFilePriority(hash, fileIds, priority) { | ||
const res = await this.request('/torrents/filePrio', 'GET', { | ||
await this.request('/torrents/filePrio', 'POST', undefined, objToUrlSearchParams({ | ||
hash, | ||
id: normalizeHashes(fileIds), | ||
priority, | ||
}); | ||
return res; | ||
priority: priority.toString(), | ||
}), undefined, false); | ||
return true; | ||
} | ||
@@ -331,3 +331,3 @@ /** | ||
}; | ||
await this.request('/torrents/delete', 'POST', undefined, objToUrlSearchParams(data)); | ||
await this.request('/torrents/delete', 'POST', undefined, objToUrlSearchParams(data), undefined, false); | ||
return true; | ||
@@ -410,11 +410,11 @@ } | ||
* @param hash Hash for desired torrent | ||
* @param id id of the file to be renamed | ||
* @param name new name to be assigned to the file | ||
* @param oldPath id of the file to be renamed | ||
* @param newPath new name to be assigned to the file | ||
*/ | ||
async renameFile(hash, id, name) { | ||
const form = new FormData(); | ||
form.append('hash', hash); | ||
form.append('id', id.toString()); | ||
form.append('name', name); | ||
await this.request('/torrents/renameFile', 'POST', undefined, undefined, form, false); | ||
async renameFile(hash, oldPath, newPath) { | ||
await this.request('/torrents/renameFile', 'POST', undefined, objToUrlSearchParams({ | ||
hash, | ||
oldPath, | ||
newPath, | ||
}), undefined, false); | ||
return true; | ||
@@ -426,7 +426,7 @@ } | ||
async renameFolder(hash, oldPath, newPath) { | ||
const form = new FormData(); | ||
form.append('hash', hash); | ||
form.append('oldPath', oldPath); | ||
form.append('newPath', newPath); | ||
await this.request('/torrents/renameFolder', 'POST', undefined, undefined, form, false); | ||
await this.request('/torrents/renameFolder', 'POST', undefined, objToUrlSearchParams({ | ||
hash, | ||
oldPath, | ||
newPath, | ||
}), undefined, false); | ||
return true; | ||
@@ -573,3 +573,3 @@ } | ||
// eslint-disable-next-line max-params | ||
async request(path, method, params, body, headers = {}, json = true) { | ||
async request(path, method, params, body, headers = {}, isJson = true) { | ||
if (!this._sid || !this._exp || this._exp.getTime() < new Date().getTime()) { | ||
@@ -590,6 +590,7 @@ const authed = await this.login(); | ||
params, | ||
// allow proxy agent | ||
retry: 0, | ||
timeout: this.config.timeout, | ||
responseType: json ? 'json' : 'text', | ||
// casting to json to avoid type error | ||
responseType: isJson ? 'json' : 'text', | ||
// allow proxy agent | ||
// @ts-expect-error for some reason agent is not in the type | ||
@@ -596,0 +597,0 @@ agent: this.config.agent, |
{ | ||
"name": "@ctrl/qbittorrent", | ||
"version": "8.2.0", | ||
"version": "8.3.0", | ||
"description": "TypeScript api wrapper for qbittorrent using got", | ||
@@ -50,12 +50,12 @@ "author": "Scott Cooper <scttcper@gmail.com>", | ||
"@biomejs/biome": "1.8.3", | ||
"@ctrl/eslint-config-biome": "3.1.3", | ||
"@ctrl/eslint-config-biome": "4.1.4", | ||
"@eslint/compat": "^1.1.1", | ||
"@sindresorhus/tsconfig": "6.0.0", | ||
"@types/cookie": "0.6.0", | ||
"@types/node": "20.14.11", | ||
"@vitest/coverage-v8": "2.0.3", | ||
"@types/node": "22.5.0", | ||
"@vitest/coverage-v8": "2.0.5", | ||
"p-wait-for": "5.0.2", | ||
"typedoc": "0.26.4", | ||
"typescript": "5.5.3", | ||
"vitest": "2.0.3" | ||
"typedoc": "0.26.6", | ||
"typescript": "5.5.4", | ||
"vitest": "2.0.5" | ||
}, | ||
@@ -62,0 +62,0 @@ "release": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79078
2327