diff --git a/package.json b/package.json index d83995e..d584a98 100644 --- a/package.json +++ b/package.json @@ -348,11 +348,12 @@ "name": "MoviePilot更新推送", "description": "MoviePilot推送release更新通知、自动重启。", "labels": "消息通知,自动更新", - "version": "1.3", + "version": "1.4", "icon": "Moviepilot_A.png", "author": "thsrite", "level": 1, "history": { + "v1.4": "兼容更新内容带版本号的情况", "v1.3": "增加前端版本更新检查,需要主程序升级至v1.8.4+版本" } }, diff --git a/plugins/moviepilotupdatenotify/__init__.py b/plugins/moviepilotupdatenotify/__init__.py index e3df7f8..625af7a 100644 --- a/plugins/moviepilotupdatenotify/__init__.py +++ b/plugins/moviepilotupdatenotify/__init__.py @@ -22,7 +22,7 @@ class MoviePilotUpdateNotify(_PluginBase): # 插件图标 plugin_icon = "Moviepilot_A.png" # 插件版本 - plugin_version = "1.3" + plugin_version = "1.4" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -89,22 +89,10 @@ class MoviePilotUpdateNotify(_PluginBase): logger.info(f"发现MoviePilot后端更新:{release_version} {description} {update_time}") # 推送更新消息 - if self._notify: - # 将时间字符串转为datetime对象 - dt = datetime.datetime.strptime(update_time, "%Y-%m-%dT%H:%M:%SZ") - # 设置时区 - timezone = pytz.timezone(settings.TZ) - dt = dt.replace(tzinfo=timezone) - # 将datetime对象转换为带时区的字符串 - update_time = dt.strftime("%Y-%m-%d %H:%M:%S") - self.post_message( - mtype=NotificationType.SiteMessage, - title="【MoviePilot后端更新通知】", - text=f"{release_version} \n" - f"\n" - f"{description} \n" - f"\n" - f"{update_time}") + self.__notify_update(update_time=update_time, + release_version=release_version, + description=description, + mtype="后端") return True @@ -125,6 +113,18 @@ class MoviePilotUpdateNotify(_PluginBase): logger.info(f"发现MoviePilot前端更新:{release_version} {description} {update_time}") + # 推送更新消息 + self.__notify_update(update_time=update_time, + release_version=release_version, + description=description, + mtype="前端") + + return True + + def __notify_update(self, update_time, release_version, description, mtype): + """ + 推送更新消息 + """ # 推送更新消息 if self._notify: # 将时间字符串转为datetime对象 @@ -134,16 +134,12 @@ class MoviePilotUpdateNotify(_PluginBase): dt = dt.replace(tzinfo=timezone) # 将datetime对象转换为带时区的字符串 update_time = dt.strftime("%Y-%m-%d %H:%M:%S") + if not description.startswith(release_version): + description = f"{release_version}\n\n{description}" self.post_message( mtype=NotificationType.SiteMessage, - title="【MoviePilot前端更新通知】", - text=f"{release_version} \n" - f"\n" - f"{description} \n" - f"\n" - f"{update_time}") - - return True + title=f"【MoviePilot{mtype}更新通知】", + text=f"{description}\n\n{update_time}") @staticmethod def __get_release_version():