From 5a0bdfb171746ecd2c26b7a9904908e24b84f8be Mon Sep 17 00:00:00 2001 From: binaryify Date: Mon, 21 Aug 2023 10:19:17 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E7=8A=B6=E6=80=81=E7=A0=81=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=AE=8C=E5=96=84,=E8=A1=A5=E5=85=85verify=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=8E=A5=E5=8F=A3=20#1783?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.MD | 5 +++++ docs/README.md | 6 ++--- module/verify_getQr.js | 42 +++++++++++++++++++++++++++++++++++ module/verify_qrcodestatus.js | 17 ++++++++++++++ util/request.js | 11 ++++++--- 5 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 module/verify_getQr.js create mode 100644 module/verify_qrcodestatus.js diff --git a/CHANGELOG.MD b/CHANGELOG.MD index a67472e..009ad5a 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,4 +1,9 @@ # 更新日志 +### 4.9.3 | 2023.08.21 +- 禁用NMTID #1788 +- 状态码判断完善,补充verify相关接口 #1783 +- 增加对带用户名密码的代理支持 #1787 + ### 4.9.2 | 2023.08.15 - 补充 `/vip/info/v2` 接口 diff --git a/docs/README.md b/docs/README.md index 1c6e589..4f60674 100644 --- a/docs/README.md +++ b/docs/README.md @@ -489,9 +489,9 @@ $ sudo docker run -d -p 3000:3000 netease-music-api 不要频繁调登录接口,不然可能会被风控,登录状态还存在就不要重复调登录接口 -因网易增加了网易云盾验证,密码登录暂时不要使用,尽量使用短信验证码登录和二维码登录,否则调用某些接口会触发需要验证的错误 +~~因网易增加了网易云盾验证,密码登录暂时不要使用,尽量使用短信验证码登录和二维码登录,否则调用某些接口会触发需要验证的错误~~ -#### 1. 手机登录(现在要求验证,暂时绕不过,请使用二维码登录) +#### 1. 手机登录 **必选参数 :** `phone`: 手机号码 @@ -509,7 +509,7 @@ $ sudo docker run -d -p 3000:3000 netease-music-api **调用例子 :** `/login/cellphone?phone=xxx&password=yyy` `/login/cellphone?phone=xxx&md5_password=yyy` `/login/cellphone?phone=xxx&captcha=1234` -#### 2. 邮箱登录(现在要求验证,暂时绕不过,请使用二维码登录) +#### 2. 邮箱登录 **必选参数 :** diff --git a/module/verify_getQr.js b/module/verify_getQr.js new file mode 100644 index 0000000..7322267 --- /dev/null +++ b/module/verify_getQr.js @@ -0,0 +1,42 @@ +module.exports = async (query, request) => { + const data = { + verifyConfigId: query.vid, + verifyType: query.type, + token: query.token, + params: JSON.stringify({ + event_id: query.evid, + sign: query.sign, + }), + size: 150, + } + + const res = await request( + 'POST', + `https://music.163.com/weapi/frontrisk/verify/getqrcode`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ) + const result = `https://st.music.163.com/encrypt-pages?qrCode=${ + res.body.data.qrCode + }&verifyToken=${query.token}&verifyId=${query.vid}&verifyType=${ + query.type + }¶ms=${JSON.stringify({ + event_id: query.evid, + sign: query.sign, + })}` + return { + status: 200, + body: { + code: 200, + data: { + qrCode: res.body.data.qrCode, + qrurl: result, + }, + }, + } +} diff --git a/module/verify_qrcodestatus.js b/module/verify_qrcodestatus.js new file mode 100644 index 0000000..6263bdd --- /dev/null +++ b/module/verify_qrcodestatus.js @@ -0,0 +1,17 @@ +module.exports = async (query, request) => { + const data = { + qrCode: query.qr, + } + const res = await request( + 'POST', + `https://music.163.com/weapi/frontrisk/verify/qrcodestatus`, + data, + { + crypto: 'weapi', + cookie: query.cookie, + proxy: query.proxy, + realIP: query.realIP, + }, + ) + return res +} diff --git a/util/request.js b/util/request.js index 0dcad61..16bd458 100644 --- a/util/request.js +++ b/util/request.js @@ -147,11 +147,16 @@ const createRequest = (method, url, data = {}, options) => { } else { const purl = new URL(options.proxy) if (purl.hostname) { - const agent = tunnel[purl.protocol === 'https' ? 'httpsOverHttp' : 'httpOverHttp']({ + const agent = tunnel[ + purl.protocol === 'https' ? 'httpsOverHttp' : 'httpOverHttp' + ]({ proxy: { host: purl.hostname, port: purl.port || 80, - proxyAuth: purl.username && purl.password ? (purl.username + ':' + purl.password) : '' + proxyAuth: + purl.username && purl.password + ? purl.username + ':' + purl.password + : '', }, }) settings.httpsAgent = agent @@ -183,7 +188,7 @@ const createRequest = (method, url, data = {}, options) => { answer.body = body } - answer.status = answer.body.code || res.status + answer.status = Number(answer.body.code || res.status) if ( [201, 302, 400, 502, 800, 801, 802, 803].indexOf(answer.body.code) > -1