feat 插件API

This commit is contained in:
jxxghp 2023-09-08 15:38:32 +08:00
parent d1f9647a63
commit 678638e9f1
4 changed files with 16 additions and 6 deletions

View File

@ -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:

View File

@ -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:

View File

@ -32,3 +32,5 @@ class Plugin(BaseModel):
installed: Optional[bool] = False
# 运行状态
state: Optional[bool] = False
# 是否有详情页面
has_page: Optional[bool] = False

View File

@ -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: