feat 优化插件仓库URL格式
This commit is contained in:
parent
615a52cef9
commit
fb39500428
@ -105,7 +105,7 @@ MoviePilot需要配套下载器和媒体服务器配合使用。
|
|||||||
- **AUTO_DOWNLOAD_USER:** 远程交互搜索时自动择优下载的用户ID(消息通知渠道的用户ID),多个用户使用,分割,未设置需要选择资源或者回复`0`
|
- **AUTO_DOWNLOAD_USER:** 远程交互搜索时自动择优下载的用户ID(消息通知渠道的用户ID),多个用户使用,分割,未设置需要选择资源或者回复`0`
|
||||||
---
|
---
|
||||||
- **OCR_HOST:** OCR识别服务器地址,格式:`http(s)://ip:port`,用于识别站点验证码实现自动登录获取Cookie等,不配置默认使用内建服务器`https://movie-pilot.org`,可使用 [这个镜像](https://hub.docker.com/r/jxxghp/moviepilot-ocr) 自行搭建。
|
- **OCR_HOST:** OCR识别服务器地址,格式:`http(s)://ip:port`,用于识别站点验证码实现自动登录获取Cookie等,不配置默认使用内建服务器`https://movie-pilot.org`,可使用 [这个镜像](https://hub.docker.com/r/jxxghp/moviepilot-ocr) 自行搭建。
|
||||||
- **PLUGIN_MARKET:** 插件市场仓库地址,多个地址使用`,`分隔,保留最后的/,默认为官方插件仓库:`https://raw.githubusercontent.com/jxxghp/MoviePilot-Plugins/main/`。
|
- **PLUGIN_MARKET:** 插件市场仓库地址,仅支持Github仓库,`main`分支,多个地址使用`,`分隔,保留最后的/,默认为官方插件仓库:`https://github.com/jxxghp/MoviePilot-Plugins/ `。
|
||||||
- **GITHUB_TOKEN:** Github token,提高请求api限流阈值 ghp_****(仅支持环境变量配置)
|
- **GITHUB_TOKEN:** Github token,提高请求api限流阈值 ghp_****(仅支持环境变量配置)
|
||||||
---
|
---
|
||||||
- **❗MESSAGER:** 消息通知渠道,支持 `telegram`/`wechat`/`slack`/`synologychat`,开启多个渠道时使用`,`分隔。同时还需要配置对应渠道的环境变量,非对应渠道的变量可删除,推荐使用`telegram`
|
- **❗MESSAGER:** 消息通知渠道,支持 `telegram`/`wechat`/`slack`/`synologychat`,开启多个渠道时使用`,`分隔。同时还需要配置对应渠道的环境变量,非对应渠道的变量可删除,推荐使用`telegram`
|
||||||
|
@ -16,6 +16,8 @@ class PluginHelper(metaclass=Singleton):
|
|||||||
插件市场管理,下载安装插件到本地
|
插件市场管理,下载安装插件到本地
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_base_url = "https://raw.githubusercontent.com/%s/%s/main/"
|
||||||
|
|
||||||
@cached(cache=TTLCache(maxsize=10, ttl=1800))
|
@cached(cache=TTLCache(maxsize=10, ttl=1800))
|
||||||
def get_plugins(self, repo_url: str) -> Dict[str, dict]:
|
def get_plugins(self, repo_url: str) -> Dict[str, dict]:
|
||||||
"""
|
"""
|
||||||
@ -24,27 +26,43 @@ class PluginHelper(metaclass=Singleton):
|
|||||||
"""
|
"""
|
||||||
if not repo_url:
|
if not repo_url:
|
||||||
return {}
|
return {}
|
||||||
|
user, repo = self.get_repo_info(repo_url)
|
||||||
|
if not user or not repo:
|
||||||
|
return {}
|
||||||
|
raw_url = self._base_url % (user, repo)
|
||||||
res = RequestUtils(proxies=settings.PROXY, headers=settings.GITHUB_HEADERS,
|
res = RequestUtils(proxies=settings.PROXY, headers=settings.GITHUB_HEADERS,
|
||||||
timeout=10).get_res(f"{repo_url}package.json")
|
timeout=10).get_res(f"{raw_url}package.json")
|
||||||
if res:
|
if res:
|
||||||
return json.loads(res.text)
|
return json.loads(res.text)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def install(pid: str, repo_url: str) -> Tuple[bool, str]:
|
def get_repo_info(repo_url: str) -> Tuple[Optional[str], Optional[str]]:
|
||||||
"""
|
"""
|
||||||
安装插件
|
获取Github仓库信息
|
||||||
|
:param repo_url: Github仓库地址
|
||||||
"""
|
"""
|
||||||
# 从Github的repo_url获取用户和项目名
|
if not repo_url:
|
||||||
|
return None, None
|
||||||
try:
|
try:
|
||||||
user, repo = repo_url.split("/")[-4:-2]
|
user, repo = repo_url.split("/")[-4:-2]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False, f"不支持的插件仓库地址格式:{str(e)}"
|
print(str(e))
|
||||||
if not user or not repo:
|
return None, None
|
||||||
return False, "不支持的插件仓库地址格式"
|
return user, repo
|
||||||
|
|
||||||
|
def install(self, pid: str, repo_url: str) -> Tuple[bool, str]:
|
||||||
|
"""
|
||||||
|
安装插件
|
||||||
|
"""
|
||||||
if SystemUtils.is_frozen():
|
if SystemUtils.is_frozen():
|
||||||
return False, "可执行文件模式下,只能安装本地插件"
|
return False, "可执行文件模式下,只能安装本地插件"
|
||||||
|
|
||||||
|
# 从Github的repo_url获取用户和项目名
|
||||||
|
user, repo = self.get_repo_info(repo_url)
|
||||||
|
if not user or not repo:
|
||||||
|
return False, "不支持的插件仓库地址格式"
|
||||||
|
|
||||||
def __get_filelist(_p: str) -> Tuple[Optional[list], Optional[str]]:
|
def __get_filelist(_p: str) -> Tuple[Optional[list], Optional[str]]:
|
||||||
"""
|
"""
|
||||||
获取插件的文件列表
|
获取插件的文件列表
|
||||||
|
@ -194,5 +194,5 @@ PLEX_TOKEN=
|
|||||||
# OCR服务器地址
|
# OCR服务器地址
|
||||||
OCR_HOST=https://movie-pilot.org
|
OCR_HOST=https://movie-pilot.org
|
||||||
# 插件市场仓库地址,多个地址使用`,`分隔,保留最后的/
|
# 插件市场仓库地址,多个地址使用`,`分隔,保留最后的/
|
||||||
PLUGIN_MARKET=https://raw.githubusercontent.com/jxxghp/MoviePilot-Plugins/main/
|
PLUGIN_MARKET=https://github.com/jxxghp/MoviePilot-Plugins/
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user