diff --git a/src/clients/Deluge.ts b/src/clients/Deluge.ts index fa9835d8f..6e16195cc 100644 --- a/src/clients/Deluge.ts +++ b/src/clients/Deluge.ts @@ -24,7 +24,8 @@ enum DelugeErrorCode { } interface TorrentInfo { complete: boolean; - save_path?: string; + save_path: string; + label?: string; } export default class Deluge implements TorrentClient { @@ -156,6 +157,7 @@ export default class Deluge implements TorrentClient { ): Promise { try { let torrentInfo: TorrentInfo; + const { duplicateCategories } = getRuntimeConfig(); if (searchee.infoHash) { torrentInfo = await this.getTorrentInfo(searchee); if (!torrentInfo.complete) { @@ -182,7 +184,13 @@ export default class Deluge implements TorrentClient { const { dataCategory } = getRuntimeConfig(); await this.setLabel( newTorrent.infoHash, - searchee.path ? dataCategory : this.delugeLabel + searchee.path + ? dataCategory + : torrentInfo.label + ? duplicateCategories + ? `${torrentInfo.label}.cross-seed` + : torrentInfo.label + : this.delugeLabel ); return InjectionResult.SUCCESS; } else if (addResult?.error?.message?.includes("already")) { @@ -229,17 +237,26 @@ export default class Deluge implements TorrentClient { */ private async getTorrentInfo(searchee: Searchee): Promise { try { + let torrentLabel: string = undefined; const params = [ - ["state", "progress", "save_path"], + ["state", "progress", "save_path", "label"], { hash: searchee.infoHash }, ]; - const response = await this.call("web.update_ui", params); if (response?.result?.torrents?.[searchee.infoHash] === undefined) { throw new Error( `Torrent not found in client (${searchee.infoHash})` ); } + if ( + this.isLabelEnabled && + response?.result?.torrents?.[searchee.infoHash]?.label + ?.length != 0 + ) { + torrentLabel = + response?.result?.torrents?.[searchee.infoHash]?.label; + } + const completedTorrent = response?.result?.torrents?.[searchee.infoHash]?.state === "Seeding" || @@ -249,6 +266,7 @@ export default class Deluge implements TorrentClient { complete: completedTorrent, save_path: response?.result?.torrents?.[searchee.infoHash]?.save_path, + label: torrentLabel, }; } catch (e) { logger.error({ diff --git a/src/config.template.cjs b/src/config.template.cjs index 0fdf0699f..1d2d8030c 100644 --- a/src/config.template.cjs +++ b/src/config.template.cjs @@ -172,9 +172,10 @@ module.exports = { delugeRpcUrl: undefined, /** - * qBittorrent-specific - * Whether to inject using categories with the same save paths as your normal categories. - * Example: if you have a category called "Movies", + * qBittorrent and Deluge specific + * Whether to inject using the same labels/categories as the original torrent. + * qBittorrent: This will apply the category's save path + * Example: if you have a label/category called "Movies", * this will automatically inject cross-seeds to "Movies.cross-seed" */ duplicateCategories: false, diff --git a/src/config.template.docker.cjs b/src/config.template.docker.cjs index aedd6b43c..5804b718c 100644 --- a/src/config.template.docker.cjs +++ b/src/config.template.docker.cjs @@ -177,9 +177,10 @@ module.exports = { delugeRpcUrl: undefined, /** - * qBittorrent-specific - * Whether to inject using categories with the same save paths as your normal categories. - * Example: if you have a category called "Movies", + * qBittorrent and Deluge specific + * Whether to inject using the same labels/categories as the original torrent. + * qBittorrent: This will apply the category's save path + * Example: if you have a label/category called "Movies", * this will automatically inject cross-seeds to "Movies.cross-seed" */ duplicateCategories: false,