mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-05-23 22:37:41 +08:00
refactor: 补充一些注释
This commit is contained in:
parent
c38a8a0816
commit
bd8c049576
@ -6,6 +6,6 @@ module.exports = (query, request) => {
|
||||
typeof query.data === 'string' ? JSON.parse(query.data) : query.data || {}
|
||||
const crypto = query.crypto || ''
|
||||
|
||||
let res = request(method, uri, data, createOption(query, crypto))
|
||||
const res = request(method, uri, data, createOption(query, crypto))
|
||||
return res
|
||||
}
|
||||
|
@ -84,7 +84,9 @@ const createRequest = (method, uri, data = {}, options) => {
|
||||
headers['Cookie'] = cookieObjToString(cookie)
|
||||
}
|
||||
// console.log(options.cookie, headers['Cookie'])
|
||||
|
||||
let url = ''
|
||||
// 目前任意uri都支持三种加密方式
|
||||
if (options.crypto === 'weapi') {
|
||||
headers['Referer'] = 'https://music.163.com'
|
||||
headers['User-Agent'] = options.ua || chooseUserAgent('pc')
|
||||
@ -93,13 +95,13 @@ const createRequest = (method, uri, data = {}, options) => {
|
||||
data = encrypt.weapi(data)
|
||||
url = APP_CONF.domain + '/weapi/' + uri.substr(5)
|
||||
} else if (options.crypto === 'linuxapi') {
|
||||
headers['User-Agent'] =
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36'
|
||||
data = encrypt.linuxapi({
|
||||
method: method,
|
||||
url: APP_CONF.apiDomain + uri,
|
||||
params: data,
|
||||
})
|
||||
headers['User-Agent'] =
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36'
|
||||
url = 'https://music.163.com/api/linux/forward'
|
||||
} else if (
|
||||
options.crypto === 'eapi' ||
|
||||
@ -148,6 +150,9 @@ const createRequest = (method, uri, data = {}, options) => {
|
||||
eapiEncrypt()
|
||||
} else url = APP_CONF.apiDomain + uri
|
||||
}
|
||||
} else {
|
||||
// 未知的加密方式
|
||||
console.log('[ERR]', 'Unknown Crypto:', options.crypto)
|
||||
}
|
||||
const answer = { status: 500, body: {}, cookie: [] }
|
||||
// console.log(headers, 'headers')
|
||||
@ -160,8 +165,6 @@ const createRequest = (method, uri, data = {}, options) => {
|
||||
httpsAgent: new https.Agent({ keepAlive: true }),
|
||||
}
|
||||
|
||||
if (options.crypto === 'eapi') settings.encoding = null
|
||||
|
||||
if (options.proxy) {
|
||||
if (options.proxy.indexOf('pac') > -1) {
|
||||
settings.httpAgent = new PacProxyAgent(options.proxy)
|
||||
@ -191,12 +194,6 @@ const createRequest = (method, uri, data = {}, options) => {
|
||||
} else {
|
||||
settings.proxy = false
|
||||
}
|
||||
if (options.crypto === 'eapi') {
|
||||
settings = {
|
||||
...settings,
|
||||
responseType: 'arraybuffer',
|
||||
}
|
||||
}
|
||||
axios(settings)
|
||||
.then((res) => {
|
||||
const body = res.data
|
||||
|
Loading…
x
Reference in New Issue
Block a user