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