Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ aiofiles==0.5.0
RUL = 'http://music.163.com/api/song/detail/?id={0}&ids=%5B{1}%5D'.format(song_id, song_id)

例子:http://music.163.com/api/song/detail/?id=1347203552&ids=%5B1347203552%5D

****
2024-12-19
修改json读取方式
4 changes: 3 additions & 1 deletion transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import aiohttp
import aiofiles
import config
import json

class Transform():
def __init__(self):
Expand Down Expand Up @@ -77,7 +78,8 @@ async def get_song_info(self, song_id):
url = 'http://music.163.com/api/song/detail/?id={0}&ids=%5B{1}%5D'.format(song_id, song_id) # 请求url例子:http://music.163.com/api/song/detail/?id=1347203552&ids=%5B1347203552%5D
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
jsons = await response.json()
raw_response = await response.text()
jsons = json.loads(raw_response)
song_name = jsons['songs'][0]['name']
singer = jsons['songs'][0]['artists'][0]['name']
return song_name, singer
Expand Down