NeteaseMusicLyricDownloader/modules/multi_download.py

37 lines
1.2 KiB
Python
Raw Normal View History

2022-07-17 18:59:58 +08:00
import re
2022-04-02 22:50:52 +08:00
from modules.clear_screen import clear
2023-04-03 22:29:25 +08:00
from modules.inputs import rinput
2022-04-02 22:50:52 +08:00
from modules.get_song import get_song_lyric
def mdl(path: str):
2022-07-17 18:59:58 +08:00
"""多个歌词文件的下载
``path: str`` 传入歌词文件保存的路径"""
2022-04-02 22:50:52 +08:00
clear()
ids = []
print("输入歌曲id,用回车分开,输入s停止")
while True:
r = rinput()
if r == 's':
break
else:
try:
int(r)
except ValueError:
2022-07-20 13:15:39 +08:00
tmp = re.search(r"song\?id=[0-9]*", r)
2022-07-17 18:59:58 +08:00
if tmp:
r = tmp.group()[8:]
else:
print("不合法的形式.\n")
continue
ids.append(r)
print("\t#%d id:%s - 已添加!" % (len(ids), r))
2022-04-02 22:50:52 +08:00
clear()
for i in range(0, len(ids)):
2023-04-03 22:29:25 +08:00
print("进度: %d/%d" % (i+1, len(ids)))
r = get_song_lyric(ids[i], path)
if r == "dl_err_connection":
2022-04-02 22:50:52 +08:00
input("下载发生错误!可能是连接被拒绝!请检查网络后再试\n按回车键继续任务(该任务会被跳过)...")
input("按回车键返回...")