From 43d657dd6fd0dea6256f7cd958384e09c1e56042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Fri, 17 Jan 2025 20:01:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=AD=8C=E5=8D=95=E9=87=8D=E5=91=BD=E5=90=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_remove_common_prefix.py | 4 ++-- xiaomusic/utils.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_remove_common_prefix.py b/test/test_remove_common_prefix.py index c956d9d..da15803 100644 --- a/test/test_remove_common_prefix.py +++ b/test/test_remove_common_prefix.py @@ -2,7 +2,7 @@ import re def removepre(filename): - match = re.search(r"^(\d+)\s+\d*(.+?)\.(.*$)", filename.strip()) + match = re.search(r"^[pP]?(\d+)\s+\d*(.+?)\.(.*$)", filename.strip()) new_filename = filename if match: num = match.group(1) @@ -26,4 +26,4 @@ if __name__ == "__main__": removepre(" 18 色风车.mp3") removepre(" 18 18 你好.mp3") removepre(" 18 18 我好.mp3") - removepre("09 009. 梁静茹-亲亲.mp3") + removepre("p09 009. 梁静茹-亲亲.mp3") diff --git a/xiaomusic/utils.py b/xiaomusic/utils.py index bc3c503..5778cac 100644 --- a/xiaomusic/utils.py +++ b/xiaomusic/utils.py @@ -983,7 +983,7 @@ def remove_common_prefix(directory): log.info(f'Common prefix identified: "{common_prefix}"') - pattern = re.compile(r"^(\d+)\s+\d*(.+?)\.(.*$)") + pattern = re.compile(r"^[pP]?(\d+)\s+\d*(.+?)\.(.*$)") for filename in files: if filename == common_prefix: continue