From b4b8ac41f108fc3e6e68caf3e8ab268107ba30bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=89=E9=BB=98=E3=81=AE=E9=87=91?= <110812055+chenmozhijin@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:00:14 +0800 Subject: [PATCH] refactor: Optimize code --- LDDC/backend/song_info.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/LDDC/backend/song_info.py b/LDDC/backend/song_info.py index 1a32b4b..c13b3a9 100644 --- a/LDDC/backend/song_info.py +++ b/LDDC/backend/song_info.py @@ -274,10 +274,10 @@ def parse_cue(data: str, file_dir: str, file_path: str | None = None) -> tuple[l if not os.path.isfile(audio_file_path): for file_extension in audio_formats: if file_path and ( - (audio_file_path := os.path.join(os.path.dirname(file_path), os.path.splitext(file["filename"])[0] + "." + file_extension)) - and os.path.isfile(audio_file_path) or - (audio_file_path := os.path.splitext(file_path)[0] + "." + file_extension) - and os.path.isfile(audio_file_path)): + ((audio_file_path := os.path.join(os.path.dirname(file_path), os.path.splitext(file["filename"])[0] + "." + file_extension)) + and os.path.isfile(audio_file_path)) or + ((audio_file_path := os.path.splitext(file_path)[0] + "." + file_extension) + and os.path.isfile(audio_file_path))): break else: logger.warning("未找到音频文件: %s", file["filename"])