Skip to content

Commit 957213b

Browse files
committed
fix: 修复anonymous_token路径异常 #1795
1 parent 39ad34f commit 957213b

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

CHANGELOG.MD

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 更新日志
2-
### 4.12.0 | 2023.09.10
2+
### 4.12.2 | 2023.09.12
3+
- 新增 `播客声音列表`接口
4+
- 修复anonymous_token路径异常 #1795
5+
6+
### 4.12.1 | 2023.09.10
37
- 补充 `get/userids`(根据nickname获取userid) 接口
48

59
### 4.12.0 | 2023.09.10

app.js

100644100755
+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ async function start() {
88
if (!fs.existsSync(path.resolve(tmpPath, 'anonymous_token'))) {
99
fs.writeFileSync(path.resolve(tmpPath, 'anonymous_token'), '', 'utf-8')
1010
}
11+
// 启动时更新anonymous_token
1112
const generateConfig = require('./generateConfig')
1213
await generateConfig()
1314
require('./server').serveNcmApi({

docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4280,7 +4280,7 @@ qrCodeStatus:20,detailReason:0 验证成功qrCodeStatus:21,detailReason:0 二
42804280
42814281
`nicknames`: 用户昵称,多个用分号(;)隔开
42824282
4283-
**接口地址:** `/user/nickname`
4283+
**接口地址:** `/get/userids`
42844284
42854285
**调用例子:** `/get/userids?nicknames=binaryify` `/get/userids?nicknames=binaryify;binaryify2`
42864286

main.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
const fs = require('fs')
22
const path = require('path')
3+
const tmpPath = require('os').tmpdir()
34
const { cookieToJson } = require('./util')
4-
const request = require('./util/request')
55

6+
if (!fs.existsSync(path.resolve(tmpPath, 'anonymous_token'))) {
7+
fs.writeFileSync(path.resolve(tmpPath, 'anonymous_token'), '', 'utf-8')
8+
}
9+
10+
let firstRun = true
611
/** @type {Record<string, any>} */
712
let obj = {}
813
fs.readdirSync(path.join(__dirname, 'module'))
@@ -20,7 +25,17 @@ fs.readdirSync(path.join(__dirname, 'module'))
2025
...data,
2126
cookie: data.cookie ? data.cookie : {},
2227
},
23-
request,
28+
async (...args) => {
29+
if (firstRun) {
30+
firstRun = false
31+
const generateConfig = require('./generateConfig')
32+
await generateConfig()
33+
}
34+
// 待优化
35+
const request = require('./util/request')
36+
37+
return request(...args)
38+
},
2439
)
2540
}
2641
})

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "NeteaseCloudMusicApi",
3-
"version": "4.12.1",
3+
"version": "4.12.2",
44
"description": "网易云音乐 NodeJS 版 API",
55
"scripts": {
66
"start": "node app.js",

0 commit comments

Comments
 (0)