Skip to content

Commit

Permalink
update: 状态码判断完善,补充verify相关接口
Browse files Browse the repository at this point in the history
  • Loading branch information
Binaryify committed Aug 21, 2023
1 parent 7f21fbc commit 759b9fe
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
42 changes: 42 additions & 0 deletions module/verify_getQr.js
Original file line number Diff line number Diff line change
@@ -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
}&params=${JSON.stringify({
event_id: query.evid,
sign: query.sign,
})}`
return {
status: 200,
body: {
code: 200,
data: {
qrCode: res.body.data.qrCode,
qrurl: result,
},
},
}
}
17 changes: 17 additions & 0 deletions module/verify_qrcodestatus.js
Original file line number Diff line number Diff line change
@@ -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
}
11 changes: 8 additions & 3 deletions util/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 759b9fe

Please sign in to comment.