mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-05-23 22:37:41 +08:00
代码优化
This commit is contained in:
parent
065d4aa111
commit
6bd63eb061
@ -4,8 +4,6 @@
|
||||
// !需要登录或者匿名登录,非登录返回 []
|
||||
const config = require('../util/config.json')
|
||||
module.exports = (query, request) => {
|
||||
if (!('MUSIC_U' in query.cookie))
|
||||
query.cookie.MUSIC_A = config.anonymous_token
|
||||
const data = {}
|
||||
query.cookie.os = 'ios'
|
||||
query.cookie.appver = '8.7.01'
|
||||
|
@ -1,8 +1,6 @@
|
||||
// 相似歌手
|
||||
const config = require('../util/config.json')
|
||||
module.exports = (query, request) => {
|
||||
if (!('MUSIC_U' in query.cookie))
|
||||
query.cookie.MUSIC_A = config.anonymous_token
|
||||
const data = {
|
||||
artistid: query.id,
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"anonymous_token": "8aae43f148f990410b9a2af38324af24e87ab9227c9265627ddd10145db744295fcd8701dc45b1ab8985e142f491516295dd965bae848761274a577a62b0fdc54a50284d1e434dcc04ca6d1a52333c9a",
|
||||
"anonymous_token": "8aae43f148f990410b9a2af38324af24e87ab9227c9265627ddd10145db744295fcd8701dc45b1ab8985e142f491516295dd965bae848761274a577a62b0fdc54a50284d1e434dcc04ca6",
|
||||
"resourceTypeMap": {
|
||||
"0": "R_SO_4_",
|
||||
"1": "R_MV_5_",
|
||||
|
@ -14,4 +14,11 @@ module.exports = {
|
||||
})
|
||||
return obj
|
||||
},
|
||||
getRandom(num) {
|
||||
var random = Math.floor(
|
||||
(Math.random() + Math.floor(Math.random() * 9 + 1)) *
|
||||
Math.pow(10, num - 1),
|
||||
)
|
||||
return random
|
||||
},
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ const https = require('https')
|
||||
const tunnel = require('tunnel')
|
||||
const { URLSearchParams, URL } = require('url')
|
||||
const config = require('../util/config.json')
|
||||
const { getRandom } = require('../util')
|
||||
// request.debug = true // 开启可看到更详细信息
|
||||
|
||||
const chooseUserAgent = (ua = false) => {
|
||||
@ -54,7 +55,7 @@ const createRequest = (method, url, data, options) => {
|
||||
if (typeof options.cookie === 'object') {
|
||||
if (!options.cookie.MUSIC_U) {
|
||||
// 匿名
|
||||
options.cookie.MUSIC_A = config.anonymous_token
|
||||
options.cookie.MUSIC_A = config.anonymous_token + getRandom(10)
|
||||
}
|
||||
headers['Cookie'] = Object.keys(options.cookie)
|
||||
.map(
|
||||
@ -112,7 +113,6 @@ const createRequest = (method, url, data, options) => {
|
||||
data = encrypt.eapi(options.url, data)
|
||||
url = url.replace(/\w*api/, 'eapi')
|
||||
}
|
||||
|
||||
const answer = { status: 500, body: {}, cookie: [] }
|
||||
let settings = {
|
||||
method: method,
|
||||
|
Loading…
x
Reference in New Issue
Block a user