From 9843e561c15fc9c03728a2359e508e1d5fde1bab Mon Sep 17 00:00:00 2001 From: thsrite Date: Thu, 4 Jan 2024 09:54:19 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=AA=92=E4=BD=93=E9=87=8D=E5=91=BD?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/shortplaymonitor/__init__.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/shortplaymonitor/__init__.py b/plugins/shortplaymonitor/__init__.py index befbce7..3ebed1a 100644 --- a/plugins/shortplaymonitor/__init__.py +++ b/plugins/shortplaymonitor/__init__.py @@ -234,7 +234,7 @@ class ShortPlayMonitor(_PluginBase): target_path = event_path.replace(source_dir, dest_dir) - # 硬链接 + # 目录重命名 if isinstance(rename_conf, bool): target = target_path.replace(dest_dir, "") parent = Path(Path(target).parents[0]) @@ -264,6 +264,21 @@ class ShortPlayMonitor(_PluginBase): logger.info(f"创建目标文件夹 {target_path}") os.makedirs(target_path) else: + # 媒体重命名 + try: + pattern = r'S(\d{2})E(\d{2})' + matches = re.search(pattern, Path(target_path).name) + + if matches: + season = matches.group(1) # 提取S后面的数字作为季数 + episode = matches.group(2) # 提取E后面的数字作为集数 + target_path = Path( + target_path).parent / f"S{season}E{episode}{Path(Path(target_path).name).suffix}" + else: + print("未找到匹配的季数和集数") + except Exception as e: + print(e) + # 目标文件夹不存在则创建 if not Path(target_path).parent.exists(): logger.info(f"创建目标文件夹 {Path(target_path).parent}")