Merge pull request #917 from thsrite/main

fix 更新通知
This commit is contained in:
jxxghp 2023-10-19 18:11:06 +08:00 committed by GitHub
commit c3fe22a76f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,5 @@
import datetime
from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.cron import CronTrigger from apscheduler.triggers.cron import CronTrigger
@ -81,12 +83,14 @@ class MoviePilotUpdateNotify(_PluginBase):
# 本地版本 # 本地版本
local_version = SystemChain().get_local_version() local_version = SystemChain().get_local_version()
if release_version == local_version: if local_version and release_version <= local_version:
logger.info(f"当前版本:{local_version} 远程版本:{release_version} 停止运行") logger.info(f"当前版本:{local_version} 远程版本:{release_version} 停止运行")
return return
# 推送更新消息 # 推送更新消息
if self._notify: if self._notify:
# 将时间字符串转为datetime对象
update_time = datetime.datetime.strptime(update_time, "%Y-%m-%dT%H:%M:%SZ").strftime("%Y-%m-%d %H:%M:%S")
self.post_message( self.post_message(
mtype=NotificationType.SiteMessage, mtype=NotificationType.SiteMessage,
title="【MoviePilot更新通知】", title="【MoviePilot更新通知】",
@ -131,91 +135,91 @@ class MoviePilotUpdateNotify(_PluginBase):
拼装插件配置页面需要返回两块数据1页面配置2数据结构 拼装插件配置页面需要返回两块数据1页面配置2数据结构
""" """
return [ return [
{ {
'component': 'VForm', 'component': 'VForm',
'content': [ 'content': [
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'enabled', 'model': 'enabled',
'label': '启用插件', 'label': '启用插件',
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'update', 'model': 'update',
'label': '自动更新', 'label': '自动更新',
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'notify', 'model': 'notify',
'label': '发送通知', 'label': '发送通知',
} }
} }
] ]
} }
] ]
}, },
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
}, },
'content': [ 'content': [
{ {
'component': 'VTextField', 'component': 'VTextField',
'props': { 'props': {
'model': 'cron', 'model': 'cron',
'label': '检查周期', 'label': '检查周期',
'placeholder': '5位cron表达式' 'placeholder': '5位cron表达式'
} }
} }
] ]
}, },
] ]
} }
] ]
} }
], { ], {
"enabled": False, "enabled": False,
"update": False, "update": False,
"notify": False, "notify": False,
"cron": "0 9 * * *" "cron": "0 9 * * *"
} }
def get_page(self) -> List[dict]: def get_page(self) -> List[dict]:
pass pass