diff --git a/CHANGELOG.MD b/CHANGELOG.MD index bf4c3bf9fcf..969ca29c854 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -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 diff --git a/app.js b/app.js old mode 100644 new mode 100755 index 61ca724b451..1c662e007ab --- a/app.js +++ b/app.js @@ -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({ diff --git a/docs/README.md b/docs/README.md index 8c1ab79b20d..d48261b0b21 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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` diff --git a/main.js b/main.js index 796298accbd..b6fc81b9046 100644 --- a/main.js +++ b/main.js @@ -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} */ 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) + }, ) } }) diff --git a/package.json b/package.json index 8c07adba961..919f1416f8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "NeteaseCloudMusicApi", - "version": "4.12.1", + "version": "4.12.2", "description": "网易云音乐 NodeJS 版 API", "scripts": { "start": "node app.js",