feat CloudDrive2助手 v1.3

增加云盘Cookie失效检测
This commit is contained in:
thsrite
2024-07-01 14:56:16 +08:00
parent 74593c41a8
commit 736bbcecac
3 changed files with 40 additions and 6 deletions

View File

@@ -43,7 +43,7 @@ MoviePilot三方插件市场https://github.com/thsrite/MoviePilot-Plugins/
- Sql执行器 v1.2
- 命令执行器 v1.2
- 云盘助手(docs%2FCloudAssistant.md) v2.0.6
- CloudDrive2助手 v1.2
- CloudDrive2助手 v1.3
- 软连接重定向 v1.0
- 云盘同步删除 v1.3
- 媒体库重复媒体检测 v1.9

View File

@@ -552,11 +552,12 @@
"name": "CloudDrive2助手",
"description": "监控上传任务,检测是否有异常,发送通知。",
"labels": "云盘",
"version": "1.2",
"version": "1.3",
"icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/clouddrive.png",
"author": "thsrite",
"level": 2,
"history": {
"v1.3": "增加云盘Cookie失效检测",
"v1.2": "实时速率显示",
"v1.1": "交互命令重启cd2、获取cd2系统信息支持仪表盘",
"v1.0": "监控上传任务,检测是否有异常,发送通知"

View File

@@ -25,7 +25,7 @@ class Cd2Assistant(_PluginBase):
# 插件图标
plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/clouddrive.png"
# 插件版本
plugin_version = "1.2"
plugin_version = "1.3"
# 插件作者
plugin_author = "thsrite"
# 作者主页
@@ -143,6 +143,39 @@ class Cd2Assistant(_PluginBase):
})
def check(self):
"""
检查
"""
self.__check_cookie()
self.__check_task()
def __check_cookie(self):
"""
检查cookie是否过期
"""
logger.info("开始检查CloudDrive2 cookie")
fs = self._cd2_client.fs
if not fs:
logger.error("CloudDrive2连接失败请检查配置")
return
for f in fs.listdir():
error_msg = None
if f:
try:
cloud_file = fs.listdir(f)
if not cloud_file or len(cloud_file) == 0:
logger.warning(f"云盘 {f} 为空")
error_msg = f"云盘 {f} cookie过期"
except Exception as err:
logger.error(f"云盘 {f} cookie过期{err}")
error_msg = f"云盘 {f} cookie过期"
# 发送通知
if self._notify and error_msg:
self.__send_notify(error_msg)
def __check_task(self):
"""
检查上传任务
"""
@@ -159,7 +192,7 @@ class Cd2Assistant(_PluginBase):
logger.info(f"发现异常上传任务:{task.get('errorMessage')}")
# 发送通知
if self._notify:
self.__send_notify(task)
self.__send_notify(task.get("errorMessage"))
break
@eventmanager.register(EventType.PluginAction)
@@ -253,7 +286,7 @@ class Cd2Assistant(_PluginBase):
# 将匹配到的结果转换为字典
return {key: float(value) for key, value in matches}
def __send_notify(self, task):
def __send_notify(self, msg):
"""
发送通知
"""
@@ -262,7 +295,7 @@ class Cd2Assistant(_PluginBase):
mtype = NotificationType.__getitem__(str(self._msgtype)) or NotificationType.Manual
self.post_message(title="CloudDrive2助手通知",
mtype=mtype,
text=task.get("errorMessage"))
text=msg)
@staticmethod
def convert_seconds(seconds):