From a8e9c78aebec0ff5aaf1fb1cce85d00f510788c2 Mon Sep 17 00:00:00 2001 From: dengtongyu Date: Sun, 19 May 2019 23:28:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=B7=E7=8B=97=E6=AD=8C?= =?UTF-8?q?=E6=9B=B2=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/forwarding.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/server/forwarding.js b/server/forwarding.js index a05b00b..46b4d70 100644 --- a/server/forwarding.js +++ b/server/forwarding.js @@ -7,6 +7,17 @@ const request = require('request'); +function randomString(len) { +   len = len || 32; +   var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; +   var maxPos = chars.length; +   var pwd = ''; +   for (i = 0; i < len; i++) { +     pwd += chars.charAt(Math.floor(Math.random() * maxPos)); +   } +   return pwd; +} + module.exports = { getSearchSongList:function(param,req,callback){ @@ -58,8 +69,11 @@ module.exports = { let proxy_url = 'http://www.kugou.com/yy/index.php?r=play/getdata&hash='+hash; let options = { - headers: {"Connection": "close"}, url: proxy_url, + headers: { + "Connection": "close", + "Cookie":"kg_mid="+randomString() + }, method: req.method.toUpperCase(), json: true, body: req.body