806e6e6ea4
增加了根据歌单下载的功能,修复了多个音乐一块下载时文件名格式无效的问题,优化代码
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
import re
|
|
from modules.utils.inputs import rinput
|
|
from modules.functions.mainly.get_playlist import getplaylist
|
|
from modules.utils.clear_screen import clear
|
|
from modules.functions.mainly.download_multiple_songs import donload_multiple_songs
|
|
from os.path import sep
|
|
from modules.utils.initapp import mkdir
|
|
|
|
def download_by_playlist(self) -> None:
|
|
"""
|
|
按照歌单id获取歌词
|
|
|
|
:params: path: str 存储歌词的路径
|
|
|
|
:return: None
|
|
|
|
"""
|
|
clear()
|
|
playlist_id = rinput(
|
|
f"[NeteaseMusicLyricDownloader] {self.version}\n"
|
|
"[手动-歌单下载]\n"
|
|
"请输入歌曲id:")
|
|
try:
|
|
int(playlist_id)
|
|
except ValueError:
|
|
r = re.search("playlist\?id=[0-9]*", playlist_id)
|
|
if r:
|
|
playlist_id = r.group()[12:]
|
|
else:
|
|
input("不合法的形式.\n按回车键返回...")
|
|
return
|
|
|
|
playlist = getplaylist(playlist_id)
|
|
|
|
if not playlist["playlist"]:
|
|
print("改歌单为空集,下载停止!")
|
|
input()
|
|
return
|
|
|
|
if mkdir(self.settings.lyric_path+sep+playlist["name"]):
|
|
print("歌单文件夹已存在")
|
|
|
|
donload_multiple_songs(self, self.settings.lyric_path+sep+playlist["name"], playlist["playlist"])
|
|
input("按回车键返回...")
|
|
|