modify scripts

This commit is contained in:
2025-12-29 16:56:16 +08:00
parent 39c5c6d526
commit 4e1a7835dd

View File

@ -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