mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-04-05 03:38:36 +08:00
feat:支持V2专用插件
This commit is contained in:
@@ -542,11 +542,11 @@ class PluginManager(metaclass=Singleton):
|
||||
获取所有在线插件信息
|
||||
"""
|
||||
|
||||
def __get_plugin_info(market: str) -> Optional[List[schemas.Plugin]]:
|
||||
def __get_plugin_info(market: str, version: str = None) -> Optional[List[schemas.Plugin]]:
|
||||
"""
|
||||
获取插件信息
|
||||
"""
|
||||
online_plugins = self.pluginhelper.get_plugins(market) or {}
|
||||
online_plugins = self.pluginhelper.get_plugins(repo_url=market, version=version) or {}
|
||||
if not online_plugins:
|
||||
logger.warn(f"获取插件库失败:{market}")
|
||||
return
|
||||
@@ -554,10 +554,11 @@ class PluginManager(metaclass=Singleton):
|
||||
add_time = len(online_plugins)
|
||||
for pid, plugin_info in online_plugins.items():
|
||||
# 版本兼容性控制
|
||||
if hasattr(settings, 'VERSION_FLAG') \
|
||||
and not plugin_info.get(settings.VERSION_FLAG):
|
||||
# 插件当前版本不兼容
|
||||
continue
|
||||
if not version:
|
||||
if hasattr(settings, 'VERSION_FLAG') \
|
||||
and not plugin_info.get(settings.VERSION_FLAG):
|
||||
# 插件当前版本不兼容
|
||||
continue
|
||||
# 运行状插件
|
||||
plugin_obj = self._running_plugins.get(pid)
|
||||
# 非运行态插件
|
||||
@@ -644,7 +645,11 @@ class PluginManager(metaclass=Singleton):
|
||||
for m in settings.PLUGIN_MARKET.split(","):
|
||||
if not m:
|
||||
continue
|
||||
futures.append(executor.submit(__get_plugin_info, m))
|
||||
# v1版本插件
|
||||
futures.append(executor.submit(__get_plugin_info, m, None))
|
||||
# v2+版本插件
|
||||
if settings.VERSION_FLAG:
|
||||
futures.append(executor.submit(__get_plugin_info, m, settings.VERSION_FLAG))
|
||||
for future in concurrent.futures.as_completed(futures):
|
||||
plugins = future.result()
|
||||
if plugins:
|
||||
|
||||
@@ -40,10 +40,11 @@ class PluginHelper(metaclass=Singleton):
|
||||
return None if settings.GITHUB_PROXY else settings.PROXY
|
||||
|
||||
@cached(cache=TTLCache(maxsize=1000, ttl=1800))
|
||||
def get_plugins(self, repo_url: str) -> Dict[str, dict]:
|
||||
def get_plugins(self, repo_url: str, version: str = None) -> Dict[str, dict]:
|
||||
"""
|
||||
获取Github所有最新插件列表
|
||||
:param repo_url: Github仓库地址
|
||||
:param version: 版本
|
||||
"""
|
||||
if not repo_url:
|
||||
return {}
|
||||
@@ -51,9 +52,10 @@ class PluginHelper(metaclass=Singleton):
|
||||
if not user or not repo:
|
||||
return {}
|
||||
raw_url = self._base_url % (user, repo)
|
||||
package_url = f"{raw_url}package.{version}.json" if version else f"{raw_url}package.json"
|
||||
res = RequestUtils(proxies=self.proxies,
|
||||
headers=settings.REPO_GITHUB_HEADERS(repo=f"{user}/{repo}"),
|
||||
timeout=10).get_res(f"{raw_url}package.json")
|
||||
timeout=10).get_res(package_url)
|
||||
if res:
|
||||
try:
|
||||
return json.loads(res.text)
|
||||
|
||||
Reference in New Issue
Block a user