Skip to content

Commit

Permalink
feat: 可将站点名称作为 tag 添加到 qb
Browse files Browse the repository at this point in the history
  • Loading branch information
IITII committed Dec 18, 2023
1 parent ef8968d commit ed27df8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
22 changes: 19 additions & 3 deletions resource/clients/qbittorrent/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions resource/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions resource/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,8 @@
"autoStart": "发送种子时自动开始下载",
"enabled": "是否启用",
"tagIMDb": "发送种子时自动添加IMDb标签(Beta)",
"hostnameAsTag": "发送种子时将小写 host 添加到标签 (Beta)",
"siteNameAsTag": "发送种子时将小写站点名添加到标签 (Beta)",
"enableCategory": "发送种子时自动添加 QB 分类 (Beta)",
"enableCategoryText": "QB 分类列表",
"enableCategoryTextTip": "每行填写一个地址,逗号分隔分类名称和路径, 不支持路径关键字。如:'movie,/tmp/movie'。默认分类请使用'movie,_'的格式。还需在下载目录设置里面填写一样的下载路径. 当指定了下载路径且下载路径命中了某一个分类, 才会添加分类并启用自动种子管理.",
Expand Down
1 change: 1 addition & 0 deletions src/background/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 2 additions & 0 deletions src/interface/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export interface DownloadClient {
// 发送种子的时候发送分类
enableCategory?: boolean;
qbCategories?: QbCategory[];
hostnameAsTag?: boolean;
siteNameAsTag?: boolean;
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/options/views/settings/DownloadClients/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@
v-if="['qbittorrent'].includes(option.type)"
></v-switch>

<!--站点 host 作为 qb 标签-->
<v-switch
:label="$t('settings.downloadClients.editor.hostnameAsTag')"
v-model="option.hostnameAsTag"
></v-switch>
<!--站点名 作为 qb 标签-->
<v-switch
:label="$t('settings.downloadClients.editor.siteNameAsTag')"
v-model="option.siteNameAsTag"
></v-switch>
<!--启用 qb 分类-->
<v-switch
:label="$t('settings.downloadClients.editor.enableCategory')"
Expand Down

0 comments on commit ed27df8

Please sign in to comment.