NeteaseMusicLyricDownloader/modules/functions/mainly/one_download.py

29 lines
895 B
Python
Raw Normal View History

2022-07-17 18:59:58 +08:00
import re
2023-04-04 19:58:02 +08:00
from modules.utils.inputs import rinput
from modules.functions.mainly.get_song import get_song_lyric
2023-04-04 19:58:02 +08:00
from modules.utils.clear_screen import clear
2022-04-02 22:50:52 +08:00
2023-04-04 19:58:02 +08:00
def download_one_lyric(self):
2022-04-02 22:50:52 +08:00
"""单次下载歌词
``path: str`` 存储歌词的路径"""
clear()
2023-04-04 19:58:02 +08:00
song_id = rinput(
f"[NeteaseMusicLyricDownloader] {self.version}\n"
"[手动-单个下载]\n"
"请输入歌曲id:")
2022-04-02 22:50:52 +08:00
try:
int(song_id)
except ValueError:
2022-07-17 18:59:58 +08:00
r = re.search("song\?id=[0-9]*", song_id)
if r:
song_id = r.group()[8:]
else:
input("不合法的形式.\n按回车键返回...")
return
if get_song_lyric(int(song_id), self.settings.lyric_path) == "dl_err_connection":
2022-07-17 18:59:58 +08:00
input("下载发生错误!可能是连接被拒绝!请检查网络后再试\n按回车键返回...")
input("按回车键返回...")