解决网络拥堵提示问题

This commit is contained in:
binaryify 2022-09-12 17:23:49 +08:00
parent b4f6ba0884
commit 3cca8d2924
8 changed files with 9 additions and 7 deletions

View File

@ -1,5 +1,5 @@
# 更新日志 # 更新日志
### 4.8.0 | 2022.09.12 ### 4.8.1 | 2022.09.12
- 解决网络拥堵提示问题 - 解决网络拥堵提示问题
### 4.7.0 | 2022.09.02 ### 4.7.0 | 2022.09.02

View File

@ -1,6 +1,6 @@
{ {
"name": "NeteaseCloudMusicApi", "name": "NeteaseCloudMusicApi",
"version": "4.8.0", "version": "4.8.1",
"description": "网易云音乐 NodeJS 版 API", "description": "网易云音乐 NodeJS 版 API",
"scripts": { "scripts": {
"start": "node app.js", "start": "node app.js",

View File

@ -6,7 +6,6 @@ describe('测试获取歌手专辑列表是否正常', () => {
it('数据的 code 应该为200', (done) => { it('数据的 code 应该为200', (done) => {
const qs = { const qs = {
id: 32311, id: 32311,
cookie: '__remember_me=true; NMTID=xxx',
} }
axios axios

View File

@ -6,7 +6,6 @@ describe('测试获取评论是否正常', () => {
it('数据的 code 应该为200', (done) => { it('数据的 code 应该为200', (done) => {
const qs = { const qs = {
id: 32311, id: 32311,
cookie: '__remember_me=true; NMTID=xxx',
} }
axios axios

View File

@ -6,7 +6,6 @@ describe('测试获取歌词是否正常', () => {
it('数据应该有 lrc 字段', (done) => { it('数据应该有 lrc 字段', (done) => {
const qs = { const qs = {
id: 347230, id: 347230,
cookie: '__remember_me=true; NMTID=xxx',
} }
axios axios

View File

@ -8,7 +8,6 @@ describe('测试获取歌曲是否正常', () => {
id: 462791935, id: 462791935,
br: 999000, br: 999000,
realIP: '116.25.146.177', realIP: '116.25.146.177',
cookie: '__remember_me=true; NMTID=xxx',
} }
axios axios

View File

@ -7,7 +7,6 @@ describe('测试搜索是否正常', () => {
const qs = { const qs = {
keywords: '海阔天空', keywords: '海阔天空',
type: 1, type: 1,
cookie: '__remember_me=true; NMTID=xxx',
} }
axios axios
.get(`${host}/search`, { .get(`${host}/search`, {

View File

@ -57,6 +57,11 @@ const createRequest = (method, url, data = {}, options) => {
} }
// headers['X-Real-IP'] = '118.88.88.88' // headers['X-Real-IP'] = '118.88.88.88'
if (typeof options.cookie === 'object') { if (typeof options.cookie === 'object') {
options.cookie = {
...options.cookie,
__remember_me: true,
NMTID: 'xxx',
}
if (!options.cookie.MUSIC_U) { if (!options.cookie.MUSIC_U) {
// 游客 // 游客
if (!options.cookie.MUSIC_A) { if (!options.cookie.MUSIC_A) {
@ -73,6 +78,8 @@ const createRequest = (method, url, data = {}, options) => {
.join('; ') .join('; ')
} else if (options.cookie) { } else if (options.cookie) {
headers['Cookie'] = options.cookie headers['Cookie'] = options.cookie
} else {
headers['Cookie'] = '__remember_me=true; NMTID=xxx'
} }
// console.log(options.cookie, headers['Cookie']) // console.log(options.cookie, headers['Cookie'])
if (options.crypto === 'weapi') { if (options.crypto === 'weapi') {