增加了保存歌词时不保存歌词时间的设定,增加了自动初始化文件夹的功能,修复了设置歌词文件名格式不生效的bug
This commit is contained in:
parent
c10bd094da
commit
9078104529
BIN
modules/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/functions/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/functions/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/functions/mainly/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/functions/mainly/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/functions/mainly/__pycache__/get_song.cpython-311.pyc
Normal file
BIN
modules/functions/mainly/__pycache__/get_song.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -30,7 +30,7 @@ def wait_retry(kind, identify, bar=None):
|
||||
|
||||
def get_song_info_raw(types: list, identify: str, bar: CompactBar = None):
|
||||
"""获取歌曲信息
|
||||
|
||||
|
||||
``types`` 提供一个list,将会返回内部所有符合要求的信息类型\n
|
||||
``identify`` 提供一个歌曲id(str),将会把歌曲的`types`信息返回"""
|
||||
bprint(Fore.CYAN + "ID:%s" % identify, bar)
|
||||
@ -63,9 +63,10 @@ def get_song_lyric(identify: str | int | dict,
|
||||
path: str,
|
||||
lyric_format="%(name)s - %(artists)s",
|
||||
allinfo: bool = False,
|
||||
bar: CompactBar = None):
|
||||
bar: CompactBar = None,
|
||||
save_lyrics_time: bool = True):
|
||||
"""获取歌词
|
||||
|
||||
|
||||
``identify`` 提供一个歌曲id
|
||||
``path`` 提供歌曲下载的路径
|
||||
``lyric_format`` 提供歌词保存的格式
|
||||
@ -122,6 +123,12 @@ def get_song_lyric(identify: str | int | dict,
|
||||
return
|
||||
else:
|
||||
with open(os.path.join(path, filename), "w", encoding="utf-8") as f:
|
||||
f.write(info["lyric"])
|
||||
bprint(Fore.GREEN + "\t--> 歌词下载完成!被保存在" + Style.RESET_ALL + f"{os.path.join(path, filename)}\n", bar)
|
||||
if not save_lyrics_time:
|
||||
for lyric in info["lyric"].split("\n"):
|
||||
print(lyric)
|
||||
f.write("".join(lyric.split("]")[1:]))
|
||||
f.write('\n')
|
||||
else:
|
||||
f.write(info["lyric"])
|
||||
bprint(Fore.GREEN + "\t--> 歌词下载完成!文件被保存在" + Style.RESET_ALL + f"{os.path.join(path, filename)}\n", bar)
|
||||
return
|
||||
|
@ -23,6 +23,6 @@ def download_one_lyric(self):
|
||||
input("不合法的形式.\n按回车键返回...")
|
||||
return
|
||||
|
||||
if get_song_lyric(int(song_id), self.settings.lyric_path) == "dl_err_connection":
|
||||
if get_song_lyric(int(song_id), self.settings.lyric_path, self.settings.lyric_format, save_lyrics_time = self.settings.save_lyrics_time) == "dl_err_connection":
|
||||
input("下载发生错误!可能是连接被拒绝!请检查网络后再试\n按回车键返回...")
|
||||
input("按回车键返回...")
|
||||
|
BIN
modules/functions/settings/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/functions/settings/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
@ -5,11 +5,12 @@ import os
|
||||
|
||||
|
||||
class Settings(object): # 设定一个基础的存储设置信息的 class ,并设置形参用于 json 导入设置
|
||||
def __init__(self, l_p="./out/", l_f="%(name)s - %(artists)s", lang="en", a_s=True):
|
||||
def __init__(self, l_p="./out/", l_f="%(name)s - %(artists)s", lang="en", a_s=True, s_l_t = True):
|
||||
self.lyric_path = l_p
|
||||
self.lyric_format = l_f
|
||||
self.language = lang
|
||||
self.auto_save = a_s
|
||||
self.save_lyrics_time = s_l_t
|
||||
|
||||
|
||||
def class2dict(aclass: Settings): # 让 json.dumps 将 class 转化为一个 dict ,用于保存
|
||||
@ -17,7 +18,8 @@ def class2dict(aclass: Settings): # 让 json.dumps 将 class 转化为一个 di
|
||||
"lyric_path": aclass.lyric_path,
|
||||
"lyric_format": aclass.lyric_format,
|
||||
"language": aclass.language,
|
||||
"auto_save": aclass.auto_save
|
||||
"auto_save": aclass.auto_save,
|
||||
"save_lyrics_time": aclass.save_lyrics_time
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +31,8 @@ def dict2class(adict): # 让 json.load 将读取到的 dict 转化为我们所
|
||||
l_p=adict["lyric_path"],
|
||||
l_f=adict["lyric_format"],
|
||||
lang=adict["language"],
|
||||
a_s=adict["auto_save"]
|
||||
a_s=adict["auto_save"],
|
||||
s_l_t=adict["save_lyrics_time"]
|
||||
)
|
||||
|
||||
|
||||
|
BIN
modules/submenus/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/submenus/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/submenus/__pycache__/settings.cpython-311.pyc
Normal file
BIN
modules/submenus/__pycache__/settings.cpython-311.pyc
Normal file
Binary file not shown.
@ -15,29 +15,36 @@ def settings_menu(self):
|
||||
save_settings(self.settings)
|
||||
cls_stay(self, f"[设置菜单] "
|
||||
f"{Fore.LIGHTCYAN_EX}自动保存: "
|
||||
f"{({True: f'{Fore.GREEN}开', False: f'{Fore.RED}关'}[self.settings.auto_save])}")
|
||||
f"{({True: f'{Fore.GREEN}开', False: f'{Fore.RED}关'}[self.settings.auto_save])} \t"
|
||||
f"{Fore.LIGHTCYAN_EX}保存每句歌词的时间: "
|
||||
f"{({True: f'{Fore.GREEN}开', False: f'{Fore.RED}关'}[self.settings.save_lyrics_time])}"
|
||||
)
|
||||
r = input_menu({
|
||||
"0": "返回上级菜单",
|
||||
"1": "歌曲保存路径",
|
||||
"2": "清空输出文件夹内的内容",
|
||||
"3": "歌词文件保存格式",
|
||||
"3": "歌词文件名保存格式",
|
||||
"4": "部分动态效果",
|
||||
"s": "切换设置自动保存"
|
||||
"5": "切换是否保存每句歌词的时间",
|
||||
"s": "切换设置是否自动保存",
|
||||
})
|
||||
if r == "0":
|
||||
return
|
||||
elif r == "1":
|
||||
__set_lyric_path(self)
|
||||
elif r == "2":
|
||||
__remove_output_files(self)
|
||||
elif r == "3":
|
||||
__set_lyric_format(self)
|
||||
elif r == "4":
|
||||
pass
|
||||
elif r == "s":
|
||||
self.settings.auto_save = not self.settings.auto_save
|
||||
else:
|
||||
input("输入无效!按回车键继续...")
|
||||
match r:
|
||||
case "0":
|
||||
return
|
||||
case "1":
|
||||
__set_lyric_path(self)
|
||||
case "2":
|
||||
__remove_output_files(self)
|
||||
case "3":
|
||||
__set_lyric_filename_format(self)
|
||||
case "4":
|
||||
pass
|
||||
case "5":
|
||||
self.settings.save_lyrics_time = not self.settings.save_lyrics_time
|
||||
case "s":
|
||||
self.settings.auto_save = not self.settings.auto_save
|
||||
case _:
|
||||
input("输入无效!按回车键继续...")
|
||||
|
||||
|
||||
def __remove_output_files(self):
|
||||
@ -112,7 +119,7 @@ def __set_lyric_path(self):
|
||||
return
|
||||
|
||||
|
||||
def __set_lyric_format(self):
|
||||
def __set_lyric_filename_format(self):
|
||||
while True:
|
||||
cls_stay(self, f"[设置菜单 - 文件名格式]\n{Fore.LIGHTCYAN_EX}当前格式: ", end="")
|
||||
if self.settings.lyric_format == "%(name)s":
|
||||
|
BIN
modules/utils/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
modules/utils/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/utils/__pycache__/bar.cpython-311.pyc
Normal file
BIN
modules/utils/__pycache__/bar.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/utils/__pycache__/clear_screen.cpython-311.pyc
Normal file
BIN
modules/utils/__pycache__/clear_screen.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/utils/__pycache__/dump.cpython-311.pyc
Normal file
BIN
modules/utils/__pycache__/dump.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/utils/__pycache__/inputs.cpython-311.pyc
Normal file
BIN
modules/utils/__pycache__/inputs.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/utils/__pycache__/length.cpython-311.pyc
Normal file
BIN
modules/utils/__pycache__/length.cpython-311.pyc
Normal file
Binary file not shown.
BIN
modules/utils/__pycache__/prints.cpython-311.pyc
Normal file
BIN
modules/utils/__pycache__/prints.cpython-311.pyc
Normal file
Binary file not shown.
11
modules/utils/initapp.py
Normal file
11
modules/utils/initapp.py
Normal file
@ -0,0 +1,11 @@
|
||||
from os import mkdir
|
||||
from os.path import exists
|
||||
|
||||
INIT_DIRECTORIES = [
|
||||
'out'
|
||||
]
|
||||
|
||||
def init_directories():
|
||||
for dir_name in INIT_DIRECTORIES:
|
||||
if not exists(dir_name):
|
||||
mkdir(dir_name)
|
Loading…
Reference in New Issue
Block a user