From 29ae2a76cfa39baf9e3a69cba467fa6b3f7c5dec Mon Sep 17 00:00:00 2001 From: TNTcraftHIM Date: Sat, 29 Aug 2020 03:49:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9C=9F=C2=B7ID=E6=92=AD=E6=94=BE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=B7=BB=E5=8A=A0=EF=BC=88=E4=B9=8B=E5=89=8D=E6=98=AF?= =?UTF-8?q?=E5=81=87=E7=9A=84=EF=BC=8C=E5=97=AF=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.json | 4 ++-- neteasemusic.py | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) 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']