mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2025-10-22 14:43:10 +00:00
fix: ua 问题修复
This commit is contained in:
parent
4fe71a4903
commit
d55fb43f0a
@ -1,4 +1,6 @@
|
||||
# 更新日志
|
||||
### 4.16.5 | 2024.04.25
|
||||
- ua 问题修复
|
||||
|
||||
### 4.16.4 | 2024.04.23
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "NeteaseCloudMusicApi",
|
||||
"version": "4.16.4",
|
||||
"version": "4.16.5",
|
||||
"description": "网易云音乐 NodeJS 版 API",
|
||||
"scripts": {
|
||||
"start": "node app.js",
|
||||
|
@ -15,7 +15,7 @@ const anonymous_token = fs.readFileSync(
|
||||
const { URLSearchParams, URL } = require('url')
|
||||
// request.debug = true // 开启可看到更详细信息
|
||||
|
||||
const chooseUserAgent = (uaType = false) => {
|
||||
const chooseUserAgent = (uaType) => {
|
||||
const userAgentMap = {
|
||||
mobile:
|
||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 17_2_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1',
|
||||
@ -80,8 +80,7 @@ const createRequest = (method, url, data = {}, options) => {
|
||||
}
|
||||
// console.log(options.cookie, headers['Cookie'])
|
||||
if (options.crypto === 'weapi') {
|
||||
headers['User-Agent'] =
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.69'
|
||||
headers['User-Agent'] = options.ua || chooseUserAgent('pc')
|
||||
let csrfToken = (headers['Cookie'] || '').match(/_csrf=([^(;|$)]+)/)
|
||||
data.csrf_token = csrfToken ? csrfToken[1] : ''
|
||||
data = encrypt.weapi(data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user