feat(music): 添加酷我音乐支持并替换QQ音乐功能
- 实现酷我音乐搜索和播放功能,替换原有的QQ音乐接口 - 更新歌词获取逻辑以适配酷我音乐API格式 - 修改音乐搜索和列表显示以支持酷我音乐数据结构 - 将Git仓库地址从公共域名切换到内部域名 - 更新版本号从4.3.6到4.3.7 - 调整音乐源选择界面标签为酷我音乐
This commit is contained in:
43
NFLmusic.py
43
NFLmusic.py
@ -154,19 +154,26 @@ def download_music(song_name, choose):
|
||||
music_name = resp.json()["data"]["name"]
|
||||
singer = resp.json()["data"]["singers"][0]["name"]
|
||||
music_url = resp.json()["data"]["url"]
|
||||
elif choice == "QQ":
|
||||
elif choice == "KUWO":
|
||||
resp = requests.get(f"{url}?msg={song_name}&n={choose}&limit=60&type=json&br={br}&key=oiapi-e3329f47-ccbc-2279-14b6-eabd4c7286ac")
|
||||
resp.close()
|
||||
songid = resp.json()["data"]["songid"]
|
||||
resp1 = requests.get(f"https://oiapi.net/api/QQMusicLyric?id={songid}")
|
||||
songid = resp.json()["data"]["id"]
|
||||
try:
|
||||
lrc = resp1.json()["message"]
|
||||
resp_lrc = requests.get(f"https://www.kuwo.cn/openapi/v1/www/lyric/getlyric?musicId={songid}")
|
||||
resp_lrc.close()
|
||||
lrc = ""
|
||||
lrclist = resp_lrc.json()["data"]["lrclist"]
|
||||
for i in lrclist:
|
||||
total_time = i["time"]
|
||||
min = float(total_time) // 60
|
||||
sec = float(total_time) % 60
|
||||
lrc += f'[{int(min)}:{sec}]{i["lineLyric"]}\n'
|
||||
except Exception as e:
|
||||
print(f"download_qq_lrc: {e}")
|
||||
print(f"download_kw_lrc: {e}")
|
||||
lrc = ""
|
||||
music_name = resp.json()["data"]["song"]
|
||||
singer = resp.json()["data"]["singer"]
|
||||
music_url = resp.json()["data"]["music"]
|
||||
music_url = resp.json()["data"]["url"]
|
||||
else:
|
||||
lrc = ""
|
||||
lrc = lrc.replace("\\n", "\n")
|
||||
@ -276,7 +283,7 @@ def get_data_without_blocking(song_name):
|
||||
songlist.delete(*songlist.get_children())
|
||||
if choice == "WANGYIYUN":
|
||||
url1 = f"{url}?name={song_name}&limit=60&type=json&key=oiapi-e3329f47-ccbc-2279-14b6-eabd4c7286ac"
|
||||
elif choice == "QQ":
|
||||
elif choice == "KUWO":
|
||||
url1 = f"{url}?msg={song_name}&limit=60&type=json&key=oiapi-e3329f47-ccbc-2279-14b6-eabd4c7286ac"
|
||||
resp = requests.get(url1)
|
||||
jsondata = resp.json()
|
||||
@ -287,10 +294,10 @@ def get_data_without_blocking(song_name):
|
||||
full_name = jsondata["data"][index]["name"]
|
||||
artist = jsondata["data"][index]["singers"][0]["name"]
|
||||
album = jsondata["data"][index]["id"]
|
||||
elif choice == "QQ":
|
||||
elif choice == "KUWO":
|
||||
full_name = jsondata["data"][index]["song"]
|
||||
artist = jsondata["data"][index]["singer"]
|
||||
album = jsondata["data"][index]["songid"]
|
||||
album = jsondata["data"][index]["album"]
|
||||
songlist.insert("", "end", values=(full_name, artist, album))
|
||||
except requests.exceptions.JSONDecodeError:
|
||||
resp_text = resp.text
|
||||
@ -465,10 +472,10 @@ def display_sentences():
|
||||
time.sleep(0.1)
|
||||
poem = ""
|
||||
try:
|
||||
resp = requests.get("http://git.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/random_quote")
|
||||
resp = requests.get("http://internalgit.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/random_quote")
|
||||
poem = resp.text.replace("\r", "").split("\n")
|
||||
resp.close()
|
||||
resp0 = requests.get("http://git.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/announcement")
|
||||
resp0 = requests.get("http://internalgit.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/announcement")
|
||||
announcement_text = resp0.text.replace("\\n", "")
|
||||
resp0.close()
|
||||
poem = c(poem)
|
||||
@ -657,12 +664,12 @@ def update():
|
||||
if not os.path.exists(appdata + "/.NFLmusic/update"):
|
||||
os.mkdir(appdata + "/.NFLmusic/update")
|
||||
if not have_checked:
|
||||
data_url = "http://git.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/data"
|
||||
data_url = "http://internalgit.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/data"
|
||||
data_resp = requests.get(data_url)
|
||||
data_resp.close()
|
||||
datalist = data_resp.text.replace("\r", "").split("\n")
|
||||
update_path = appdata + "/.NFLmusic/update/"
|
||||
data_url = "http://git.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/latest_update_log"
|
||||
data_url = "http://internalgit.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/latest_update_log"
|
||||
data_resp = requests.get(data_url).text
|
||||
latest_version = datalist[0]
|
||||
if latest_version != version:
|
||||
@ -786,7 +793,7 @@ def check_update():
|
||||
global datalist, have_checked
|
||||
check_update_button["state"] = "disabled"
|
||||
try:
|
||||
data_url = "http://git.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/data"
|
||||
data_url = "http://internalgit.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/data"
|
||||
data_resp = requests.get(data_url)
|
||||
datalist = data_resp.text.replace("\r", "").split("\n")
|
||||
latest_version = datalist[0]
|
||||
@ -1181,7 +1188,7 @@ def load_versions():
|
||||
global version_json
|
||||
time.sleep(0.5)
|
||||
try:
|
||||
resp = requests.get("http://git.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/version_list.json")
|
||||
resp = requests.get("http://internalgit.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/version_list.json")
|
||||
version_json = resp.json()
|
||||
resp.close()
|
||||
for version_item in version_json:
|
||||
@ -1254,7 +1261,7 @@ def search_local_song():
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
version = "4.3.6"
|
||||
version = "4.3.7"
|
||||
poem = ""
|
||||
appdata = os.getenv("APPDATA")
|
||||
make_resource()
|
||||
@ -1558,7 +1565,7 @@ sponsors_list.place(x=10, y=210)
|
||||
scrollbar3.config(command=sponsors_list.yview)
|
||||
scrollbar3.place(x=227, y=210, height=240)
|
||||
try:
|
||||
data_url = "http://git.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/sponsors"
|
||||
data_url = "http://internalgit.nanfengling.cn/NFL_jiancx/NFLmusic/raw/branch/master/version_info/sponsors"
|
||||
data_resp = requests.get(data_url)
|
||||
data_list = data_resp.text.replace("\r", "").split("\n")
|
||||
for sponsor in data_list:
|
||||
@ -1623,7 +1630,7 @@ themeLabel.place(x=10, y=25)
|
||||
|
||||
# 基本设置
|
||||
repo_dict = {
|
||||
"QQ音乐": "QQ",
|
||||
"酷我音乐": "KUWO",
|
||||
"网易云音乐": "WANGYIYUN",
|
||||
}
|
||||
repo_dict_reverse = {}
|
||||
|
||||
Reference in New Issue
Block a user