From 678638e9f14ffaf73f4af6718b8cdd5c869e7f40 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 8 Sep 2023 15:38:32 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=8F=92=E4=BB=B6API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/core/plugin.py | 11 +++++++++-- app/plugins/brushflow/__init__.py | 7 ++++--- app/schemas/plugin.py | 2 ++ app/utils/object.py | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/core/plugin.py b/app/core/plugin.py index 7649490c..2c94a817 100644 --- a/app/core/plugin.py +++ b/app/core/plugin.py @@ -183,6 +183,8 @@ class PluginManager(metaclass=Singleton): # 已安装插件 installed_apps = self.systemconfig.get(SystemConfigKey.UserInstalledPlugins) or [] for pid, plugin in self._plugins.items(): + # 运行状插件 + plugin_obj = self._running_plugins.get(pid) # 基本属性 conf = {} # ID @@ -193,11 +195,16 @@ class PluginManager(metaclass=Singleton): else: conf.update({"installed": False}) # 运行状态 - if pid in self._running_plugins.keys() and hasattr(plugin, "get_state"): - plugin_obj = self._running_plugins.get(pid) + if plugin_obj and hasattr(plugin, "get_state"): conf.update({"state": plugin_obj.get_state()}) else: conf.update({"state": False}) + # 是否有详情页面 + if hasattr(plugin, "get_page"): + if ObjectUtils.check_method(plugin.get_page): + conf.update({"has_page": True}) + else: + conf.update({"has_page": False}) # 权限 if hasattr(plugin, "auth_level"): if self.siteshelper.auth_level < plugin.auth_level: diff --git a/app/plugins/brushflow/__init__.py b/app/plugins/brushflow/__init__.py index 34d30a28..65b45746 100644 --- a/app/plugins/brushflow/__init__.py +++ b/app/plugins/brushflow/__init__.py @@ -28,11 +28,11 @@ class BrushFlow(_PluginBase): # 插件名称 plugin_name = "站点刷流" # 插件描述 - plugin_desc = "自动托管刷流,将会默认提高对应站点的种子刷新频率。" + plugin_desc = "自动托管刷流,将会提高对应站点的访问频率。" # 插件图标 - plugin_icon = "fileupload.png" + plugin_icon = "brush.jpg" # 主题色 - plugin_color = "#EC5665" + plugin_color = "#FFD54E" # 插件版本 plugin_version = "1.0" # 插件作者 @@ -1437,6 +1437,7 @@ class BrushFlow(_PluginBase): else: task_info[torrent_info.get("hash")]["downloaded"] = torrent_info.get("downloaded") task_info[torrent_info.get("hash")]["uploaded"] = torrent_info.get("uploaded") + task_info[torrent_info.get("hash")]["ratio"] = torrent_info.get("ratio") # 做种时间(小时) if self._seed_time: if torrent_info.get("seeding_time") >= float(self._seed_time) * 3600: diff --git a/app/schemas/plugin.py b/app/schemas/plugin.py index f8b4660f..a0f2ee0b 100644 --- a/app/schemas/plugin.py +++ b/app/schemas/plugin.py @@ -32,3 +32,5 @@ class Plugin(BaseModel): installed: Optional[bool] = False # 运行状态 state: Optional[bool] = False + # 是否有详情页面 + has_page: Optional[bool] = False diff --git a/app/utils/object.py b/app/utils/object.py index 6afb2da4..08045807 100644 --- a/app/utils/object.py +++ b/app/utils/object.py @@ -35,7 +35,7 @@ class ObjectUtils: """ 检查函数是否已实现 """ - return func.__code__.co_code != b'd\x01S\x00' + return func.__code__.co_code not in [b'd\x01S\x00', b'\x97\x00d\x00S\x00'] @staticmethod def check_signature(func: FunctionType, *args) -> bool: