From ed27df82cf1e9448faee1aa5c6fcc86659029d88 Mon Sep 17 00:00:00 2001 From: IITII Date: Mon, 18 Dec 2023 16:23:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=AF=E5=B0=86=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E4=BD=9C=E4=B8=BA=20tag=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=B0=20qb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #1621 --- resource/clients/qbittorrent/init.js | 22 ++++++++++++++++--- resource/i18n/en.json | 2 ++ resource/i18n/zh-CN.json | 2 ++ src/background/controller.ts | 1 + src/interface/common.ts | 2 ++ .../views/settings/DownloadClients/Editor.vue | 10 +++++++++ 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/resource/clients/qbittorrent/init.js b/resource/clients/qbittorrent/init.js index 46764143e..07d10f073 100644 --- a/resource/clients/qbittorrent/init.js +++ b/resource/clients/qbittorrent/init.js @@ -169,7 +169,8 @@ */ addTorrentFromUrl(data, callback) { let formData = new FormData(); - let {savePath, category, clientOptions} = data, autoTMM = undefined, qbCategories + let {savePath, category, clientOptions, siteConfig} = data, autoTMM = undefined, qbCategories + let tags = [data.imdbId] if (savePath) { formData.append("savepath", data.savePath) @@ -197,6 +198,21 @@ } } + if (clientOptions && siteConfig) { + // 以 frds 为例, 这里是 keepfrds + if (clientOptions.hostnameAsTag) { + let url = new URL(siteConfig.activeURL).hostname + let arr = url.split('.') + arr.pop() + tags.push(arr.pop()) + } + // 以 frds 为例, 这里是 pt@keepfrds + if (clientOptions.siteNameAsTag) { + tags.push(siteConfig.name) + } + } + tags = tags.filter(_ => !!_).map(_ => _.toLowerCase()).join(',') + if (autoTMM !== undefined) { formData.append("autoTMM", autoTMM); } @@ -209,8 +225,8 @@ formData.append("paused", !data.autoStart); } - if (data.imdbId != undefined) { - formData.append("tags", data.imdbId); + if (tags) { + formData.append("tags", tags); } if (data.upLoadLimit && data.upLoadLimit > 0) { diff --git a/resource/i18n/en.json b/resource/i18n/en.json index e3c94b46d..9b8a76e30 100644 --- a/resource/i18n/en.json +++ b/resource/i18n/en.json @@ -587,6 +587,8 @@ "loginPwd": "login password", "id": "ID", "autoStart": "Automatically start downloading when sending a torrent", + "hostnameAsTag": "Add lowercase host name to tags when sending torrents (Beta)", + "siteNameAsTag": "Add lowercase site name to tags when sending torrents (Beta)", "tagIMDb": "Add IMDb tag when sending a torrent(Beta)", "enableCategory": "Automatically add QB categories when sending torrents (Beta)", "enableCategoryText": "QB category list", diff --git a/resource/i18n/zh-CN.json b/resource/i18n/zh-CN.json index 0ebc0cac2..5a0ffdbe9 100644 --- a/resource/i18n/zh-CN.json +++ b/resource/i18n/zh-CN.json @@ -583,6 +583,8 @@ "autoStart": "发送种子时自动开始下载", "enabled": "是否启用", "tagIMDb": "发送种子时自动添加IMDb标签(Beta)", + "hostnameAsTag": "发送种子时将小写 host 添加到标签 (Beta)", + "siteNameAsTag": "发送种子时将小写站点名添加到标签 (Beta)", "enableCategory": "发送种子时自动添加 QB 分类 (Beta)", "enableCategoryText": "QB 分类列表", "enableCategoryTextTip": "每行填写一个地址,逗号分隔分类名称和路径, 不支持路径关键字。如:'movie,/tmp/movie'。默认分类请使用'movie,_'的格式。还需在下载目录设置里面填写一样的下载路径. 当指定了下载路径且下载路径命中了某一个分类, 才会添加分类并启用自动种子管理.", diff --git a/src/background/controller.ts b/src/background/controller.ts index 10c25ae95..e620b796d 100644 --- a/src/background/controller.ts +++ b/src/background/controller.ts @@ -273,6 +273,7 @@ export default class Controller { imdbId: downloadOptions.tagIMDb ? downloadOptions.imdbId : null, upLoadLimit: siteConfig !== undefined ? siteConfig.upLoadLimit : null, clientOptions: clientConfig.options, + siteConfig, }) .then((result: any) => { this.service.logger.add({ diff --git a/src/interface/common.ts b/src/interface/common.ts index 8f489c0c1..29033fb3b 100644 --- a/src/interface/common.ts +++ b/src/interface/common.ts @@ -40,6 +40,8 @@ export interface DownloadClient { // 发送种子的时候发送分类 enableCategory?: boolean; qbCategories?: QbCategory[]; + hostnameAsTag?: boolean; + siteNameAsTag?: boolean; } /** diff --git a/src/options/views/settings/DownloadClients/Editor.vue b/src/options/views/settings/DownloadClients/Editor.vue index 3eb94d8ad..baac2987e 100644 --- a/src/options/views/settings/DownloadClients/Editor.vue +++ b/src/options/views/settings/DownloadClients/Editor.vue @@ -51,6 +51,16 @@ v-if="['qbittorrent'].includes(option.type)" > + + + +