mirror of
https://github.com/thsrite/MoviePilot-Plugins.git
synced 2026-03-27 10:05:57 +00:00
fix 自定义保留消息天数
This commit is contained in:
@@ -10,7 +10,7 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/
|
||||
### 插件新增
|
||||
|
||||
- 站点数据统计 1.4 (无未读消息版本)(废弃)
|
||||
- 站点未读消息 1.7
|
||||
- 站点未读消息 1.8 (依赖于[站点数据统计]插件)
|
||||
- [云盘Strm生成 3.7](docs%2FCloudStrm.md)
|
||||
- [Strm文件模式转换 1.0](docs%2FStrmConvert.md)
|
||||
- 清理订阅缓存 1.0
|
||||
@@ -29,8 +29,8 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/
|
||||
- 源文件恢复 1.2
|
||||
- [微信消息转发 2.1](docs%2FWeChatForward.md)
|
||||
- 订阅下载统计 1.5
|
||||
- [自定义命令 1.5](docs%2FCustomCommand.md)
|
||||
- docker自定义任务 1.2
|
||||
- [自定义命令 1.6](docs%2FCustomCommand.md)
|
||||
- docker自定义任务 1.3
|
||||
- 插件彻底卸载 1.0
|
||||
- 实时软连接 1.3
|
||||
- 订阅规则自动填充 2.5
|
||||
|
||||
@@ -28,11 +28,12 @@
|
||||
"SiteUnreadMsg": {
|
||||
"name": "站点未读消息",
|
||||
"description": "发送站点未读消息。",
|
||||
"version": "1.7",
|
||||
"version": "1.8",
|
||||
"icon": "Synomail_A.png",
|
||||
"author": "thsrite",
|
||||
"level": 2,
|
||||
"history": {
|
||||
"v1.8": "自定义保留消息天数",
|
||||
"v1.7": "删除重复代码、依赖于[站点数据统计]插件",
|
||||
"v1.6": "增加解析失败日志",
|
||||
"v1.5": "修复馒头未读消息1",
|
||||
@@ -274,11 +275,12 @@
|
||||
"CustomCommand": {
|
||||
"name": "自定义命令",
|
||||
"description": "自定义执行周期执行命令并推送结果。",
|
||||
"version": "1.5",
|
||||
"version": "1.6",
|
||||
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/code.png",
|
||||
"author": "thsrite",
|
||||
"level": 1,
|
||||
"history": {
|
||||
"v1.6": "自定义保留消息天数",
|
||||
"v1.5": "修复多个任务立即运行一次",
|
||||
"v1.4": "fix icon",
|
||||
"v1.3": "清除历史记录",
|
||||
@@ -290,11 +292,12 @@
|
||||
"DockerManager": {
|
||||
"name": "docker自定义任务",
|
||||
"description": "管理宿主机docker,自定义容器定时任务。",
|
||||
"version": "1.2",
|
||||
"version": "1.3",
|
||||
"icon": "Docker_F.png",
|
||||
"author": "thsrite",
|
||||
"level": 1,
|
||||
"history": {
|
||||
"v1.3": "自定义保留消息天数",
|
||||
"v1.2": "多个容器名,拼接",
|
||||
"v1.1": "修复多个任务立即运行一次",
|
||||
"v1.0": "init"
|
||||
|
||||
@@ -22,7 +22,7 @@ class CustomCommand(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/code.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.5"
|
||||
plugin_version = "1.6"
|
||||
# 插件作者
|
||||
plugin_author = "thsrite"
|
||||
# 作者主页
|
||||
@@ -41,6 +41,7 @@ class CustomCommand(_PluginBase):
|
||||
_clear: bool = False
|
||||
_msgtype: str = None
|
||||
_time_confs = None
|
||||
_history_days = None
|
||||
_scheduler: Optional[BackgroundScheduler] = None
|
||||
|
||||
def init_plugin(self, config: dict = None):
|
||||
@@ -53,6 +54,7 @@ class CustomCommand(_PluginBase):
|
||||
self._notify = config.get("notify")
|
||||
self._msgtype = config.get("msgtype")
|
||||
self._clear = config.get("clear")
|
||||
self._history_days = config.get("history_days") or 30
|
||||
self._time_confs = config.get("time_confs")
|
||||
|
||||
# 清除历史
|
||||
@@ -149,6 +151,11 @@ class CustomCommand(_PluginBase):
|
||||
"result": last_output if last_output else last_error,
|
||||
"time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
|
||||
})
|
||||
|
||||
thirty_days_ago = time.time() - int(self._history_days) * 24 * 60 * 60
|
||||
history = [record for record in history if
|
||||
datetime.strptime(record["time"],
|
||||
'%Y-%m-%d %H:%M:%S').timestamp() >= thirty_days_ago]
|
||||
# 保存历史
|
||||
self.save_data(key="history", value=history)
|
||||
|
||||
@@ -169,6 +176,7 @@ class CustomCommand(_PluginBase):
|
||||
"notify": self._notify,
|
||||
"msgtype": self._msgtype,
|
||||
"time_confs": self._time_confs,
|
||||
"history_days": self._history_days,
|
||||
"clear": self._clear
|
||||
})
|
||||
|
||||
@@ -204,7 +212,7 @@ class CustomCommand(_PluginBase):
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 2
|
||||
'md': 3
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
@@ -220,7 +228,7 @@ class CustomCommand(_PluginBase):
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 2
|
||||
'md': 3
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
@@ -264,11 +272,16 @@ class CustomCommand(_PluginBase):
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 2
|
||||
'md': 6
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
@@ -283,6 +296,22 @@ class CustomCommand(_PluginBase):
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 6
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VTextField',
|
||||
'props': {
|
||||
'model': 'history_days',
|
||||
'label': '保留历史天数'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -358,6 +387,7 @@ class CustomCommand(_PluginBase):
|
||||
"onlyonce": False,
|
||||
"clear": False,
|
||||
"time_confs": "",
|
||||
"history_days": 30,
|
||||
"msgtype": ""
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class DockerManager(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "Docker_F.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.2"
|
||||
plugin_version = "1.3"
|
||||
# 插件作者
|
||||
plugin_author = "thsrite"
|
||||
# 作者主页
|
||||
@@ -41,6 +41,7 @@ class DockerManager(_PluginBase):
|
||||
_msgtype: str = None
|
||||
_time_confs = None
|
||||
_docker_client = None
|
||||
_history_days = None
|
||||
_scheduler: Optional[BackgroundScheduler] = None
|
||||
|
||||
def init_plugin(self, config: dict = None):
|
||||
@@ -54,6 +55,7 @@ class DockerManager(_PluginBase):
|
||||
self._msgtype = config.get("msgtype")
|
||||
self._clear = config.get("clear")
|
||||
self._time_confs = config.get("time_confs")
|
||||
self._history_days = config.get("history_days") or 30
|
||||
|
||||
# 清除历史
|
||||
if self._clear:
|
||||
@@ -164,6 +166,11 @@ class DockerManager(_PluginBase):
|
||||
"result": 'success' if state else 'fail',
|
||||
"time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
|
||||
})
|
||||
|
||||
thirty_days_ago = time.time() - int(self._history_days) * 24 * 60 * 60
|
||||
history = [record for record in history if
|
||||
datetime.strptime(record["time"],
|
||||
'%Y-%m-%d %H:%M:%S').timestamp() >= thirty_days_ago]
|
||||
# 保存历史
|
||||
self.save_data(key="history", value=history)
|
||||
|
||||
@@ -188,6 +195,7 @@ class DockerManager(_PluginBase):
|
||||
"notify": self._notify,
|
||||
"msgtype": self._msgtype,
|
||||
"time_confs": self._time_confs,
|
||||
"history_days": self._history_days,
|
||||
"clear": self._clear
|
||||
})
|
||||
|
||||
@@ -223,7 +231,7 @@ class DockerManager(_PluginBase):
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 2
|
||||
'md': 3
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
@@ -239,7 +247,7 @@ class DockerManager(_PluginBase):
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 2
|
||||
'md': 3
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
@@ -283,11 +291,16 @@ class DockerManager(_PluginBase):
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 2
|
||||
'md': 6
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
@@ -302,6 +315,22 @@ class DockerManager(_PluginBase):
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 6
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VTextField',
|
||||
'props': {
|
||||
'model': 'history_days',
|
||||
'label': '保留历史天数'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -355,6 +384,7 @@ class DockerManager(_PluginBase):
|
||||
"onlyonce": False,
|
||||
"clear": False,
|
||||
"time_confs": "",
|
||||
"history_days": 30,
|
||||
"msgtype": ""
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class SiteUnreadMsg(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "Synomail_A.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.7"
|
||||
plugin_version = "1.8"
|
||||
# 插件作者
|
||||
plugin_author = "thsrite"
|
||||
# 作者主页
|
||||
@@ -63,6 +63,7 @@ class SiteUnreadMsg(_PluginBase):
|
||||
_cron: str = ""
|
||||
_notify: bool = False
|
||||
_queue_cnt: int = 5
|
||||
_history_days: int = 30
|
||||
_unread_sites: list = []
|
||||
|
||||
def init_plugin(self, config: dict = None):
|
||||
@@ -78,6 +79,7 @@ class SiteUnreadMsg(_PluginBase):
|
||||
self._cron = config.get("cron")
|
||||
self._notify = config.get("notify")
|
||||
self._queue_cnt = config.get("queue_cnt")
|
||||
self._history_days = config.get("history_days") or 30
|
||||
self._unread_sites = config.get("unread_sites") or []
|
||||
|
||||
# 过滤掉已删除的站点
|
||||
@@ -224,7 +226,7 @@ class SiteUnreadMsg(_PluginBase):
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 6
|
||||
'md': 4
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
@@ -241,7 +243,7 @@ class SiteUnreadMsg(_PluginBase):
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 6
|
||||
'md': 4
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
@@ -253,6 +255,22 @@ class SiteUnreadMsg(_PluginBase):
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
'md': 4
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VTextField',
|
||||
'props': {
|
||||
'model': 'history_days',
|
||||
'label': '保留历史天数'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -289,7 +307,7 @@ class SiteUnreadMsg(_PluginBase):
|
||||
'props': {
|
||||
'type': 'info',
|
||||
'variant': 'tonal',
|
||||
'text': '依赖于[站点数据统计]插件。'
|
||||
'text': '依赖于[站点数据统计]插件,解析邮件失败请去[站点数据统计]插件仓库提交issue。'
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -304,6 +322,7 @@ class SiteUnreadMsg(_PluginBase):
|
||||
"notify": True,
|
||||
"cron": "5 1 * * *",
|
||||
"queue_cnt": 5,
|
||||
"history_days": 30,
|
||||
"unread_sites": []
|
||||
}
|
||||
|
||||
@@ -619,6 +638,10 @@ class SiteUnreadMsg(_PluginBase):
|
||||
p.map(self.__refresh_site_data, refresh_sites)
|
||||
|
||||
if self._history:
|
||||
thirty_days_ago = time.time() - int(self._history_days) * 24 * 60 * 60
|
||||
self._history = [record for record in self._history if
|
||||
datetime.strptime(record["time"], '%Y-%m-%d %H:%M:%S').timestamp() >= thirty_days_ago]
|
||||
|
||||
# 保存数据
|
||||
self.save_data("history", self._history)
|
||||
|
||||
@@ -638,6 +661,7 @@ class SiteUnreadMsg(_PluginBase):
|
||||
"cron": self._cron,
|
||||
"notify": self._notify,
|
||||
"queue_cnt": self._queue_cnt,
|
||||
"history_days": self._history_days,
|
||||
"unread_sites": self._unread_sites,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user