fix: 修复anonymous_token路径异常 #1795

This commit is contained in:
binaryify 2023-09-12 11:22:57 +08:00
parent 39ad34fa0b
commit 957213bb93
5 changed files with 25 additions and 5 deletions

View File

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

1
app.js Normal file → Executable file
View File

@ -8,6 +8,7 @@ async function start() {
if (!fs.existsSync(path.resolve(tmpPath, 'anonymous_token'))) {
fs.writeFileSync(path.resolve(tmpPath, 'anonymous_token'), '', 'utf-8')
}
// 启动时更新anonymous_token
const generateConfig = require('./generateConfig')
await generateConfig()
require('./server').serveNcmApi({

View File

@ -4280,7 +4280,7 @@ qrCodeStatus:20,detailReason:0 验证成功qrCodeStatus:21,detailReason:0 二
`nicknames`: 用户昵称,多个用分号(;)隔开
**接口地址:** `/user/nickname`
**接口地址:** `/get/userids`
**调用例子:** `/get/userids?nicknames=binaryify` `/get/userids?nicknames=binaryify;binaryify2`

19
main.js
View File

@ -1,8 +1,13 @@
const fs = require('fs')
const path = require('path')
const tmpPath = require('os').tmpdir()
const { cookieToJson } = require('./util')
const request = require('./util/request')
if (!fs.existsSync(path.resolve(tmpPath, 'anonymous_token'))) {
fs.writeFileSync(path.resolve(tmpPath, 'anonymous_token'), '', 'utf-8')
}
let firstRun = true
/** @type {Record<string, any>} */
let obj = {}
fs.readdirSync(path.join(__dirname, 'module'))
@ -20,7 +25,17 @@ fs.readdirSync(path.join(__dirname, 'module'))
...data,
cookie: data.cookie ? data.cookie : {},
},
request,
async (...args) => {
if (firstRun) {
firstRun = false
const generateConfig = require('./generateConfig')
await generateConfig()
}
// 待优化
const request = require('./util/request')
return request(...args)
},
)
}
})

View File

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