mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
feat:支持V2专用插件
This commit is contained in:
+8
-3
@@ -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:
|
if not online_plugins:
|
||||||
logger.warn(f"获取插件库失败:{market}")
|
logger.warn(f"获取插件库失败:{market}")
|
||||||
return
|
return
|
||||||
@@ -554,6 +554,7 @@ class PluginManager(metaclass=Singleton):
|
|||||||
add_time = len(online_plugins)
|
add_time = len(online_plugins)
|
||||||
for pid, plugin_info in online_plugins.items():
|
for pid, plugin_info in online_plugins.items():
|
||||||
# 版本兼容性控制
|
# 版本兼容性控制
|
||||||
|
if not version:
|
||||||
if hasattr(settings, 'VERSION_FLAG') \
|
if hasattr(settings, 'VERSION_FLAG') \
|
||||||
and not plugin_info.get(settings.VERSION_FLAG):
|
and not plugin_info.get(settings.VERSION_FLAG):
|
||||||
# 插件当前版本不兼容
|
# 插件当前版本不兼容
|
||||||
@@ -644,7 +645,11 @@ class PluginManager(metaclass=Singleton):
|
|||||||
for m in settings.PLUGIN_MARKET.split(","):
|
for m in settings.PLUGIN_MARKET.split(","):
|
||||||
if not m:
|
if not m:
|
||||||
continue
|
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):
|
for future in concurrent.futures.as_completed(futures):
|
||||||
plugins = future.result()
|
plugins = future.result()
|
||||||
if plugins:
|
if plugins:
|
||||||
|
|||||||
@@ -40,10 +40,11 @@ class PluginHelper(metaclass=Singleton):
|
|||||||
return None if settings.GITHUB_PROXY else settings.PROXY
|
return None if settings.GITHUB_PROXY else settings.PROXY
|
||||||
|
|
||||||
@cached(cache=TTLCache(maxsize=1000, ttl=1800))
|
@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所有最新插件列表
|
获取Github所有最新插件列表
|
||||||
:param repo_url: Github仓库地址
|
:param repo_url: Github仓库地址
|
||||||
|
:param version: 版本
|
||||||
"""
|
"""
|
||||||
if not repo_url:
|
if not repo_url:
|
||||||
return {}
|
return {}
|
||||||
@@ -51,9 +52,10 @@ class PluginHelper(metaclass=Singleton):
|
|||||||
if not user or not repo:
|
if not user or not repo:
|
||||||
return {}
|
return {}
|
||||||
raw_url = self._base_url % (user, repo)
|
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,
|
res = RequestUtils(proxies=self.proxies,
|
||||||
headers=settings.REPO_GITHUB_HEADERS(repo=f"{user}/{repo}"),
|
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:
|
if res:
|
||||||
try:
|
try:
|
||||||
return json.loads(res.text)
|
return json.loads(res.text)
|
||||||
|
|||||||
Reference in New Issue
Block a user