diff --git a/README.md b/README.md index ce1422a..3d0180d 100644 --- a/README.md +++ b/README.md @@ -45,4 +45,4 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/ - 云盘助手(docs%2FCloudAssistant.md) v2.0.3 - CloudDrive2助手 v1.2 - 软连接重定向 v1.0 -- 云盘同步删除 v1.1 \ No newline at end of file +- 云盘同步删除 v1.2 \ No newline at end of file diff --git a/package.json b/package.json index 489353e..b55d793 100644 --- a/package.json +++ b/package.json @@ -573,11 +573,12 @@ "name": "云盘同步删除", "description": "媒体库删除软连接文件后,同步删除云盘文件。", "labels": "云盘", - "version": "1.0", + "version": "1.2", "icon": "clouddisk.png", "author": "thsrite", "level": 2, "history": { + "v1.2": "修复删除bug", "v1.1": "增加测试模式按钮(不删除文件)", "v1.0": "媒体库删除软连接文件后,同步删除云盘文件" } diff --git a/plugins/cloudsyncdel/__init__.py b/plugins/cloudsyncdel/__init__.py index 51fe64e..8e928dd 100644 --- a/plugins/cloudsyncdel/__init__.py +++ b/plugins/cloudsyncdel/__init__.py @@ -1,3 +1,4 @@ +import os import shutil import time from pathlib import Path @@ -21,7 +22,7 @@ class CloudSyncDel(_PluginBase): # 插件图标 plugin_icon = "clouddisk.png" # 插件版本 - plugin_version = "1.1" + plugin_version = "1.2" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -39,7 +40,6 @@ class CloudSyncDel(_PluginBase): _paths = {} _cloud_paths = {} _notify = False - _test = False _del_history = False _video_formats = ('.mp4', '.avi', '.rmvb', '.wmv', '.mov', '.mkv', '.flv', '.ts', '.webm', '.iso', '.mpg') @@ -48,7 +48,6 @@ class CloudSyncDel(_PluginBase): if config: self._enabled = config.get("enabled") self._notify = config.get("notify") - self._test = config.get("test") or True self._del_history = config.get("del_history") if config.get("path"): for path in str(config.get("path")).split("\n"): @@ -110,8 +109,7 @@ class CloudSyncDel(_PluginBase): logger.info(f"开始筛选 {cloud_file_path.parent} 下同名文件 {pattern}") files = cloud_file_path.parent.glob(f"{pattern}.*") for file in files: - if not self._test: - Path(file).unlink() + Path(file).unlink() logger.info(f"云盘文件 {file} 已删除") cloud_file_flag = True @@ -124,15 +122,13 @@ class CloudSyncDel(_PluginBase): # 父目录非根目录,才删除父目录 if not SystemUtils.exits_files(parent_path, settings.RMT_MEDIAEXT): # 当前路径下没有媒体文件则删除 - if not self._test: - shutil.rmtree(parent_path) - logger.warn(f"云盘{type}目录 {parent_path} 已删除") + shutil.rmtree(parent_path) + logger.warn(f"云盘目录 {parent_path} 已删除") else: # 删除云盘文件 cloud_path = self.__get_path(self._cloud_paths, str(media_path)) if Path(cloud_path).exists(): - if not self._test: - shutil.rmtree(cloud_path) + shutil.rmtree(cloud_path) logger.warn(f"云盘目录 {cloud_path} 已删除") cloud_file_flag = True @@ -268,7 +264,7 @@ class CloudSyncDel(_PluginBase): 'component': 'VCol', 'props': { 'cols': 12, - 'md': 3 + 'md': 4 }, 'content': [ { @@ -284,7 +280,7 @@ class CloudSyncDel(_PluginBase): 'component': 'VCol', 'props': { 'cols': 12, - 'md': 3 + 'md': 4 }, 'content': [ { @@ -300,24 +296,7 @@ class CloudSyncDel(_PluginBase): 'component': 'VCol', 'props': { 'cols': 12, - 'md': 3 - }, - 'content': [ - { - 'component': 'VSwitch', - 'props': { - 'model': 'test', - 'label': '测试模式', - 'placeholder': '测试模式下不会真正删除文件,仅仅模拟删除操作' - } - } - ] - }, - { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'md': 3 + 'md': 4 }, 'content': [ { @@ -405,7 +384,6 @@ class CloudSyncDel(_PluginBase): "enabled": False, "path": "", "notify": False, - "test": True, "del_history": False }