server: qBittorrent: allow to attach tags while adding torrents

Needs: qbittorrent/qBittorrent#13882
This commit is contained in:
Jesse Chan
2020-11-30 20:34:00 +08:00
parent 3d2284b768
commit 9051a00fba
2 changed files with 18 additions and 6 deletions
@@ -36,28 +36,38 @@ class QBittorrentClientGatewayService extends ClientGatewayService {
clientRequestManager = new ClientRequestManager(this.user.client as QBittorrentConnectionSettings);
cachedProperties: Record<string, Pick<TorrentProperties, 'dateCreated' | 'isPrivate' | 'trackerURIs'>> = {};
async addTorrentsByFile({files, destination, isBasePath, start}: Required<AddTorrentByFileOptions>): Promise<void> {
async addTorrentsByFile({
files,
destination,
tags,
isBasePath,
start,
}: Required<AddTorrentByFileOptions>): Promise<void> {
const fileBuffers = files.map((file) => {
return Buffer.from(file, 'base64');
});
// TODO: qBittorrent does not have capability to add tags during add torrents.
return this.clientRequestManager
.torrentsAddFiles(fileBuffers, {
savepath: destination,
tags: tags.join(','),
paused: !start,
root_folder: !isBasePath,
})
.then(this.processClientRequestSuccess, this.processClientRequestError);
}
async addTorrentsByURL({urls, destination, isBasePath, start}: Required<AddTorrentByURLOptions>): Promise<void> {
// TODO: qBittorrent does not have capability to add tags during add torrents.
async addTorrentsByURL({
urls,
destination,
tags,
isBasePath,
start,
}: Required<AddTorrentByURLOptions>): Promise<void> {
return this.clientRequestManager
.torrentsAddURLs(urls, {
savepath: destination,
tags: tags.join(','),
paused: !start,
root_folder: !isBasePath,
})
@@ -117,6 +117,8 @@ export interface QBittorrentTorrentsAddOptions {
cookie?: string;
// Category for the torrent
category?: string;
// Tags for the torrent, split by ','
tags?: string;
// Skip hash checking. Possible values are true, false (default)
skip_checking?: boolean;
// Add torrents in the paused state. Possible values are true, false (default)