feat(NFLmusic): 添加多个音乐平台支持
- 新增 QQ音乐、酷狗音乐、汽水音乐、小粉音乐平台支持 - 优化音乐搜索和播放功能,适配不同平台的 API - 增加歌词获取功能,支持多个平台的歌词格式 - 调整音乐列表显示,适应不同平台的数据结构
This commit is contained in:
94
NFLmusic.py
94
NFLmusic.py
@ -163,9 +163,9 @@ def download_music(song_name, choose):
|
|||||||
singer = resp.json()["song_singer"]
|
singer = resp.json()["song_singer"]
|
||||||
music_url = resp.json()["flac_url"]
|
music_url = resp.json()["flac_url"]
|
||||||
elif choice == "WANGYIYUN":
|
elif choice == "WANGYIYUN":
|
||||||
resp = requests.get(f"{url}/?name={song_name}&n={choose}&br={br}&limit=60")
|
resp = requests.get(f"{url}?gm={song_name}&n={choose}&br={br}&num=60&type=json")
|
||||||
resp.close()
|
resp.close()
|
||||||
id = resp.json()["data"]["id"]
|
id = resp.json()["link"].rsplit("=", 1)[1]
|
||||||
try:
|
try:
|
||||||
resp_lrc = requests.get(f"https://music.163.com/api/song/lyric?id={id}&lv=-1&kv=-1&tv=-1")
|
resp_lrc = requests.get(f"https://music.163.com/api/song/lyric?id={id}&lv=-1&kv=-1&tv=-1")
|
||||||
resp_lrc.close()
|
resp_lrc.close()
|
||||||
@ -173,13 +173,61 @@ def download_music(song_name, choose):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"download_wyy_lrc: {e}")
|
print(f"download_wyy_lrc: {e}")
|
||||||
lrc = ""
|
lrc = ""
|
||||||
music_name = resp.json()["data"]["name"]
|
music_name = resp.json()["title"]
|
||||||
singer = resp.json()["data"]["singers"][0]["name"]
|
singer = resp.json()["singer"]
|
||||||
|
music_url = resp.json()["music_url"]
|
||||||
|
elif choice == "QQ":
|
||||||
|
resp = requests.get(f"{url}?msg={song_name}&n={choose}&num=60&type=json")
|
||||||
|
resp.close()
|
||||||
|
try:
|
||||||
|
lrc = resp.json()["data"]["lyric"]
|
||||||
|
except Exception as e:
|
||||||
|
print(f"download_qq_lrc: {e}")
|
||||||
|
lrc = ""
|
||||||
|
music_name = resp.json()["data"]["title"]
|
||||||
|
singer = resp.json()["data"]["singer"]
|
||||||
|
music_url = resp.json()["data"]["music_url"]
|
||||||
|
elif choice == "KUGOU":
|
||||||
|
resp = requests.get(f"{url}?gm={song_name}&n={choose}&num=60&type=json")
|
||||||
|
resp.close()
|
||||||
|
try:
|
||||||
|
lrc = resp.json()["lyrics"]
|
||||||
|
except Exception as e:
|
||||||
|
print(f"download_kugou_lrc: {e}")
|
||||||
|
lrc = ""
|
||||||
|
music_name = resp.json()["title"]
|
||||||
|
singer = resp.json()["singer"]
|
||||||
|
music_url = resp.json()["music_url"]
|
||||||
|
elif choice == "DOUYIN":
|
||||||
|
resp = requests.get(f"{url}?msg={song_name}&n={choose}&num=50&type=json")
|
||||||
|
resp.close()
|
||||||
|
try:
|
||||||
|
lrc = resp.json()["data"]["lrc"]
|
||||||
|
except Exception as e:
|
||||||
|
print(f"download_qishui_lrc: {e}")
|
||||||
|
lrc = ""
|
||||||
|
music_name = resp.json()["data"]["title"]
|
||||||
|
singer = resp.json()["data"]["singer"]
|
||||||
music_url = resp.json()["data"]["url"]
|
music_url = resp.json()["data"]["url"]
|
||||||
|
elif choice == "XIAOFEN":
|
||||||
|
resp = requests.get(f"{url}?msg={song_name}&n={choose}&num=60&type=json")
|
||||||
|
resp.close()
|
||||||
|
try:
|
||||||
|
lrc = resp.json()["lrc"]
|
||||||
|
except Exception as e:
|
||||||
|
print(f"download_xiaofen_lrc: {e}")
|
||||||
|
lrc = ""
|
||||||
|
music_name = resp.json()["title"]
|
||||||
|
singer = resp.json()["singer"]
|
||||||
|
music_url = resp.json()["music_url"]
|
||||||
else:
|
else:
|
||||||
lrc = ""
|
lrc = ""
|
||||||
|
print("请求api:", url)
|
||||||
response = requests.get(music_url, stream=True)
|
response = requests.get(music_url, stream=True)
|
||||||
|
print("下载直链:", music_url)
|
||||||
formated = music_url.split("?")[0].rsplit(".", 1)[1]
|
formated = music_url.split("?")[0].rsplit(".", 1)[1]
|
||||||
|
if formated not in ["m4a", "mp3", "ogg", "flac"]:
|
||||||
|
formated = "mp3"
|
||||||
filename_without_endswith = f"{singer} - {music_name}"
|
filename_without_endswith = f"{singer} - {music_name}"
|
||||||
filename = f"{filename_without_endswith}.{formated}"
|
filename = f"{filename_without_endswith}.{formated}"
|
||||||
filename = filename.replace("\\", "#").replace("/", "#")
|
filename = filename.replace("\\", "#").replace("/", "#")
|
||||||
@ -278,8 +326,16 @@ def get_data_without_blocking(song_name):
|
|||||||
songlist.delete(*songlist.get_children())
|
songlist.delete(*songlist.get_children())
|
||||||
if choice == "KUWO":
|
if choice == "KUWO":
|
||||||
url1 = f"{url}?msg={song_name}&num=60&type=json"
|
url1 = f"{url}?msg={song_name}&num=60&type=json"
|
||||||
else:
|
elif choice == "WANGYIYUN":
|
||||||
url1 = f"{url}/?name={song_name}&limit=60"
|
url1 = f"{url}?gm={song_name}&num=60&type=json"
|
||||||
|
elif choice == "QQ":
|
||||||
|
url1 = f"{url}?msg={song_name}&num=60&type=json"
|
||||||
|
elif choice == "KUGOU":
|
||||||
|
url1 = f"{url}?gm={song_name}&num=60&type=json"
|
||||||
|
elif choice == "DOUYIN":
|
||||||
|
url1 = f"{url}?msg={song_name}&num=50&type=json"
|
||||||
|
elif choice == "XIAOFEN":
|
||||||
|
url1 = f"{url}?msg={song_name}&num=60&type=json"
|
||||||
resp = requests.get(url1)
|
resp = requests.get(url1)
|
||||||
jsondata = resp.json()["data"]
|
jsondata = resp.json()["data"]
|
||||||
resp.close()
|
resp.close()
|
||||||
@ -290,8 +346,24 @@ def get_data_without_blocking(song_name):
|
|||||||
artist = jsondata[index]["singer"]
|
artist = jsondata[index]["singer"]
|
||||||
album = jsondata[index]["song_rid"]
|
album = jsondata[index]["song_rid"]
|
||||||
elif choice == "WANGYIYUN":
|
elif choice == "WANGYIYUN":
|
||||||
full_name = jsondata[index]["name"]
|
full_name = jsondata[index]["title"]
|
||||||
artist = jsondata[index]["singers"][0]["name"]
|
artist = jsondata[index]["singer"]
|
||||||
|
album = jsondata[index]["songid"]
|
||||||
|
elif choice == "QQ":
|
||||||
|
full_name = jsondata[index]["title"]
|
||||||
|
artist = jsondata[index]["singer"]
|
||||||
|
album = ""
|
||||||
|
elif choice == "KUGOU":
|
||||||
|
full_name = jsondata[index]["title"]
|
||||||
|
artist = jsondata[index]["singer"]
|
||||||
|
album = ""
|
||||||
|
elif choice == "DOUYIN":
|
||||||
|
full_name = jsondata[index]["title"]
|
||||||
|
artist = jsondata[index]["singer"]
|
||||||
|
album = ""
|
||||||
|
elif choice == "XIAOFEN":
|
||||||
|
full_name = jsondata[index]["title"]
|
||||||
|
artist = jsondata[index]["singer"]
|
||||||
album = ""
|
album = ""
|
||||||
songlist.insert("", "end", values=(full_name, artist, album))
|
songlist.insert("", "end", values=(full_name, artist, album))
|
||||||
except requests.exceptions.JSONDecodeError:
|
except requests.exceptions.JSONDecodeError:
|
||||||
@ -1596,7 +1668,11 @@ themeLabel.place(x=10, y=25)
|
|||||||
# 基本设置
|
# 基本设置
|
||||||
repo_dict = {
|
repo_dict = {
|
||||||
"酷我音乐": "KUWO",
|
"酷我音乐": "KUWO",
|
||||||
"网易云音乐": "WANGYIYUN"
|
"网易云音乐": "WANGYIYUN",
|
||||||
|
"QQ音乐": "QQ",
|
||||||
|
"酷狗音乐": "KUGOU",
|
||||||
|
"汽水音乐": "DOUYIN",
|
||||||
|
"小粉音乐": "XIAOFEN"
|
||||||
}
|
}
|
||||||
repo_dict_reverse = {}
|
repo_dict_reverse = {}
|
||||||
for repo in repo_dict:
|
for repo in repo_dict:
|
||||||
|
Reference in New Issue
Block a user