From 4e1a7835dd0b43c142cb09901b4c5ec2729a195b Mon Sep 17 00:00:00 2001 From: sophon Date: Mon, 29 Dec 2025 16:56:16 +0800 Subject: [PATCH] modify scripts --- src/tools/sync_filename.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/tools/sync_filename.py b/src/tools/sync_filename.py index a47edec..ee8a52b 100644 --- a/src/tools/sync_filename.py +++ b/src/tools/sync_filename.py @@ -109,6 +109,17 @@ def sync_whisper_to_stash(whisper_db_path, stash_db_path, dir_prefix, studio_fil matched = False for whisper_code, whisper_row in idx_whisper.items(): if whisper_code and basename and str(whisper_code).lower() in basename.lower(): + # 尝试对 basename 进行截取,从匹配到 whisper_code 的位置开始截取,一直遇到非字母和数字的字符为止 + start_index = basename.lower().find(str(whisper_code).lower()) + end_index = start_index + len(whisper_code) + # 向后扩展,直到遇到非字母数字字符 + while end_index < len(basename) and basename[end_index].isalnum(): + end_index += 1 + extracted_code = basename[start_index:end_index] + if extracted_code.lower() != str(whisper_code).lower(): + # 截取结果与whisper_code不匹配,跳过 + continue + # 找到匹配项,更新stash数据库 matched = True matched_cnt += 1