From 4afb471d331d693ca25d1a8b9bb912d187880f25 Mon Sep 17 00:00:00 2001 From: huggy <6511667+makeding@users.noreply.github.com> Date: Thu, 10 Sep 2020 23:54:22 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=BA=86=E4=B8=8B=20UA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/request.js | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/util/request.js b/util/request.js index b0d3b473c3f..251253d93b5 100644 --- a/util/request.js +++ b/util/request.js @@ -8,19 +8,25 @@ const zlib = require('zlib') const chooseUserAgent = ua => { const userAgentList = [ - 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1', - 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1', - 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Mobile Safari/537.36', - 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Mobile Safari/537.36', - 'Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Mobile Safari/537.36', - 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Mobile/14F89;GameHelper', - 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_0 like Mac OS X) AppleWebKit/602.1.38 (KHTML, like Gecko) Version/10.0 Mobile/14A300 Safari/602.1', - 'Mozilla/5.0 (iPad; CPU OS 10_0 like Mac OS X) AppleWebKit/602.1.38 (KHTML, like Gecko) Version/10.0 Mobile/14A300 Safari/602.1', - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:46.0) Gecko/20100101 Firefox/46.0', - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36', - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4', - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:46.0) Gecko/20100101 Firefox/46.0', - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36', + // iOS 13.5.1 14.0 beta with safari + 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1', + 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.', + // iOS with qq micromsg + 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/602.1.50 (KHTML like Gecko) Mobile/14A456 QQ/6.5.7.408 V1_IPH_SQ_6.5.7_1_APP_A Pixel/750 Core/UIWebView NetType/4G Mem/103', + 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.15(0x17000f27) NetType/WIFI Language/zh', + // Android -> Huawei Xiaomi + 'Mozilla/5.0 (Linux; Android 9; PCT-AL10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.64 HuaweiBrowser/10.0.3.311 Mobile Safari/537.36', + 'Mozilla/5.0 (Linux; U; Android 9; zh-cn; Redmi Note 8 Build/PKQ1.190616.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/71.0.3578.141 Mobile Safari/537.36 XiaoMi/MiuiBrowser/12.5.22', + // Android with qq micromsg + 'Mozilla/5.0 (Linux; Android 10; YAL-AL00 Build/HUAWEIYAL-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.62 XWEB/2581 MMWEBSDK/200801 Mobile Safari/537.36 MMWEBID/3027 MicroMessenger/7.0.18.1740(0x27001235) Process/toolsmp WeChat/arm64 NetType/WIFI Language/zh_CN ABI/arm64', + 'Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; BKK-AL10 Build/HONORBKK-AL10) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/10.6 Mobile Safari/537.36', + // macOS 10.15.6 Firefox / Chrome / Safari + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:80.0) Gecko/20100101 Firefox/80.0', + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.30 Safari/537.36', + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Safari/605.1.15', + // Windows 10 Firefox / Chrome / Edge + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0', + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.30 Safari/537.36', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/13.10586' ] let index = 0 @@ -52,7 +58,7 @@ const createRequest = (method, url, data, options) => { ) .join('; ') else if (options.cookie) headers['Cookie'] = options.cookie - + if (!headers['Cookie']) { headers['Cookie'] = options.token || '' } @@ -68,7 +74,7 @@ const createRequest = (method, url, data, options) => { 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' + 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36' url = 'https://music.163.com/api/linux/forward' } else if (options.crypto === 'eapi') { const cookie = options.cookie || {}; @@ -134,10 +140,10 @@ const createRequest = (method, url, data, options) => { zlib.unzip(body, function (err, buffer) { const _buffer = err ? body : buffer try { - try{ + try { answer.body = JSON.parse(encrypt.decrypt(_buffer).toString()) answer.status = answer.body.code || res.statusCode - } catch(e){ + } catch (e) { answer.body = JSON.parse(_buffer.toString()) answer.status = res.statusCode } @@ -156,7 +162,7 @@ const createRequest = (method, url, data, options) => { answer.body = JSON.parse(body) answer.status = answer.body.code || res.statusCode - if(answer.body.code === 502){ + if (answer.body.code === 502) { answer.status = 200 } } From 9ee30f363a4d6645aa0e7ac7612ca666b644590e Mon Sep 17 00:00:00 2001 From: huggy <6511667+makeding@users.noreply.github.com> Date: Fri, 11 Sep 2020 00:17:05 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=8B=20UA?= =?UTF-8?q?=20=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91=20.gitignore=20?= =?UTF-8?q?=E5=BC=84=E5=BE=97=E5=A5=BD=E7=9C=8B=E4=BA=86=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 +--- util/request.js | 70 +++++++++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index 4a4d9a93dec..f284b532d73 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,5 @@ .DS_Store node_modules *.log - -.idea/ - - +.idea .vscode \ No newline at end of file diff --git a/util/request.js b/util/request.js index 251253d93b5..fc4df40972d 100644 --- a/util/request.js +++ b/util/request.js @@ -6,38 +6,46 @@ const zlib = require('zlib') // request.debug = true // 开启可看到更详细信息 -const chooseUserAgent = ua => { - const userAgentList = [ - // iOS 13.5.1 14.0 beta with safari - 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1', - 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.', - // iOS with qq micromsg - 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/602.1.50 (KHTML like Gecko) Mobile/14A456 QQ/6.5.7.408 V1_IPH_SQ_6.5.7_1_APP_A Pixel/750 Core/UIWebView NetType/4G Mem/103', - 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.15(0x17000f27) NetType/WIFI Language/zh', - // Android -> Huawei Xiaomi - 'Mozilla/5.0 (Linux; Android 9; PCT-AL10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.64 HuaweiBrowser/10.0.3.311 Mobile Safari/537.36', - 'Mozilla/5.0 (Linux; U; Android 9; zh-cn; Redmi Note 8 Build/PKQ1.190616.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/71.0.3578.141 Mobile Safari/537.36 XiaoMi/MiuiBrowser/12.5.22', - // Android with qq micromsg - 'Mozilla/5.0 (Linux; Android 10; YAL-AL00 Build/HUAWEIYAL-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.62 XWEB/2581 MMWEBSDK/200801 Mobile Safari/537.36 MMWEBID/3027 MicroMessenger/7.0.18.1740(0x27001235) Process/toolsmp WeChat/arm64 NetType/WIFI Language/zh_CN ABI/arm64', - 'Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; BKK-AL10 Build/HONORBKK-AL10) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/10.6 Mobile Safari/537.36', - // macOS 10.15.6 Firefox / Chrome / Safari - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:80.0) Gecko/20100101 Firefox/80.0', - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.30 Safari/537.36', - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Safari/605.1.15', - // Windows 10 Firefox / Chrome / Edge - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0', - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.30 Safari/537.36', - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/13.10586' - ] - let index = 0 - if (typeof ua == 'undefined') - index = Math.floor(Math.random() * userAgentList.length) - else if (ua === 'mobile') index = Math.floor(Math.random() * 7) - else if (ua === 'pc') index = Math.floor(Math.random() * 5) + 8 - else return ua - return userAgentList[index] +function chooseUserAgent(ua = false) { + // UA 列表要经常更新啊 + const userAgentList = { + mobile: [ + // iOS 13.5.1 14.0 beta with safari + 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1', + 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.', + // iOS with qq micromsg + 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/602.1.50 (KHTML like Gecko) Mobile/14A456 QQ/6.5.7.408 V1_IPH_SQ_6.5.7_1_APP_A Pixel/750 Core/UIWebView NetType/4G Mem/103', + 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.15(0x17000f27) NetType/WIFI Language/zh', + // Android -> Huawei Xiaomi + 'Mozilla/5.0 (Linux; Android 9; PCT-AL10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.64 HuaweiBrowser/10.0.3.311 Mobile Safari/537.36', + 'Mozilla/5.0 (Linux; U; Android 9; zh-cn; Redmi Note 8 Build/PKQ1.190616.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/71.0.3578.141 Mobile Safari/537.36 XiaoMi/MiuiBrowser/12.5.22', + // Android + qq micromsg + 'Mozilla/5.0 (Linux; Android 10; YAL-AL00 Build/HUAWEIYAL-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.62 XWEB/2581 MMWEBSDK/200801 Mobile Safari/537.36 MMWEBID/3027 MicroMessenger/7.0.18.1740(0x27001235) Process/toolsmp WeChat/arm64 NetType/WIFI Language/zh_CN ABI/arm64', + 'Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; BKK-AL10 Build/HONORBKK-AL10) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/10.6 Mobile Safari/537.36', + ], + pc: [ + // macOS 10.15.6 Firefox / Chrome / Safari + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:80.0) Gecko/20100101 Firefox/80.0', + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.30 Safari/537.36', + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Safari/605.1.15', + // Windows 10 Firefox / Chrome / Edge + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0', + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.30 Safari/537.36', + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/13.10586' + // Linux 就算了 + ] + } + let realUserAgentList = [] + if (!ua) + realUserAgentList = (userAgentList.mobile).concat(userAgentList.pc) // concat 把两个 array 合并 + else if (ua == 'mobile') + realUserAgentList = userAgentList.mobile + else if (ua == 'pc') + realUserAgentList = userAgentList.pc + else + return ua // 最后返回自定义的 ua + return realUserAgentList[Math.floor(Math.random() * realUserAgentList.length)] } - const createRequest = (method, url, data, options) => { return new Promise((resolve, reject) => { let headers = { 'User-Agent': chooseUserAgent(options.ua) } From c05c83db14cf9d7f6daf5137c30addec93886641 Mon Sep 17 00:00:00 2001 From: huggy <6511667+makeding@users.noreply.github.com> Date: Fri, 11 Sep 2020 00:32:21 +0800 Subject: [PATCH 3/6] =?UTF-8?q?readme=20=E4=BF=AE=E6=94=B9=E6=88=90=20http?= =?UTF-8?q?s=20=E5=85=8B=E9=9A=86=EF=BC=88=E4=B8=8D=E7=94=A8=E7=99=BB?= =?UTF-8?q?=E5=BD=95=20=E4=BF=AE=E6=94=B9=20/public=20=E5=87=A0=E4=B8=AA?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=BD=91=E9=A1=B5=20=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E4=BA=86=20http://localhost:port/=20public=20=E9=87=8C?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E7=BD=91=E9=A1=B5=20lang=20=E9=83=BD?= =?UTF-8?q?=E6=94=B9=E6=88=90=20zh=20=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 2 +- public/avatar_update.html | 154 +++++++++++++-------------- public/index.html | 30 ++++-- public/playlist_cover_update.html | 166 +++++++++++++++--------------- public/test.html | 119 ++++++++++----------- 5 files changed, 243 insertions(+), 228 deletions(-) diff --git a/README.MD b/README.MD index 957fc00ccd6..95b5731d687 100644 --- a/README.MD +++ b/README.MD @@ -192,7 +192,7 @@ ## 安装 ```shell -$ git clone git@github.com:Binaryify/NeteaseCloudMusicApi.git +$ git clone https://github.com/Binaryify/NeteaseCloudMusicApi.git $ npm install ``` diff --git a/public/avatar_update.html b/public/avatar_update.html index cc3caa299f8..45c2b8284c8 100644 --- a/public/avatar_update.html +++ b/public/avatar_update.html @@ -1,80 +1,82 @@ - -
- - -