diff --git a/package.json b/package.json index 3658cda..fef90d9 100644 --- a/package.json +++ b/package.json @@ -611,11 +611,12 @@ "name": "下载器助手", "description": "自动做种、站点标签、自动删种。", "labels": "下载管理", - "version": "1.6", + "version": "1.7", "icon": "DownloaderHelper.png", "author": "hotlcc", "level": 2, "history": { + "v1.7": "优化了表单界面和一些逻辑。", "v1.6": "修复事件触发tr打标问题;表单界面优化。" } }, diff --git a/plugins/downloaderhelper/__init__.py b/plugins/downloaderhelper/__init__.py index c2f2b38..c802180 100644 --- a/plugins/downloaderhelper/__init__.py +++ b/plugins/downloaderhelper/__init__.py @@ -19,7 +19,7 @@ from app.log import logger from app.modules.qbittorrent.qbittorrent import Qbittorrent from app.modules.transmission.transmission import Transmission from app.plugins import _PluginBase -from app.plugins.downloaderhelper.module import TaskContext, TaskResult +from app.plugins.downloaderhelper.module import TaskContext, TaskResult, Downloader from app.schemas.types import EventType from app.utils.string import StringUtils @@ -32,7 +32,7 @@ class DownloaderHelper(_PluginBase): # 插件图标 plugin_icon = "DownloaderHelper.png" # 插件版本 - plugin_version = "1.6" + plugin_version = "1.7" # 插件作者 plugin_author = "hotlcc" # 作者主页 @@ -168,7 +168,82 @@ class DownloaderHelper(_PluginBase): } # 合并默认配置 config_suggest.update(self.__config_default) - + # 下载器tabs + downloader_tabs = [{ + 'component': 'VTab', + 'props': { + 'value': d.id + }, + 'text': d.name_ + } for d in Downloader if d] + # 下载器tab items + downloader_tab_items = [{ + 'component': 'VWindowItem', + 'props': { + 'value': d.id + }, + 'content': [{ + 'component': 'VRow', + 'content': [{ + 'component': 'VCol', + 'props': { + 'cols': 12, + 'xxl': 3, 'xl': 3, 'lg': 3, 'md': 3, 'sm': 6, 'xs': 12 + }, + 'content': [{ + 'component': 'VSwitch', + 'props': { + 'model': f'{d.short_id}_enable', + 'label': '任务开关', + 'hint': '该下载器子任务的开关' + } + }] + }, { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'xxl': 3, 'xl': 3, 'lg': 3, 'md': 3, 'sm': 6, 'xs': 12 + }, + 'content': [{ + 'component': 'VSwitch', + 'props': { + 'model': f'{d.short_id}_enable_seeding', + 'label': '自动做种', + 'hint': '是否开启自动做种功能' + } + }] + }, { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'xxl': 3, 'xl': 3, 'lg': 3, 'md': 3, 'sm': 6, 'xs': 12 + }, + 'content': [{ + 'component': 'VSwitch', + 'props': { + 'model': f'{d.short_id}_enable_tagging', + 'label': '站点标签', + 'hint': '是否开启站点标签功能' + } + }] + }, { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'xxl': 3, 'xl': 3, 'lg': 3, 'md': 3, 'sm': 6, 'xs': 12 + }, + 'content': [{ + 'component': 'VSwitch', + 'props': { + 'model': f'{d.short_id}_enable_delete', + 'label': '自动删种', + 'hint': '是否开启自动删种功能' + } + }] + }] + }] + } for d in Downloader if d] + # 返回form return [{ 'component': 'VForm', 'content': [{ # 业务无关总控 @@ -313,174 +388,83 @@ class DownloaderHelper(_PluginBase): 'content': [{ 'component': 'VCol', 'props': { - 'cols': 12 + 'cols': 12, + 'xxl': 4, 'xl': 4, 'lg': 4, 'md': 4, 'sm': 6, 'xs': 12 }, 'content': [{ - 'component': 'VTextarea', + 'component': 'VSwitch', 'props': { - 'model': 'tracker_mappings', - 'label': 'Tracker映射', - 'placeholder': '格式:\n' - ':\n\n' - '例如:\n' - 'chdbits.xyz:ptchdbits.co', - 'hint': 'Tracker映射。用于在站点打标签时,指定tracker和站点域名不同的种子的域名对应关系;前面为tracker域名(完整域名或者主域名皆可),中间是英文冒号,后面是站点域名。' + 'model': '_config_tracker_mappings_dialog_closed', + 'label': '配置Tracker映射', + 'hint': '点击展开Tracker映射配置窗口。' } }] }] }, { - 'component': 'VTabs', + 'component': 'VDialog', 'props': { - 'model': '_tabs', - 'height': 72, - 'style': { - 'margin-top': '20px', - 'margin-bottom': '20px' - } + 'model': '_config_tracker_mappings_dialog_closed', + 'max-width': '60rem' }, 'content': [{ - 'component': 'VTab', + 'component': 'VCard', 'props': { - 'value': 'qbittorrent' - }, - 'text': 'qbittorrent' - }, { - 'component': 'VTab', - 'props': { - 'value': 'transmission' - }, - 'text': 'transmission' - }] - }, { - 'component': 'VWindow', - 'props': { - 'model': '_tabs' - }, - 'content': [{ - 'component': 'VWindowItem', - 'props': { - 'value': 'qbittorrent' + 'title': '配置Tracker映射', + 'style': { + 'padding': '0 20px 20px 20px' + } }, 'content': [{ + 'component': 'VDialogCloseBtn', + 'props': { + 'model': '_config_tracker_mappings_dialog_closed' + } + }, { 'component': 'VRow', 'content': [{ 'component': 'VCol', 'props': { - 'cols': 12, - 'xxl': 3, 'xl': 3, 'lg': 3, 'md': 3, 'sm': 6, 'xs': 12 + 'cols': 12 }, 'content': [{ - 'component': 'VSwitch', + 'component': 'VTextarea', 'props': { - 'model': 'qb_enable', - 'label': '任务开关', - 'hint': '该下载器子任务的开关' - } - }] - }, { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'xxl': 3, 'xl': 3, 'lg': 3, 'md': 3, 'sm': 6, 'xs': 12 - }, - 'content': [{ - 'component': 'VSwitch', - 'props': { - 'model': 'qb_enable_seeding', - 'label': '自动做种', - 'hint': '是否开启自动做种功能' - } - }] - }, { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'xxl': 3, 'xl': 3, 'lg': 3, 'md': 3, 'sm': 6, 'xs': 12 - }, - 'content': [{ - 'component': 'VSwitch', - 'props': { - 'model': 'qb_enable_tagging', - 'label': '站点标签', - 'hint': '是否开启站点标签功能' - } - }] - }, { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'xxl': 3, 'xl': 3, 'lg': 3, 'md': 3, 'sm': 6, 'xs': 12 - }, - 'content': [{ - 'component': 'VSwitch', - 'props': { - 'model': 'qb_enable_delete', - 'label': '自动删种', - 'hint': '是否开启自动删种功能' + 'model': 'tracker_mappings', + 'label': 'Tracker映射', + 'placeholder': '格式:\n' + ':\n\n' + '例如:\n' + 'chdbits.xyz:ptchdbits.co', + 'hint': 'Tracker映射。用于在站点打标签时,指定tracker和站点域名不同的种子的域名对应关系;前面为tracker域名(完整域名或者主域名皆可),中间是英文冒号,后面是站点域名。' } }] }] }] - }, { - 'component': 'VWindowItem', + }] + }, { + 'component': 'VRow', + 'content': [{ + 'component': 'VCol', 'props': { - 'value': 'transmission' + 'cols': 12 }, 'content': [{ - 'component': 'VRow', - 'content': [{ - 'component': 'VCol', - 'props': { - 'cols': 12, - 'xxl': 3, 'xl': 3, 'lg': 3, 'md': 3, 'sm': 6, 'xs': 12 - }, - 'content': [{ - 'component': 'VSwitch', - 'props': { - 'model': 'tr_enable', - 'label': '任务开关' - } - }] - }, { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'xxl': 3, 'xl': 3, 'lg': 3, 'md': 3, 'sm': 6, 'xs': 12 - }, - 'content': [{ - 'component': 'VSwitch', - 'props': { - 'model': 'tr_enable_seeding', - 'label': '自动做种' - } - }] - }, { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'xxl': 3, 'xl': 3, 'lg': 3, 'md': 3, 'sm': 6, 'xs': 12 - }, - 'content': [{ - 'component': 'VSwitch', - 'props': { - 'model': 'tr_enable_tagging', - 'label': '站点标签' - } - }] - }, { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'xxl': 3, 'xl': 3, 'lg': 3, 'md': 3, 'sm': 6, 'xs': 12 - }, - 'content': [{ - 'component': 'VSwitch', - 'props': { - 'model': 'tr_enable_delete', - 'label': '自动删种' - } - }] - }] + 'component': 'VTabs', + 'props': { + 'model': '_tabs', + 'height': 72, + 'style': { + 'margin-top-': '20px', + 'margin-bottom-': '20px' + } + }, + 'content': downloader_tabs + }, { + 'component': 'VWindow', + 'props': { + 'model': '_tabs' + }, + 'content': downloader_tab_items }] }] }, { diff --git a/plugins/downloaderhelper/module.py b/plugins/downloaderhelper/module.py index e94ad44..cab6158 100644 --- a/plugins/downloaderhelper/module.py +++ b/plugins/downloaderhelper/module.py @@ -1,15 +1,19 @@ from typing import Set, List, Optional +from enum import Enum -class Constants: +class Downloader(Enum): """ - 常量 + 下载器枚举 """ - # 下载器ID - # qb下载器id - qb_downloader_id: str = 'qbittorrent' - # tr下载器id - tr_downloader_id: str = 'transmission' + QB = ('qbittorrent', 'qBittorrent', 'qb', 'QB') + TR = ('transmission', 'Transmission', 'tr', 'TR') + + def __init__(self, id: str, name_: str, short_id: str, short_name: str): + self.id: str = id + self.name_: str = name_ + self.short_id: str = short_id + self.short_name: str = short_name class TaskResult: @@ -133,14 +137,14 @@ class TaskContext: 是否选择了qb下载器 :return: 是否选择了qb下载器 """ - return self.__is_selected_the_downloader(Constants.qb_downloader_id) + return self.__is_selected_the_downloader(Downloader.QB.id) def is_selected_tr_downloader(self) -> bool: """ 是否选择了tr下载器 :return: 是否选择了tr下载器 """ - return self.__is_selected_the_downloader(Constants.tr_downloader_id) + return self.__is_selected_the_downloader(Downloader.TR.id) def enable_seeding(self, enable_seeding: bool = True): """