diff --git a/README.md b/README.md index cb2e1d6..fe025bc 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/ - 目录监控(统一入库消息增强版) v1.0 - Sql执行器 v1.3 - 命令执行器 v1.2 -- CloudDrive2助手 v1.6 +- [CloudDrive2助手](docs%2FCd2Assistant.md) v1.7 - 软连接重定向 v1.1 - 云盘同步删除 v1.5.1 - 媒体库重复媒体检测 v1.9 diff --git a/docs/Cd2Assistant.md b/docs/Cd2Assistant.md new file mode 100644 index 0000000..6ec965b --- /dev/null +++ b/docs/Cd2Assistant.md @@ -0,0 +1,46 @@ +# CloudDriver HomePage自定义API + +![img.png](../img/HomePage/img.png) + +HomePage services.yaml配置 +```angular2html +- CloudDrive2: + icon: /icons/icon/clouddrive.png + href: http://cd2ip:cd2端口/ + ping: http://cd2ip:cd2端口 + #server: unraid + #container: CloudDrive + showStats: true + display: list + widget: + type: customapi + url: http://mp_ip:mp_port/api/v1/plugin/Cd2Assistant/homepage?apikey=mp_apikey + method: GET + mappings: + # - field: uptime + # label: 运行时间 + - field: upload_count + label: 上传数量 + - field: upload_speed + label: 上传速度 + - field: download_count + label: 下载数量 + - field: download_speed + label: 下载速度 + + # - field: cloud_space + # label: 剩余空间 +``` + +### 自定义API Response字段 +- cpuUsage: CPU使用率 +- memUsageKB: 内存使用量 +- uptime: 运行时间 +- upload_count: 上传数量 +- upload_speed: 上传速度 +- download_count: 下载数量 +- download_speed: 下载速度 +- cloud_space: 剩余空间 + +### HomePage自定义API文档 +https://gethomepage.dev/latest/widgets/services/customapi/#custom-request-body \ No newline at end of file diff --git a/package.json b/package.json index 0cfba3c..4a4f9e1 100644 --- a/package.json +++ b/package.json @@ -587,11 +587,12 @@ "name": "CloudDrive2助手", "description": "监控上传任务,检测是否有异常,发送通知。", "labels": "云盘", - "version": "1.6", + "version": "1.7", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/clouddrive.png", "author": "thsrite", "level": 2, "history": { + "v1.7": "增加HomePage自定义API(详见插件说明)", "v1.6": "支持交互命令云下载", "v1.5": "增加云盘同步黑名单(排序挂载本地目录)", "v1.4": "增加云盘存储空间展示", diff --git a/plugins/cd2assistant/__init__.py b/plugins/cd2assistant/__init__.py index 9a76413..6181965 100644 --- a/plugins/cd2assistant/__init__.py +++ b/plugins/cd2assistant/__init__.py @@ -5,6 +5,7 @@ import pytz from clouddrive import CloudDriveClient, Client from clouddrive.proto import CloudDrive_pb2 +from app import schemas from app.core.config import settings from app.core.event import eventmanager, Event from app.plugins import _PluginBase @@ -25,7 +26,7 @@ class Cd2Assistant(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/clouddrive.png" # 插件版本 - plugin_version = "1.6" + plugin_version = "1.7" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -351,6 +352,15 @@ class Cd2Assistant(_PluginBase): return system_info_dict + def homepage(self, apikey: str) -> Any: + """ + homepage自定义api + """ + if apikey != settings.API_TOKEN: + return schemas.Response(success=False, message="API密钥错误") + + return self.cd2_info() + @staticmethod def __convert_bytes(size_in_bytes): """ Convert bytes to the most appropriate unit (PB, TB, GB, etc.) """ @@ -437,7 +447,13 @@ class Cd2Assistant(_PluginBase): ] def get_api(self) -> List[Dict[str, Any]]: - pass + return [{ + "path": "/homepage", + "endpoint": self.homepage, + "methods": ["GET"], + "summary": "HomePage", + "description": "HomePage自定义api", + }] def get_form(self) -> Tuple[List[dict], Dict[str, Any]]: """ @@ -712,6 +728,61 @@ class Cd2Assistant(_PluginBase): ] } ] + }, + { + 'component': 'VRow', + 'content': [ + { + 'component': 'VCol', + 'props': { + 'cols': 12, + }, + 'content': [ + { + 'component': 'VAlert', + 'props': { + 'type': 'success', + 'variant': 'tonal' + }, + 'content': [ + { + 'component': 'span', + 'text': 'HomePage配置教程请参考:' + }, + { + 'component': 'a', + 'props': { + 'href': 'https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/docs/Cd2Assistant.md', + 'target': '_blank' + }, + 'text': 'https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/docs/Cd2Assistant.md' + } + ] + } + ] + } + ] + }, + { + 'component': 'VRow', + 'content': [ + { + 'component': 'VCol', + 'props': { + 'cols': 12, + }, + 'content': [ + { + 'component': 'VAlert', + 'props': { + 'type': 'info', + 'variant': 'tonal', + 'text': '如安装完启用插件后,HomePage提示404,重启MoviePilot即可。' + } + } + ] + } + ] } ] }