From e240dca0652ca88e6052ce2ffedcb68d4b9df229 Mon Sep 17 00:00:00 2001 From: thsrite Date: Wed, 14 Aug 2024 10:48:24 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=B7=BB=E5=8A=A0=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=8C=E8=A7=A3=E5=86=B3cd2=E4=B8=8A?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E7=9B=AE=E5=BD=95=E8=8E=B7=E5=8F=96=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E7=A9=BA=E9=97=B4=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- package.json | 3 ++- plugins/cd2assistant/__init__.py | 24 +++++++++++++++--------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4cc51c8..aeb8960 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.8.2](docs%2FCd2Assistant.md) +- [CloudDrive2助手v1.8.3](docs%2FCd2Assistant.md) - 软连接重定向 v1.1 - 云盘同步删除 v1.5.3 - 媒体库重复媒体检测 v1.9 diff --git a/package.json b/package.json index 455a15b..07e594e 100644 --- a/package.json +++ b/package.json @@ -590,11 +590,12 @@ "name": "CloudDrive2助手", "description": "监控上传任务,检测是否有异常,发送通知。", "labels": "云盘", - "version": "1.8.2", + "version": "1.8.3", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/clouddrive.png", "author": "thsrite", "level": 2, "history": { + "v1.8.3": "添加异常处理,解决cd2上本地目录获取存储空间失败的问题", "v1.8.2": "插件页面密码类型设置为pasword", "v1.8.1": "云下载支持自定义路径 /cd /cd2路径 磁链", "v1.8": "修复插件依赖安装问题", diff --git a/plugins/cd2assistant/__init__.py b/plugins/cd2assistant/__init__.py index 5e3451d..b647ff2 100644 --- a/plugins/cd2assistant/__init__.py +++ b/plugins/cd2assistant/__init__.py @@ -2,12 +2,14 @@ import re from datetime import datetime, timedelta import pytz + try: from clouddrive import CloudDriveClient, Client from clouddrive.proto import CloudDrive_pb2 except ImportError: from sys import executable from subprocess import run + run([executable, "-m", "pip", "install", "-U", "clouddrive"], check=True) from app import schemas from app.core.config import settings @@ -30,7 +32,7 @@ class Cd2Assistant(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/clouddrive.png" # 插件版本 - plugin_version = "1.8.2" + plugin_version = "1.8.3" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -234,13 +236,16 @@ class Cd2Assistant(_PluginBase): _space_info = "\n" for f in fs.listdir(): - if f and f not in self._black_dir.split(","): - space_info = self._cd2_client.GetSpaceInfo(CloudDrive_pb2.FileRequest(path=f)) - space_info = self.__str_to_dict(space_info) - total = self.__convert_bytes(space_info.get("totalSpace")) - used = self.__convert_bytes(space_info.get("usedSpace")) - free = self.__convert_bytes(space_info.get("freeSpace")) - _space_info += f"{f}:{used}/{total}\n" + try: + if f and f not in self._black_dir.split(","): + space_info = self._cd2_client.GetSpaceInfo(CloudDrive_pb2.FileRequest(path=f)) + space_info = self.__str_to_dict(space_info) + total = self.__convert_bytes(space_info.get("totalSpace")) + used = self.__convert_bytes(space_info.get("usedSpace")) + free = self.__convert_bytes(space_info.get("freeSpace")) + _space_info += f"{f}:{used}/{total}\n" + except Exception: + logger.error(f"获取云盘 {f} 空间信息失败") return _space_info @@ -675,7 +680,8 @@ class Cd2Assistant(_PluginBase): 'component': 'VTextField', 'props': { 'model': 'black_dir', - 'label': 'cd2黑名单目录' + 'label': 'cd2黑名单目录', + 'placeholder': 'cd2上添加的本地目录' } } ]