mirror of
https://github.com/thsrite/MoviePilot-Plugins.git
synced 2026-05-24 07:26:45 +00:00
fix 插件更新管理
This commit is contained in:
@@ -17,6 +17,7 @@ from app.schemas import NotificationType
|
||||
from app.scheduler import Scheduler
|
||||
from app.schemas.types import EventType
|
||||
from app.core.event import eventmanager, Event
|
||||
from app.utils.string import StringUtils
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -29,7 +30,7 @@ class PluginAutoUpdate(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/pluginupdate.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.7"
|
||||
plugin_version = "1.8"
|
||||
# 插件作者
|
||||
plugin_author = "thsrite"
|
||||
# 作者主页
|
||||
@@ -273,6 +274,40 @@ class PluginAutoUpdate(_PluginBase):
|
||||
break
|
||||
router.add_api_route(**api)
|
||||
|
||||
@staticmethod
|
||||
def get_local_plugins():
|
||||
"""
|
||||
获取本地插件
|
||||
"""
|
||||
# 已安装插件
|
||||
install_plugins = SystemConfigOper().get(SystemConfigKey.UserInstalledPlugins) or []
|
||||
|
||||
local_plugins = {}
|
||||
# 线上插件列表
|
||||
markets = settings.PLUGIN_MARKET.split(",")
|
||||
for market in markets:
|
||||
online_plugins = PluginHelper().get_plugins(market) or {}
|
||||
for pid, plugin in online_plugins.items():
|
||||
if pid in install_plugins:
|
||||
local_plugin = local_plugins.get(pid)
|
||||
if local_plugin:
|
||||
if StringUtils.compare_version(local_plugin.get("plugin_version"), plugin.get("version")) < 0:
|
||||
local_plugins[pid] = {
|
||||
"id": pid,
|
||||
"plugin_name": plugin.get("name"),
|
||||
"repo_url": market,
|
||||
"plugin_version": plugin.get("version")
|
||||
}
|
||||
else:
|
||||
local_plugins[pid] = {
|
||||
"id": pid,
|
||||
"plugin_name": plugin.get("name"),
|
||||
"repo_url": market,
|
||||
"plugin_version": plugin.get("version")
|
||||
}
|
||||
|
||||
return local_plugins
|
||||
|
||||
def get_form(self) -> Tuple[List[dict], Dict[str, Any]]:
|
||||
"""
|
||||
拼装插件配置页面,需要返回两块数据:1、页面配置;2、数据结构
|
||||
@@ -285,14 +320,16 @@ class PluginAutoUpdate(_PluginBase):
|
||||
"value": item.name
|
||||
})
|
||||
|
||||
# 已安装插件
|
||||
local_plugins = self.get_local_plugins()
|
||||
# 编历 local_plugins,生成插件类型选项
|
||||
pluginOptions = []
|
||||
# 本地插件
|
||||
local_plugins = PluginManager().get_local_plugins()
|
||||
for plugin in local_plugins:
|
||||
|
||||
for plugin_id in list(local_plugins.keys()):
|
||||
local_plugin = local_plugins.get(plugin_id)
|
||||
pluginOptions.append({
|
||||
"title": f"{plugin.plugin_name} v{plugin.plugin_version}",
|
||||
"value": plugin.id
|
||||
"title": f"{local_plugin.get('plugin_name')} v{local_plugin.get('plugin_version')}",
|
||||
"value": local_plugin.get("id")
|
||||
})
|
||||
return [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user