From e6e2ee0ec6cb45e4401861e2dc8fb43b52be12ba Mon Sep 17 00:00:00 2001 From: NFL_jiancx <1678594309@qq.com> Date: Fri, 24 Jan 2025 20:07:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=AD=8C=E6=9B=B2?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E9=83=A8=E5=88=86=E6=AD=8C=E5=90=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E5=AE=8C=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NFLmusic.py | 18 +++++++++--------- tools/test.py | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 tools/test.py diff --git a/NFLmusic.py b/NFLmusic.py index d4f0b9b..c97669f 100644 --- a/NFLmusic.py +++ b/NFLmusic.py @@ -851,7 +851,7 @@ def tick(): except ValueError: current_index = -1 abs_path = song_list[current_index + 1] - music_file_without_endswith = abs_path.split("/")[-1].split(".")[0] + music_file_without_endswith = abs_path.split("/")[-1].splite(".")[0] music_playing = abs_path try: lyric = lyrics.load_lyrics(f"{path}/{music_file_without_endswith}.lrc") @@ -930,7 +930,7 @@ def former_song(): song_list_full = [song for song in music_dir_with_path if song not in song_list] random_index = randint(0, len(song_list_full) - 1) abs_path = song_list_full[random_index] - music_file_without_endswith = abs_path.split("/")[-1].split(".")[0] + music_file_without_endswith = abs_path.split("/")[-1].rsplit(".", 1)[0] song_list.insert(0, abs_path) music_playing = abs_path else: @@ -939,7 +939,7 @@ def former_song(): except ValueError: current_index = -1 abs_path = song_list[current_index - 1] - music_file_without_endswith = abs_path.split("/")[-1].split(".")[0] + music_file_without_endswith = abs_path.rsplit("/")[-1].split(".", 1)[0] music_playing = abs_path try: lyric = lyrics.load_lyrics(f"{path}/{music_file_without_endswith}.lrc") @@ -954,7 +954,7 @@ def former_song(): file.endswith(('.mp3', '.flac', '.ogg', '.m4a'))] try: music_file_name = music_dir[music_dir.index(music_playing.split("/")[-1]) - 1] - music_file_without_endswith = music_file_name.split("/")[-1].split(".")[0] + music_file_without_endswith = music_file_name.split("/")[-1].rsplit(".", 1)[0] abs_path = path + "/" + music_file_name music_playing = abs_path try: @@ -963,7 +963,7 @@ def former_song(): lyric = {} except IndexError: music_file_name = music_dir[0] - music_file_without_endswith = music_file_name.split("/")[-1].split(".")[0] + music_file_without_endswith = music_file_name.split("/")[-1].rsplit(".", 1)[0] music_playing = path + "/" + music_file_name try: lyric = lyrics.load_lyrics(f"{path}/{music_file_without_endswith}.lrc") @@ -988,7 +988,7 @@ def latter_song(): song_list_full = [song for song in music_dir_with_path if song not in song_list] random_index = randint(0, len(song_list_full) - 1) abs_path = song_list_full[random_index] - music_file_without_endswith = abs_path.split("/")[-1].split(".")[0] + music_file_without_endswith = abs_path.split("/")[-1].rsplit(".", 1)[0] song_list.append(abs_path) music_playing = abs_path else: @@ -997,7 +997,7 @@ def latter_song(): except ValueError: current_index = -1 abs_path = song_list[current_index + 1] - music_file_without_endswith = abs_path.split("/")[-1].split(".")[0] + music_file_without_endswith = abs_path.split("/")[-1].rsplit(".", 1)[0] music_playing = abs_path try: lyric = lyrics.load_lyrics(f"{path}/{music_file_without_endswith}.lrc") @@ -1012,7 +1012,7 @@ def latter_song(): file.endswith(('.mp3', '.flac', '.ogg', '.m4a'))] try: music_file_name = music_dir[music_dir.index(music_playing.split("/")[-1]) + 1] - music_file_without_endswith = music_file_name.split("/")[-1].split(".")[0] + music_file_without_endswith = music_file_name.split("/")[-1].rsplit(".", 1)[0] abs_path = path + "/" + music_file_name music_playing = abs_path try: @@ -1021,7 +1021,7 @@ def latter_song(): lyric = {} except IndexError: music_file_name = music_dir[0] - music_file_without_endswith = music_file_name.split("/")[-1].split(".")[0] + music_file_without_endswith = music_file_name.split("/")[-1].rsplit(".", 1)[0] music_playing = path + "/" + music_file_name try: lyric = lyrics.load_lyrics(f"{path}/{music_file_without_endswith}.lrc") diff --git a/tools/test.py b/tools/test.py new file mode 100644 index 0000000..c6dcba0 --- /dev/null +++ b/tools/test.py @@ -0,0 +1 @@ +"".rsplit() \ No newline at end of file