diff --git a/list.json b/list.json index 2e06cf8..c53545a 100644 --- a/list.json +++ b/list.json @@ -282,10 +282,10 @@ }, { "name": "neteasemusic", - "version": "2.6", + "version": "2.7", "section": "daily", "maintainer": "TNTcraftHIM", - "size": "24.4 kb", + "size": "24.3 kb", "supported": true, "des-short": "网易云点歌", "des": "可以在线搜索并且快速点歌,歌曲信息齐全,支持直接回复点歌。命令:nem。" diff --git a/neteasemusic.py b/neteasemusic.py index b854775..c3fd6a8 100644 --- a/neteasemusic.py +++ b/neteasemusic.py @@ -115,7 +115,7 @@ async def nem(context): search = ".*歌曲ID: (.*)\n.*" title = ".*歌名: (.*?)\n.*" title = "【"+re.findall(title, msg, re.S)[0]+"】" - keyword = re.findall(search, msg, re.S)[0] + idplay = re.findall(search, msg, re.S)[0] if reply.sender.is_self: await reply.edit(f"{title}点歌完成") except: @@ -141,18 +141,18 @@ async def nem(context): proxies = proxy[proxynum] proxynum += 1 if idplay: # 指定ID播放 - idurl = 'https://music.163.com/song?id=' + idplay - text = requests.get(url=idurl, headers=headers).text - pattern = re.compile(r'歌曲名《(.*?)》.*?由 (.*?) 演唱.*?') - keyword = pattern.findall( - text)[0][0] + " " + pattern.findall(text)[0][1] - url = "http://music.163.com/api/search/pc?&s=" + \ - keyword + "&offset=0&limit=1&type=1" - # 普通搜索+播放 + url = "http://music.163.com/api/song/detail?id="+ idplay +"&ids=[" + idplay + "]" + # 搜索后播放 req = requests.request("GET", url, headers=headers) if req.status_code == 200: req = json.loads(req.content) - if req['result']: + if req['code'] == 200: + if idplay: + req['result'] = req + result = req['result'] + else: + result = False + if result: info = {'id': '', 'title': '', 'alias': '', 'album': '', 'albumpic': '', 'artist': '', 'br': ''} info['id'] = req['result']['songs'][0]['id']