mirror of
https://github.com/thsrite/MoviePilot-Plugins.git
synced 2026-03-27 10:05:57 +00:00
feat 日程提醒插件
This commit is contained in:
@@ -20,5 +20,6 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/
|
||||
- [插件强制重装 1.2](plugins_record%2FPluginReInstall.md)
|
||||
- [群辉Webhook通知 1.1](plugins_record%2FSynologyNotify.md)
|
||||
- [同步CookieCloud 1.1](plugins_record%2FSyncCookieCloud.md)
|
||||
- [日程提醒 1.0](plugins_record%2FScheduleReminder.md)
|
||||
|
||||
|
||||
|
||||
BIN
icons/reminder.png
Normal file
BIN
icons/reminder.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
19
package.json
19
package.json
@@ -4,7 +4,6 @@
|
||||
"description": "自动统计和展示站点数据(无站点未读消息)。",
|
||||
"version": "1.0",
|
||||
"icon": "statistic.png",
|
||||
"color": "#324A5E",
|
||||
"author": "lightolly",
|
||||
"level": 2
|
||||
},
|
||||
@@ -13,7 +12,6 @@
|
||||
"description": "监控文件创建,生成Strm文件。",
|
||||
"version": "1.7",
|
||||
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/create.png",
|
||||
"color": "#999999",
|
||||
"author": "thsrite",
|
||||
"level": 1
|
||||
},
|
||||
@@ -22,7 +20,6 @@
|
||||
"description": "Strm文件内容转为本地路径或者cd2/alist API路径。",
|
||||
"version": "1.0",
|
||||
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/convert.png",
|
||||
"color": "#7eabf3",
|
||||
"author": "thsrite",
|
||||
"level": 1
|
||||
},
|
||||
@@ -31,7 +28,6 @@
|
||||
"description": "发送站点未读消息。",
|
||||
"version": "1.2",
|
||||
"icon": "Synomail_A.png",
|
||||
"color": "#4179F4",
|
||||
"author": "thsrite",
|
||||
"level": 2
|
||||
},
|
||||
@@ -40,7 +36,6 @@
|
||||
"description": "清理订阅已下载集数。",
|
||||
"version": "1.0",
|
||||
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/broom.png",
|
||||
"color": "#80bef7",
|
||||
"author": "thsrite",
|
||||
"level": 2
|
||||
},
|
||||
@@ -49,7 +44,6 @@
|
||||
"description": "选择下载器,添加种子任务。",
|
||||
"version": "1.0",
|
||||
"icon": "download.png",
|
||||
"color": "#f87878",
|
||||
"author": "thsrite",
|
||||
"level": 1
|
||||
},
|
||||
@@ -58,7 +52,6 @@
|
||||
"description": "删除下载器中某站点种子。",
|
||||
"version": "1.1",
|
||||
"icon": "delete.png",
|
||||
"color": "#f25454",
|
||||
"author": "thsrite",
|
||||
"level": 1
|
||||
},
|
||||
@@ -67,7 +60,6 @@
|
||||
"description": "监测已安装插件,自动更新最新版本。",
|
||||
"version": "1.2",
|
||||
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/pluginupdate.png",
|
||||
"color": "#95eb95",
|
||||
"author": "thsrite",
|
||||
"level": 1
|
||||
},
|
||||
@@ -76,7 +68,6 @@
|
||||
"description": "卸载当前插件,强制重装。",
|
||||
"version": "1.2",
|
||||
"icon": "refresh.png",
|
||||
"color": "#3c78d8",
|
||||
"author": "thsrite",
|
||||
"level": 1
|
||||
},
|
||||
@@ -85,7 +76,6 @@
|
||||
"description": "接收群辉webhook通知并推送。",
|
||||
"version": "1.1",
|
||||
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/synology.png",
|
||||
"color": "#adc8f7",
|
||||
"author": "thsrite",
|
||||
"level": 1
|
||||
},
|
||||
@@ -94,7 +84,14 @@
|
||||
"description": "同步MoviePilot站点Cookie到CookieCloud。",
|
||||
"version": "1.1",
|
||||
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/cookiecloud.png",
|
||||
"color": "#adc8f7",
|
||||
"author": "thsrite",
|
||||
"level": 1
|
||||
},
|
||||
"ScheduleReminder": {
|
||||
"name": "日程提醒",
|
||||
"description": "自定义提醒事项、提醒时间。",
|
||||
"version": "1.0",
|
||||
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/reminder.png",
|
||||
"author": "thsrite",
|
||||
"level": 1
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class CloudStrm(_PluginBase):
|
||||
|
||||
# 私有属性
|
||||
_enabled = False
|
||||
_monitor_confs = []
|
||||
_monitor_confs = None
|
||||
_onlyonce = False
|
||||
_relay = 3
|
||||
_observer = []
|
||||
|
||||
186
plugins/schedulereminder/__init__.py
Normal file
186
plugins/schedulereminder/__init__.py
Normal file
@@ -0,0 +1,186 @@
|
||||
from app.core.config import settings
|
||||
from app.db.site_oper import SiteOper
|
||||
from app.plugins import _PluginBase
|
||||
from typing import Any, List, Dict, Tuple, Optional
|
||||
from app.log import logger
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
from apscheduler.triggers.cron import CronTrigger
|
||||
|
||||
from app.schemas import NotificationType
|
||||
|
||||
|
||||
class ScheduleReminder(_PluginBase):
|
||||
# 插件名称
|
||||
plugin_name = "日程提醒"
|
||||
# 插件描述
|
||||
plugin_desc = "自定义提醒事项、提醒时间。"
|
||||
# 插件图标
|
||||
plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/reminder.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.0"
|
||||
# 插件作者
|
||||
plugin_author = "thsrite"
|
||||
# 作者主页
|
||||
author_url = "https://github.com/thsrite"
|
||||
# 插件配置项ID前缀
|
||||
plugin_config_prefix = "schedulereminder_"
|
||||
# 加载顺序
|
||||
plugin_order = 32
|
||||
# 可使用的用户级别
|
||||
auth_level = 1
|
||||
|
||||
# 私有属性
|
||||
_enabled: bool = False
|
||||
_confs = None
|
||||
siteoper = None
|
||||
_scheduler: Optional[BackgroundScheduler] = None
|
||||
|
||||
def init_plugin(self, config: dict = None):
|
||||
self.siteoper = SiteOper()
|
||||
|
||||
# 停止现有任务
|
||||
self.stop_service()
|
||||
|
||||
if config:
|
||||
self._enabled = config.get("enabled")
|
||||
self._confs = config.get("confs")
|
||||
|
||||
if self._enabled and self._confs:
|
||||
# 周期运行
|
||||
self._scheduler = BackgroundScheduler(timezone=settings.TZ)
|
||||
|
||||
# 读取目录配置
|
||||
confs = self._confs.split("\n")
|
||||
if not confs:
|
||||
return
|
||||
for conf in confs:
|
||||
if str(conf).count(":") != 1:
|
||||
logger.warn(f"{conf} 格式错误,跳过处理")
|
||||
continue
|
||||
try:
|
||||
self._scheduler.add_job(func=self.__send_notify,
|
||||
trigger=CronTrigger.from_crontab(str(conf).split(":")[1]),
|
||||
name=f"{str(conf).split(':')[0]}提醒",
|
||||
kwargs={"theme": str(conf).split(":")[0]})
|
||||
except Exception as err:
|
||||
logger.error(f"定时任务配置错误:{err}")
|
||||
# 推送实时消息
|
||||
self.systemmessage.put(f"执行周期配置错误:{err}")
|
||||
|
||||
# 启动任务
|
||||
if self._scheduler.get_jobs():
|
||||
self._scheduler.print_jobs()
|
||||
self._scheduler.start()
|
||||
|
||||
def __send_notify(self, theme: str):
|
||||
"""
|
||||
同步站点cookie到cookiecloud
|
||||
"""
|
||||
self.post_message(mtype=NotificationType.Manual,
|
||||
title="日程提醒",
|
||||
text=theme)
|
||||
|
||||
def get_state(self) -> bool:
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def get_command() -> List[Dict[str, Any]]:
|
||||
pass
|
||||
|
||||
def get_api(self) -> List[Dict[str, Any]]:
|
||||
pass
|
||||
|
||||
def get_form(self) -> Tuple[List[dict], Dict[str, Any]]:
|
||||
"""
|
||||
拼装插件配置页面,需要返回两块数据:1、页面配置;2、数据结构
|
||||
"""
|
||||
return [
|
||||
{
|
||||
'component': 'VForm',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VSwitch',
|
||||
'props': {
|
||||
'model': 'enabled',
|
||||
'label': '启用插件',
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VTextarea',
|
||||
'props': {
|
||||
'model': 'confs',
|
||||
'label': '提醒事项',
|
||||
'rows': 5,
|
||||
'placeholder': '提醒内容:cron'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VAlert',
|
||||
'props': {
|
||||
'type': 'info',
|
||||
'variant': 'tonal',
|
||||
'text': '提醒事项格式为:提醒内容:提醒时间cron表达式(一行一条)。'
|
||||
'需开启(手动处理通知)通知类型'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
], {
|
||||
"enabled": False,
|
||||
"confs": "",
|
||||
}
|
||||
|
||||
def get_page(self) -> List[dict]:
|
||||
pass
|
||||
|
||||
def stop_service(self):
|
||||
"""
|
||||
退出插件
|
||||
"""
|
||||
try:
|
||||
if self._scheduler:
|
||||
self._scheduler.remove_all_jobs()
|
||||
if self._scheduler.running:
|
||||
self._scheduler.shutdown()
|
||||
self._scheduler = None
|
||||
except Exception as e:
|
||||
logger.error("退出插件失败:%s" % str(e))
|
||||
5
plugins_record/ScheduleReminder.md
Normal file
5
plugins_record/ScheduleReminder.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# 日程提醒
|
||||
|
||||
### 更新记录
|
||||
|
||||
- 1.0 自定义提醒事项、提醒时间
|
||||
Reference in New Issue
Block a user