Settings: Filename Format Set
and small changes to follow PEP8 code style change default README to Chinese
This commit is contained in:
@@ -59,11 +59,16 @@ def get_song_info_raw(types: list, identify: str, bar: CompactBar = None):
|
||||
return need
|
||||
|
||||
|
||||
def get_song_lyric(identify: str | int | dict, path: str, allinfo: bool = False, bar: CompactBar = None):
|
||||
def get_song_lyric(identify: str | int | dict,
|
||||
path: str,
|
||||
lyric_format="%(name)s - %(artists)s",
|
||||
allinfo: bool = False,
|
||||
bar: CompactBar = None):
|
||||
"""获取歌词
|
||||
|
||||
``identify`` 提供一个歌曲id
|
||||
``path`` 提供歌曲下载的路径
|
||||
``lyric_format`` 提供歌词保存的格式
|
||||
``allinfo`` 若此项为 True ,则提供的identify格式必须为存储在网易云下载文件中meta_data的格式
|
||||
``bar`` 若获取歌词时下方有进度条, 则应当传入此参数"""
|
||||
if allinfo:
|
||||
@@ -96,7 +101,7 @@ def get_song_lyric(identify: str | int | dict, path: str, allinfo: bool = False,
|
||||
artists = regular_filename(artists)
|
||||
|
||||
bprint(Fore.YELLOW + "\t-> 歌曲:" + Style.RESET_ALL + f"{name} - {artists}", bar)
|
||||
filename = f"{name} - {artists}.lrc"
|
||||
filename = f"{lyric_format % {'name': name, 'artists': artists}}.lrc"
|
||||
|
||||
try:
|
||||
info = post(f"https://music.163.com/api/song/media?id={identify}").json()
|
||||
|
@@ -217,7 +217,7 @@ def get_lyric_from_folder(self):
|
||||
with CompactArrowBar(f"进度: %(index){len(str(len(musics)))}d/%(max)d",
|
||||
suffix="", max=len(musics), color="yellow", width=9999) as bar:
|
||||
for i in range(0, len(musics)): # 根据索引结果获取歌词
|
||||
if get_song_lyric(musics[i], lyric_path, allinfo=True, bar=bar) == "dl_err_connection":
|
||||
if get_song_lyric(musics[i], lyric_path, self.settings.lyric_format, True, bar) == "dl_err_connection":
|
||||
bar.print_onto_bar(Fore.RED + "下载发生错误!可能是连接被拒绝!请检查网络后再试\n按回车键继续任务(该任务会被跳过)...")
|
||||
input()
|
||||
bar.next()
|
||||
|
@@ -34,7 +34,7 @@ def mdl(self):
|
||||
with CompactArrowBar(f"进度: %(index){len(str(len(ids)))}d/%(max)d",
|
||||
suffix="", max=len(ids), color="yellow", width=9999) as bar:
|
||||
for i in range(0, len(ids)):
|
||||
r = get_song_lyric(ids[i], self.settings.lyric_path, bar=bar)
|
||||
r = get_song_lyric(ids[i], self.settings.lyric_path, self.settings.lyric_path, bar=bar)
|
||||
if r == "dl_err_connection":
|
||||
bar.print_onto_bar(Fore.RED + "下载发生错误!可能是连接被拒绝!请检查网络后再试\n按回车键继续任务(该任务会被跳过)...")
|
||||
input()
|
||||
|
Reference in New Issue
Block a user