Skip to content

Commit

Permalink
fix: 修复anonymous_token路径异常 Binaryify#1795
Browse files Browse the repository at this point in the history
  • Loading branch information
Binaryify committed Sep 12, 2023
1 parent 39ad34f commit 957213b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions app.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
19 changes: 17 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -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'))
Expand All @@ -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)
},
)
}
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "NeteaseCloudMusicApi",
"version": "4.12.1",
"version": "4.12.2",
"description": "网易云音乐 NodeJS 版 API",
"scripts": {
"start": "node app.js",
Expand Down

0 comments on commit 957213b

Please sign in to comment.