mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-20 14:41:23 +08:00
update: bump to v4.16.0
This commit is contained in:
+6
-4
@@ -15,20 +15,22 @@ const anonymous_token = fs.readFileSync(
|
||||
const { URLSearchParams, URL } = require('url')
|
||||
// request.debug = true // 开启可看到更详细信息
|
||||
|
||||
const chooseUserAgent = (ua = false) => {
|
||||
const chooseUserAgent = (uaType = false) => {
|
||||
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',
|
||||
pc: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0',
|
||||
}
|
||||
if (ua === 'mobile') {
|
||||
if (uaType === 'mobile') {
|
||||
return userAgentMap.mobile
|
||||
}
|
||||
return userAgentMap.pc
|
||||
}
|
||||
const createRequest = (method, url, data = {}, options) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let headers = { 'User-Agent': chooseUserAgent(options.ua) }
|
||||
let headers = {
|
||||
'User-Agent': options.ua || chooseUserAgent(options.uaType),
|
||||
}
|
||||
options.headers = options.headers || {}
|
||||
headers = {
|
||||
...headers,
|
||||
@@ -60,7 +62,7 @@ const createRequest = (method, url, data = {}, options) => {
|
||||
if (!options.cookie.MUSIC_A) {
|
||||
options.cookie.MUSIC_A = anonymous_token
|
||||
options.cookie.os = options.cookie.os || 'ios'
|
||||
options.cookie.appver = options.cookie.appver || '8.20.21'
|
||||
options.cookie.appver = options.cookie.appver || '9.0.65'
|
||||
}
|
||||
}
|
||||
headers['Cookie'] = Object.keys(options.cookie)
|
||||
|
||||
Reference in New Issue
Block a user