mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2025-10-22 22:53:09 +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
|
### 4.16.4 | 2024.04.23
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "NeteaseCloudMusicApi",
|
"name": "NeteaseCloudMusicApi",
|
||||||
"version": "4.16.4",
|
"version": "4.16.5",
|
||||||
"description": "网易云音乐 NodeJS 版 API",
|
"description": "网易云音乐 NodeJS 版 API",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node app.js",
|
"start": "node app.js",
|
||||||
|
@ -15,7 +15,7 @@ const anonymous_token = fs.readFileSync(
|
|||||||
const { URLSearchParams, URL } = require('url')
|
const { URLSearchParams, URL } = require('url')
|
||||||
// request.debug = true // 开启可看到更详细信息
|
// request.debug = true // 开启可看到更详细信息
|
||||||
|
|
||||||
const chooseUserAgent = (uaType = false) => {
|
const chooseUserAgent = (uaType) => {
|
||||||
const userAgentMap = {
|
const userAgentMap = {
|
||||||
mobile:
|
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',
|
'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'])
|
// console.log(options.cookie, headers['Cookie'])
|
||||||
if (options.crypto === 'weapi') {
|
if (options.crypto === 'weapi') {
|
||||||
headers['User-Agent'] =
|
headers['User-Agent'] = options.ua || chooseUserAgent('pc')
|
||||||
'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'
|
|
||||||
let csrfToken = (headers['Cookie'] || '').match(/_csrf=([^(;|$)]+)/)
|
let csrfToken = (headers['Cookie'] || '').match(/_csrf=([^(;|$)]+)/)
|
||||||
data.csrf_token = csrfToken ? csrfToken[1] : ''
|
data.csrf_token = csrfToken ? csrfToken[1] : ''
|
||||||
data = encrypt.weapi(data)
|
data = encrypt.weapi(data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user