fix(file): 修复删除歌曲时的文件名问题并优化歌词显示
- 在删除歌曲时,先尝试停止播放并删除关联的歌词文件 - 优化文件名处理,避免特殊字符导致的文件名错误 - 更新歌词显示逻辑,修复歌词格式问题 - 版本号更新至 4.2.2
This commit is contained in:
27
NFLmusic.py
27
NFLmusic.py
@ -222,6 +222,7 @@ def download_music(song_name, choose):
|
||||
music_url = resp.json()["music_url"]
|
||||
else:
|
||||
lrc = ""
|
||||
lrc = lrc.replace("\\n", "\n")
|
||||
print("请求api:", url)
|
||||
response = requests.get(music_url, stream=True)
|
||||
print("下载直链:", music_url)
|
||||
@ -229,11 +230,12 @@ def download_music(song_name, choose):
|
||||
if formated not in ["m4a", "mp3", "ogg", "flac"]:
|
||||
formated = "mp3"
|
||||
filename_without_endswith = f"{singer} - {music_name}"
|
||||
filename_without_endswith = filename_without_endswith.replace("\\", "#").replace("/", "#")
|
||||
filename_without_endswith = filename_without_endswith.replace(":", "#").replace("*", "#")
|
||||
filename_without_endswith = filename_without_endswith.replace("?", "#").replace("\"", "#")
|
||||
filename_without_endswith = filename_without_endswith.replace("<", "#").replace(">", "#").replace("|", "#")
|
||||
|
||||
filename = f"{filename_without_endswith}.{formated}"
|
||||
filename = filename.replace("\\", "#").replace("/", "#")
|
||||
filename = filename.replace(":", "#").replace("*", "#")
|
||||
filename = filename.replace("?", "#").replace("\"", "#")
|
||||
filename = filename.replace("<", "#").replace(">", "#").replace("|", "#")
|
||||
temp_filename = f"{filename}.crdownload"
|
||||
|
||||
if path == "./music":
|
||||
@ -423,19 +425,30 @@ def delete():
|
||||
file.endswith(('.mp3', '.flac', '.ogg', '.m4a'))]
|
||||
abs_path = path + "/" + music_dir0[listbox1.curselection()[0]]
|
||||
abs_path_lrc = path + "/" + music_dir_without_endswith0[listbox1.curselection()[0]] + ".lrc"
|
||||
music_dir_without_endswith.remove(filtered_list[listbox1.curselection()[0]])
|
||||
os.remove(abs_path)
|
||||
try:
|
||||
os.remove(abs_path_lrc)
|
||||
except:
|
||||
pass
|
||||
music_dir_without_endswith.remove(filtered_list[listbox1.curselection()[0]])
|
||||
music_dir.remove(music_dir[listbox1.curselection()[0]])
|
||||
listbox1.delete(listbox1.curselection()[0])
|
||||
except IndexError:
|
||||
tkinter.messagebox.showwarning(title=lang.get(la, "mbox.title.delete_fail"),
|
||||
message=lang.get(la, "mbox.text.delete_fail_no_target", ))
|
||||
except PermissionError:
|
||||
tkinter.messagebox.showerror(title=lang.get(la, "mbox.title.delete_fail"),
|
||||
try:
|
||||
music_player.stop_music()
|
||||
os.remove(abs_path)
|
||||
try:
|
||||
os.remove(abs_path_lrc)
|
||||
except:
|
||||
pass
|
||||
music_dir_without_endswith.remove(filtered_list[listbox1.curselection()[0]])
|
||||
music_dir.remove(music_dir[listbox1.curselection()[0]])
|
||||
listbox1.delete(listbox1.curselection()[0])
|
||||
except:
|
||||
tkinter.messagebox.showerror(title=lang.get(la, "mbox.title.delete_fail"),
|
||||
message=lang.get(la, "mbox.text.delete_fail_no_permission", ))
|
||||
except FileNotFoundError:
|
||||
tkinter.messagebox.showerror(title=lang.get(la, "mbox.title.delete_fail"),
|
||||
@ -1310,7 +1323,7 @@ def search_local_song():
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
version = "4.2.1"
|
||||
version = "4.2.2"
|
||||
poem = ""
|
||||
appdata = os.getenv("APPDATA")
|
||||
make_resource()
|
||||
|
Reference in New Issue
Block a user