From 57af1f79b7f75f1dbfed7ede5b62523c650719e4 Mon Sep 17 00:00:00 2001 From: thsrite Date: Sat, 6 Jul 2024 18:49:44 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=A2=9E=E5=BC=BA=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- package.json | 3 ++- plugins/filesoftlink/__init__.py | 36 ++++++++++++++++++++------------ 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 8ce4689..deefd44 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/ - [自定义命令 v1.7](docs%2FCustomCommand.md) - docker自定义任务 v1.3 - 插件彻底卸载 v1.0 -- 实时软连接 v1.9 +- 实时软连接 v1.9.1 - 订阅规则自动填充 v2.7 - Emby元数据刷新 v1.3 - Emby媒体标签 v1.2 diff --git a/package.json b/package.json index b479193..6c6cf43 100644 --- a/package.json +++ b/package.json @@ -384,11 +384,12 @@ "name": "实时软连接", "description": "监控目录文件变化,媒体文件软连接,其他文件可选复制。", "labels": "文件管理", - "version": "1.9", + "version": "1.9.1", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/softlink.png", "author": "thsrite", "level": 1, "history": { + "v1.9.1": "增强交互命令", "v1.9": "交互命令定向软连接", "v1.8": "修复bug", "v1.6": "bug修复", diff --git a/plugins/filesoftlink/__init__.py b/plugins/filesoftlink/__init__.py index 32e72e0..a5a2da5 100644 --- a/plugins/filesoftlink/__init__.py +++ b/plugins/filesoftlink/__init__.py @@ -52,7 +52,7 @@ class FileSoftLink(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/softlink.png" # 插件版本 - plugin_version = "1.9" + plugin_version = "1.9.1" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -251,24 +251,34 @@ class FileSoftLink(_PluginBase): if not args: return + # 使用正则表达式匹配 + match = re.match(r'(.*?)\s+(.*)', args) + if match: + parent_dir = match.group(1) # 国漫 + args = match.group(2) # 凡人修仙传 (2020) + else: + parent_dir = args + # 定向处理文件夹 # 遍历所有监控目录 for mon_path in self._dirconf.keys(): for root, dirs, files in os.walk(mon_path): for dir_name in dirs: src_path = os.path.join(root, dir_name) - src_name = Path(src_path).name - if str(src_name) == str(args): - logger.info(f"开始定向处理文件夹 ...{src_path}") - for sroot, sdirs, sfiles in os.walk(src_path): - for file_name in sdirs + sfiles: - src_file = os.path.join(sroot, file_name) - if Path(src_file).is_file(): - self.__handle_file(event_path=str(src_file), mon_path=mon_path) - if event: - self.post_message(channel=event.event_data.get("channel"), - title=f"{args} 软连接完成!", userid=event.event_data.get("user")) - return + # 定向上级文件夹 + if str(parent_dir) in str(src_path): + src_name = Path(src_path).name + if str(src_name) == str(args): + logger.info(f"开始定向处理文件夹 ...{src_path}") + for sroot, sdirs, sfiles in os.walk(src_path): + for file_name in sdirs + sfiles: + src_file = os.path.join(sroot, file_name) + if Path(src_file).is_file(): + self.__handle_file(event_path=str(src_file), mon_path=mon_path) + if event: + self.post_message(channel=event.event_data.get("channel"), + title=f"{args} 软连接完成!", userid=event.event_data.get("user")) + return def sync_all(self): """