diff --git a/package.json b/package.json index 69b87fd..b84970e 100644 --- a/package.json +++ b/package.json @@ -637,11 +637,12 @@ "name": "下载器助手", "description": "自动做种、站点标签、自动删种。", "labels": "下载管理,仪表板", - "version": "2.4", + "version": "2.5", "icon": "DownloaderHelper.png", "author": "hotlcc", - "level": 2, + "level": 1, "history": { + "v2.5": "优化通知类型;降低认证级别要求,使MP非认证用户可用,但无法使用【站点名称优先】功能。主程序需升级至v1.9.2及以上版本,否则插件功能异常!", "v2.4": "修复tr活动种子仪表板的种子排序的bug;优化插件的消息发送。", "v2.3": "仪表板支持多个下载器活动种子组件(主程序版本需大于v1.9.1)。", "v2.2": "优化仪表板组件标题;优化仪表板下载剩余时间描述。", @@ -687,11 +688,12 @@ "name": "插件自动升级", "description": "定时检测、升级插件。", "labels": "自动更新", - "version": "1.8", + "version": "1.9", "icon": "PluginAutoUpgrade.png", "author": "hotlcc", "level": 1, "history": { + "v1.9": "优化通知类型。", "v1.8": "修复重置插件后丢失配置建议的问题。", "v1.7": "修复了一些BUG。", "v1.6": "修正数字配置值提交为字符串导致的问题。", diff --git a/plugins/downloaderhelper/__init__.py b/plugins/downloaderhelper/__init__.py index 29f8eaa..c1fc0b4 100644 --- a/plugins/downloaderhelper/__init__.py +++ b/plugins/downloaderhelper/__init__.py @@ -11,6 +11,7 @@ from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.triggers.cron import CronTrigger from qbittorrentapi import TorrentDictionary, TorrentState from transmission_rpc.torrent import Torrent, Status as TorrentStatus +from ruamel.yaml.comments import CommentedMap from app.core.config import settings from app.core.event import eventmanager, Event @@ -21,6 +22,7 @@ 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, Downloader, TorrentField, TorrentFieldMap, DownloaderMap +from app.schemas import NotificationType from app.schemas.types import EventType from app.utils.string import StringUtils @@ -33,7 +35,7 @@ class DownloaderHelper(_PluginBase): # 插件图标 plugin_icon = "DownloaderHelper.png" # 插件版本 - plugin_version = "2.4" + plugin_version = "2.5" # 插件作者 plugin_author = "hotlcc" # 作者主页 @@ -43,7 +45,7 @@ class DownloaderHelper(_PluginBase): # 加载顺序 plugin_order = 66 # 可使用的用户级别 - auth_level = 2 + auth_level = 1 # 插件说明链接 __help_url = 'https://github.com/jxxghp/MoviePilot-Plugins/tree/main/plugins/downloaderhelper' @@ -99,6 +101,9 @@ class DownloaderHelper(_PluginBase): # 停止现有服务 self.stop_service() + # 检查环境 + self.__check_environment() + # 修正配置 config = self.__fix_config(config=config) # 加载插件配置 @@ -358,7 +363,7 @@ class DownloaderHelper(_PluginBase): 'props': { 'model': 'site_name_priority', 'label': '站点名称优先', - 'hint': '给种子添加站点标签时,是否优先以站点名称作为标签内容(否则将使用域名关键字)?' + 'hint': '给种子添加站点标签时,是否优先以站点名称作为标签内容(否则将使用域名关键字)?MoviePilot需要认证,否则将不生效。' } }] }] @@ -752,6 +757,14 @@ class DownloaderHelper(_PluginBase): finally: self.__exit_event.clear() + @staticmethod + def __check_mp_user_auth() -> bool: + """ + 检查mp用户认证 + :return: True表示已认证 + """ + return SitesHelper().auth_level >= 2 + def __parse_tracker_mappings(self, tracker_mappings: str) -> Dict[str, str]: """ 解析配置的tracker映射 @@ -870,6 +883,13 @@ class DownloaderHelper(_PluginBase): self.update_config(config=config) return config + def __check_environment(self): + """" + 检查环境 + """ + if not self.__check_mp_user_auth(): + logger.warn("MoviePilot未认证,【站点名称优先】功能将不可用。") + def __get_config_item(self, config_key: str, use_default: bool = True) -> Any: """ 获取插件配置项 @@ -913,7 +933,7 @@ class DownloaderHelper(_PluginBase): return value return None - def __get_site_info_by_domain(self, site_domain: str) -> Optional[str]: + def __get_site_info_by_domain(self, site_domain: str) -> CommentedMap: """ 根据站点域名从索引中获取站点信息 :param site_domain: 站点域名 @@ -1293,7 +1313,7 @@ class DownloaderHelper(_PluginBase): text = self.__build_notify_message(context=context) if not text: return - self.post_message(title=f'{self.plugin_name}任务执行结果', text=text) + self.post_message(title=f'{self.plugin_name}任务执行结果', text=text, mtype=NotificationType.Plugin) @staticmethod def __build_notify_message(context: TaskContext): @@ -1328,24 +1348,11 @@ class DownloaderHelper(_PluginBase): text += '\n————————————\n' return text - def __get_system_module_instance(self, module_id: str) -> Union[Qbittorrent, Transmission]: - """ - 获取系统模块实例 - """ - if not module_id: - return None - module_manager = ModuleManager() - running_modules = module_manager._running_modules - if not running_modules: - return None - module = running_modules.get(module_id) - return module if module else None - def __get_qbittorrent(self) -> Qbittorrent: """ 获取qb实例 """ - module = self.__get_system_module_instance(module_id='QbittorrentModule') + module = ModuleManager().get_running_module(module_id='QbittorrentModule') if not module: return None qbittorrent = getattr(module, 'qbittorrent') @@ -1357,7 +1364,7 @@ class DownloaderHelper(_PluginBase): """ 获取tr实例 """ - module = self.__get_system_module_instance(module_id='TransmissionModule') + module = ModuleManager().get_running_module(module_id='TransmissionModule') if not module: return None transmission = getattr(module, 'transmission') diff --git a/plugins/pluginautoupgrade/__init__.py b/plugins/pluginautoupgrade/__init__.py index 5de5a10..20187c7 100644 --- a/plugins/pluginautoupgrade/__init__.py +++ b/plugins/pluginautoupgrade/__init__.py @@ -12,6 +12,7 @@ from app.helper.plugin import PluginHelper from app.log import logger from app.plugins import _PluginBase from app.scheduler import Scheduler +from app.schemas import NotificationType from app.schemas.types import SystemConfigKey @@ -23,7 +24,7 @@ class PluginAutoUpgrade(_PluginBase): # 插件图标 plugin_icon = "PluginAutoUpgrade.png" # 插件版本 - plugin_version = "1.8" + plugin_version = "1.9" # 插件作者 plugin_author = "hotlcc" # 作者主页 @@ -665,7 +666,7 @@ class PluginAutoUpgrade(_PluginBase): text = self.__build_notify_message(results=results) if not text: return - self.post_message(title=f'{self.plugin_name}任务执行结果', text=text) + self.post_message(title=f'{self.plugin_name}任务执行结果', text=text, mtype=NotificationType.Plugin) @staticmethod def __build_notify_message(results: List[Dict[str, Any]]) -> str: