diff --git a/module/homepage_dragon_ball.js b/module/homepage_dragon_ball.js index e2421bf9b92..62280d9d20d 100644 --- a/module/homepage_dragon_ball.js +++ b/module/homepage_dragon_ball.js @@ -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' diff --git a/module/simi_artist.js b/module/simi_artist.js index 36d25726256..569618e2c76 100644 --- a/module/simi_artist.js +++ b/module/simi_artist.js @@ -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, } diff --git a/util/config.json b/util/config.json index dbfda36742d..37d2ce953a6 100644 --- a/util/config.json +++ b/util/config.json @@ -1,5 +1,5 @@ { - "anonymous_token": "8aae43f148f990410b9a2af38324af24e87ab9227c9265627ddd10145db744295fcd8701dc45b1ab8985e142f491516295dd965bae848761274a577a62b0fdc54a50284d1e434dcc04ca6d1a52333c9a", + "anonymous_token": "8aae43f148f990410b9a2af38324af24e87ab9227c9265627ddd10145db744295fcd8701dc45b1ab8985e142f491516295dd965bae848761274a577a62b0fdc54a50284d1e434dcc04ca6", "resourceTypeMap": { "0": "R_SO_4_", "1": "R_MV_5_", diff --git a/util/index.js b/util/index.js index 06aade52993..78129b4ce50 100644 --- a/util/index.js +++ b/util/index.js @@ -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 + }, } diff --git a/util/request.js b/util/request.js index 6c896a75762..c26c6324d22 100644 --- a/util/request.js +++ b/util/request.js @@ -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,