diff --git a/Dockerfile b/Dockerfile index 165ab3706..631532e72 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" @@ -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" ] diff --git a/README.md b/README.md index f5f0a33b6..c43b60435 100644 --- a/README.md +++ b/README.md @@ -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`,建议修改为复杂密码 diff --git a/app/chain/__init__.py b/app/chain/__init__.py index 7ecdcb3bb..b95bbd389 100644 --- a/app/chain/__init__.py +++ b/app/chain/__init__.py @@ -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, diff --git a/app/core/plugin.py b/app/core/plugin.py index 8182660ac..6e508e09c 100644 --- a/app/core/plugin.py +++ b/app/core/plugin.py @@ -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}) # 是否有详情页面 @@ -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}) # 是否有详情页面 diff --git a/app/helper/plugin.py b/app/helper/plugin.py index bbb0d0287..4852123df 100644 --- a/app/helper/plugin.py +++ b/app/helper/plugin.py @@ -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, "" diff --git a/app/plugins/__init__.py b/app/plugins/__init__.py index 9e5e31a0b..40a7b708f 100644 --- a/app/plugins/__init__.py +++ b/app/plugins/__init__.py @@ -86,6 +86,7 @@ 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 @@ -93,6 +94,7 @@ def get_form(self) -> Tuple[List[dict], Dict[str, Any]]: def get_page(self) -> List[dict]: """ 拼装插件详情页面,需要返回页面配置,同时附带数据 + 插件详情页面使用Vuetify组件拼装,参考:https://vuetifyjs.com/ """ pass diff --git a/entrypoint b/entrypoint index 135f8aabb..7a0c3072e 100644 --- a/entrypoint +++ b/entrypoint @@ -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 diff --git a/requirements.txt b/requirements.txt index f8ba56409..d52016441 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 \ No newline at end of file +pystray~=0.19.5 +pypushdeer~=0.0.3 \ No newline at end of file diff --git a/update b/update index e32f2b43f..a9f00400d 100644 --- a/update +++ b/update @@ -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/ # 插件仓库 @@ -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 \ No newline at end of file