提交 1eb178d0 编写于 作者: B binaryify

修复 eapi 接口无法正确解密response的问题 #1138

上级 d289f633
# 更新日志
### 4.0.6 | 2021.2.20
- 修复 eapi 接口无法正确解密response的问题 [#1138](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/1138)
### 4.0.5 | 2021.2.19
- 修复红心接口默认不红心的问题 [#1126](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/1126)
......
{
"name": "NeteaseCloudMusicApi",
"version": "4.0.5",
"version": "4.0.6",
"description": "网易云音乐 NodeJS 版 API",
"scripts": {
"start": "node app.js",
......
......@@ -111,7 +111,7 @@ const createRequest = (method, url, data, options) => {
}
const answer = { status: 500, body: {}, cookie: [] }
const settings = {
let settings = {
method: method,
url: url,
headers: headers,
......@@ -143,7 +143,12 @@ const createRequest = (method, url, data, options) => {
}
}
}
if (options.crypto === 'eapi') {
settings = {
...settings,
responseType: 'arraybuffer',
}
}
axios(settings)
.then((res) => {
const body = res.data
......@@ -151,7 +156,12 @@ const createRequest = (method, url, data, options) => {
x.replace(/\s*Domain=[^(;|$)]+;*/, ''),
)
try {
answer.body = body
if (options.crypto === 'eapi') {
answer.body = JSON.parse(encrypt.decrypt(body).toString())
} else {
answer.body = body
}
answer.status = answer.body.code || res.status
if (
[201, 302, 400, 502, 800, 801, 802, 803].indexOf(answer.body.code) >
......@@ -161,6 +171,7 @@ const createRequest = (method, url, data, options) => {
answer.status = 200
}
} catch (e) {
// console.log(e)
answer.body = body
answer.status = res.status
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册