本帖最后由 xiaqiusheng 于 2023-8-2 14:04 编辑
输入关键词接口还没有完成,目前只能输入周杰伦
代码片段提供给各位学习娱乐,main直接可以运行
import json
import re
from pprint import pprint
import datetime
import requests
from urllib import parse
def down_music():
url = f'https://wwwapi.kugou.com/yy/index.php?r=play/getdata&callback&dfid=3MmYPK1TgvoY3ekNaJ45mjYH&appid=1014&mid=a51eace30575793fc6ad4f9e52fca686&platid=4&encode_album_audio_id={uid}'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'}
res = requests.get(url=url, headers=headers)
data_list = res.json()
audioname = data_list['data']['audio_name']
play_url = data_list['data']['play_url']
audioname = re.sub(r'[<>:"/\\|?*]', '_', audioname)
#print(audioname, play_url)
if __name__ == '__main__':
key = input('请输入歌手或者歌名:')
#key = '周杰伦'
#key = '张靓颖'
urls = []
jiami_key = parse.quote(key)
url = f"https://complexsearch.kugou.com/v2/search/song?callback=callback123&srcappid=2919&clientver=1000&clienttime=1690537511637&mid=5d4f7710b54de2caf7fe201b3099483d&uuid=5d4f7710b54de2caf7fe201b3099483d&dfid=11Sz5t1I7mAE45zqa70zu6gd&keyword={jiami_key}&page=1&pagesize=30&bitrate=0&isfuzzy=0&inputtype=0&platform=WebFilter&userid=0&iscorrection=1&privilege_filter=0&filter=10&token=&appid=1014&signature=25ba10ba7ab70b1b9f003b871d53eaf3"
#url = f"https://complexsearch.kugou.com/v2/search/song?callback=callback123&srcappid=2919&clientver=1000&clienttime=1690777278081&mid=5d4f7710b54de2caf7fe201b3099483d&uuid=5d4f7710b54de2caf7fe201b3099483d&dfid=11Sz5t1I7mAE45zqa70zu6gd&keyword={jiami_key}&page=1&pagesize=30&bitrate=0&isfuzzy=0&inputtype=0&platform=WebFilter&userid=0&iscorrection=1&privilege_filter=0&filter=10&token=&appid=1014&signature=f313e1b20efbbd9fcae71e747168868b"
#print(url)
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'}
res = requests.get(url=url, headers=headers).text
res = res[12:-2]
data = json.loads(res)
data_list = (data["data"]["lists"])
# 取 EMixSongID
for item in data_list:
EMixSongID = item["EMixSongID"]
uid = EMixSongID
urls.append(uid)
for uid in urls:
down_music()
|