修复了歌曲切换部分歌名显示不完全

This commit is contained in:
2025-01-24 20:07:39 +08:00
parent 1927cb22d1
commit e6e2ee0ec6
2 changed files with 10 additions and 9 deletions

View File

@ -851,7 +851,7 @@ def tick():
except ValueError: except ValueError:
current_index = -1 current_index = -1
abs_path = song_list[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 music_playing = abs_path
try: try:
lyric = lyrics.load_lyrics(f"{path}/{music_file_without_endswith}.lrc") 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] 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) random_index = randint(0, len(song_list_full) - 1)
abs_path = song_list_full[random_index] 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) song_list.insert(0, abs_path)
music_playing = abs_path music_playing = abs_path
else: else:
@ -939,7 +939,7 @@ def former_song():
except ValueError: except ValueError:
current_index = -1 current_index = -1
abs_path = song_list[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 music_playing = abs_path
try: try:
lyric = lyrics.load_lyrics(f"{path}/{music_file_without_endswith}.lrc") lyric = lyrics.load_lyrics(f"{path}/{music_file_without_endswith}.lrc")
@ -954,7 +954,7 @@ def former_song():
file.endswith(('.mp3', '.flac', '.ogg', '.m4a'))] file.endswith(('.mp3', '.flac', '.ogg', '.m4a'))]
try: try:
music_file_name = music_dir[music_dir.index(music_playing.split("/")[-1]) - 1] 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 abs_path = path + "/" + music_file_name
music_playing = abs_path music_playing = abs_path
try: try:
@ -963,7 +963,7 @@ def former_song():
lyric = {} lyric = {}
except IndexError: except IndexError:
music_file_name = music_dir[0] 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 music_playing = path + "/" + music_file_name
try: try:
lyric = lyrics.load_lyrics(f"{path}/{music_file_without_endswith}.lrc") 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] 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) random_index = randint(0, len(song_list_full) - 1)
abs_path = song_list_full[random_index] 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) song_list.append(abs_path)
music_playing = abs_path music_playing = abs_path
else: else:
@ -997,7 +997,7 @@ def latter_song():
except ValueError: except ValueError:
current_index = -1 current_index = -1
abs_path = song_list[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 music_playing = abs_path
try: try:
lyric = lyrics.load_lyrics(f"{path}/{music_file_without_endswith}.lrc") lyric = lyrics.load_lyrics(f"{path}/{music_file_without_endswith}.lrc")
@ -1012,7 +1012,7 @@ def latter_song():
file.endswith(('.mp3', '.flac', '.ogg', '.m4a'))] file.endswith(('.mp3', '.flac', '.ogg', '.m4a'))]
try: try:
music_file_name = music_dir[music_dir.index(music_playing.split("/")[-1]) + 1] 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 abs_path = path + "/" + music_file_name
music_playing = abs_path music_playing = abs_path
try: try:
@ -1021,7 +1021,7 @@ def latter_song():
lyric = {} lyric = {}
except IndexError: except IndexError:
music_file_name = music_dir[0] 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 music_playing = path + "/" + music_file_name
try: try:
lyric = lyrics.load_lyrics(f"{path}/{music_file_without_endswith}.lrc") lyric = lyrics.load_lyrics(f"{path}/{music_file_without_endswith}.lrc")

1
tools/test.py Normal file
View File

@ -0,0 +1 @@
"".rsplit()