Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Nov 6, 2023
2 parents eb9a92d + 89a4932 commit 9744032
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 51 deletions.
14 changes: 6 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ ENV LANG="C.UTF-8" \
PORT=3001 \
NGINX_PORT=3000 \
PROXY_HOST="" \
MOVIEPILOT_AUTO_UPDATE=true \
MOVIEPILOT_AUTO_UPDATE_DEV=false \
MOVIEPILOT_AUTO_UPDATE=release \
AUTH_SITE="iyuu" \
IYUU_SIGN=""
WORKDIR "/app"
Expand Down Expand Up @@ -78,12 +77,11 @@ RUN cp -f /app/nginx.conf /etc/nginx/nginx.template.conf \
&& FRONTEND_VERSION=$(curl -sL "https://api.github.com/repos/jxxghp/MoviePilot-Frontend/releases/latest" | jq -r .tag_name) \
&& curl -sL "https://github.com/jxxghp/MoviePilot-Frontend/releases/download/${FRONTEND_VERSION}/dist.zip" | busybox unzip -d / - \
&& mv /dist /public \
&& curl -sL "https://github.com/jxxghp/MoviePilot-Plugins/archive/refs/heads/main.zip" | busybox unzip -d / - \
&& mv -f /MoviePilot-Plugins-main/plugins/* /app/app/plugins/ \
&& rm -rf /MoviePilot-Plugins-main \
&& curl -sL "https://github.com/jxxghp/MoviePilot-Resources/archive/refs/heads/main.zip" | busybox unzip -d / - \
&& mv -f /MoviePilot-Resources-main/resources/* /app/app/helper/ \
&& rm -rf /MoviePilot-Resources-main
&& curl -sL "https://github.com/jxxghp/MoviePilot-Plugins/archive/refs/heads/main.zip" | busybox unzip -d /tmp - \
&& mv -f /tmp/MoviePilot-Plugins-main/plugins/* /app/app/plugins/ \
&& curl -sL "https://github.com/jxxghp/MoviePilot-Resources/archive/refs/heads/main.zip" | busybox unzip -d /tmp - \
&& mv -f /tmp/MoviePilot-Resources-main/resources/* /app/app/helper/ \
&& rm -rf /tmp/*
EXPOSE 3000
VOLUME [ "/config" ]
ENTRYPOINT [ "/entrypoint" ]
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ MoviePilot需要配套下载器和媒体服务器配合使用。
- **PGID**:运行程序用户的`gid`,默认`0`(仅支持环境变量配置)
- **UMASK**:掩码权限,默认`000`,可以考虑设置为`022`(仅支持环境变量配置)
- **PROXY_HOST:** 网络代理,访问themoviedb或者重启更新需要使用代理访问,格式为`http(s)://ip:port``socks5://user:pass@host:port`(仅支持环境变量配置)
- **MOVIEPILOT_AUTO_UPDATE**:重启更新,`true`/`false`,默认`true` **注意:如果出现网络问题可以配置`PROXY_HOST`**(仅支持环境变量配置)
- **MOVIEPILOT_AUTO_UPDATE_DEV**:重启时更新到未发布的开发版本代码,`true`/`false`,默认`false`(仅支持环境变量配置)
- **MOVIEPILOT_AUTO_UPDATE**:重启更新,`true`/`release`/`dev`/`false`,默认`release` **注意:如果出现网络问题可以配置`PROXY_HOST`**(仅支持环境变量配置)
---
- **❗SUPERUSER:** 超级管理员用户名,默认`admin`,安装后使用该用户登录后台管理界面
- **❗SUPERUSER_PASSWORD:** 超级管理员初始密码,默认`password`,建议修改为复杂密码
Expand Down
1 change: 1 addition & 0 deletions app/chain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ def post_message(self, message: Notification) -> None:
self.eventmanager.send_event(etype=EventType.NoticeMessage,
data={
"channel": message.channel,
"type": message.mtype,
"title": message.title,
"text": message.text,
"image": message.image,
Expand Down
14 changes: 12 additions & 2 deletions app/core/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,12 @@ def get_online_plugins(self) -> List[dict]:
conf.update({"has_update": True})
# 运行状态
if plugin_obj and hasattr(plugin_obj, "get_state"):
conf.update({"state": plugin_obj.get_state()})
try:
state = plugin_obj.get_state()
except Exception as e:
logger.error(f"获取插件 {pid} 状态出错:{str(e)}")
state = False
conf.update({"state": state})
else:
conf.update({"state": False})
# 是否有详情页面
Expand Down Expand Up @@ -293,7 +298,12 @@ def get_local_plugins(self) -> List[dict]:
conf.update({"installed": False})
# 运行状态
if plugin_obj and hasattr(plugin_obj, "get_state"):
conf.update({"state": plugin_obj.get_state()})
try:
state = plugin_obj.get_state()
except Exception as e:
logger.error(f"获取插件 {pid} 状态出错:{str(e)}")
state = False
conf.update({"state": state})
else:
conf.update({"state": False})
# 是否有详情页面
Expand Down
4 changes: 4 additions & 0 deletions app/helper/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,8 @@ def __download_files(_p: str, _l: List[dict]) -> Tuple[bool, str]:
shutil.rmtree(plugin_dir, ignore_errors=True)
# 下载所有文件
__download_files(pid.lower(), file_list)
# 插件目录下如有requirements.txt则安装依赖
requirements_file = plugin_dir / "requirements.txt"
if requirements_file.exists():
SystemUtils.execute(f"pip install -r {requirements_file}")
return True, ""
2 changes: 2 additions & 0 deletions app/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ def get_api(self) -> List[Dict[str, Any]]:
def get_form(self) -> Tuple[List[dict], Dict[str, Any]]:
"""
拼装插件配置页面,需要返回两块数据:1、页面配置;2、数据结构
插件配置页面使用Vuetify组件拼装,参考:https://vuetifyjs.com/
"""
pass

@abstractmethod
def get_page(self) -> List[dict]:
"""
拼装插件详情页面,需要返回页面配置,同时附带数据
插件详情页面使用Vuetify组件拼装,参考:https://vuetifyjs.com/
"""
pass

Expand Down
10 changes: 3 additions & 7 deletions entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
# 使用 `envsubst` 将模板文件中的 ${NGINX_PORT} 替换为实际的环境变量值
envsubst '${NGINX_PORT}${PORT}' < /etc/nginx/nginx.template.conf > /etc/nginx/nginx.conf
# 自动更新
if [ "${MOVIEPILOT_AUTO_UPDATE}" = "true" ]; then
cd /
/usr/local/bin/mp_update
cd /app
else
echo "程序自动升级已关闭,如需自动升级请在创建容器时设置环境变量:MOVIEPILOT_AUTO_UPDATE=true"
fi
cd /
/usr/local/bin/mp_update
cd /app
# 更改 moviepilot userid 和 groupid
groupmod -o -g ${PGID} moviepilot
usermod -o -u ${PUID} moviepilot
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ parse~=1.19.0
docker~=6.1.3
cachetools~=5.3.1
fast-bencode~=1.1.3
pystray~=0.19.5
pystray~=0.19.5
pypushdeer~=0.0.3
66 changes: 35 additions & 31 deletions update
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ install_backend_and_download_resources() {
# 清空目录
rm -rf /app
# 后端程序
mv -f /tmp/App /app
mv /tmp/App /app
# 恢复插件目录
mv -f /plugins/* /app/app/plugins/
# 插件仓库
Expand Down Expand Up @@ -74,39 +74,43 @@ install_backend_and_download_resources() {
fi
}

# ...

if [ -n "${PROXY_HOST}" ]; then
CURL_OPTIONS="-sL -x ${PROXY_HOST}"
PIP_OPTIONS="--proxy=${PROXY_HOST}"
echo "使用代理更新程序"
else
CURL_OPTIONS="-sL"
echo "不使用代理更新程序"
fi

if [ "${MOVIEPILOT_AUTO_UPDATE_DEV}" = "true" ]; then
echo "Dev 更新模式"
install_backend_and_download_resources "heads/main.zip"
else
old_version=$(cat /app/version.py)
if [[ "${old_version}" == *APP_VERSION* ]]; then
current_version=v$(echo ${old_version} | sed -ne "s/APP_VERSION\s=\s'v\(.*\)'/\1/gp")
echo "当前版本号:${current_version}"
new_version=$(curl ${CURL_OPTIONS} "https://api.github.com/repos/jxxghp/MoviePilot/releases/latest" | jq -r .tag_name)
if [[ "${new_version}" == *v* ]]; then
release_version=${new_version}
echo "最新版本号:${release_version}"
if [ "${current_version}" != "${release_version}" ]; then
echo "发现新版本,开始自动升级..."
install_backend_and_download_resources "tags/${release_version}.zip"
if [[ "${MOVIEPILOT_AUTO_UPDATE}" = "true" ]] || [[ "${MOVIEPILOT_AUTO_UPDATE}" = "release" ]] || elif [[ "${MOVIEPILOT_AUTO_UPDATE}" = "dev" ]]; then
if [ -n "${PROXY_HOST}" ]; then
CURL_OPTIONS="-sL -x ${PROXY_HOST}"
PIP_OPTIONS="--proxy=${PROXY_HOST}"
echo "使用代理更新程序"
else
CURL_OPTIONS="-sL"
echo "不使用代理更新程序"
fi
if [ "${MOVIEPILOT_AUTO_UPDATE}" = "dev" ]; then
echo "Dev 更新模式"
install_backend_and_download_resources "heads/main.zip"
else
echo "Release 更新模式"
old_version=$(cat /app/version.py)
if [[ "${old_version}" == *APP_VERSION* ]]; then
current_version=v$(echo ${old_version} | sed -ne "s/APP_VERSION\s=\s'v\(.*\)'/\1/gp")
echo "当前版本号:${current_version}"
new_version=$(curl ${CURL_OPTIONS} "https://api.github.com/repos/jxxghp/MoviePilot/releases/latest" | jq -r .tag_name)
if [[ "${new_version}" == *v* ]]; then
release_version=${new_version}
echo "最新版本号:${release_version}"
if [ "${current_version}" != "${release_version}" ]; then
echo "发现新版本,开始自动升级..."
install_backend_and_download_resources "tags/${release_version}.zip"
else
echo "未发现新版本,跳过更新步骤..."
fi
else
echo "未发现新版本,跳过更新步骤..."
echo "最新版本号获取失败,继续启动..."
fi
else
echo "最新版本号获取失败,继续启动..."
echo "当前版本号获取失败,继续启动..."
fi
else
echo "当前版本号获取失败,继续启动..."
fi
elif [[ "${MOVIEPILOT_AUTO_UPDATE}" = "false" ]]; then
echo "程序自动升级已关闭,如需自动升级请在创建容器时设置环境变量:MOVIEPILOT_AUTO_UPDATE=release"
else
echo "MOVIEPILOT_AUTO_UPDATE 变量设置错误"
fi

0 comments on commit 9744032

Please sign in to comment.