mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2025-12-08 16:33:09 +00:00
commit
346593e0c3
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,8 +1,5 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules
|
node_modules
|
||||||
*.log
|
*.log
|
||||||
|
.idea
|
||||||
.idea/
|
|
||||||
|
|
||||||
|
|
||||||
.vscode
|
.vscode
|
||||||
@ -192,7 +192,7 @@
|
|||||||
## 安装
|
## 安装
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ git clone git@github.com:Binaryify/NeteaseCloudMusicApi.git
|
$ git clone https://github.com/Binaryify/NeteaseCloudMusicApi.git
|
||||||
$ npm install
|
$ npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="zh">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>更新头像</title>
|
<title>更新头像</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<input id="file" type="file" name="filename" />
|
<input id="file" type="file" name="filename" />
|
||||||
<img id="avatar" style="height: 200px; width: 200px; border-radius: 50%;" />
|
<img id="avatar" style="height: 200px; width: 200px; border-radius: 50%;" />
|
||||||
@ -13,7 +15,6 @@
|
|||||||
<script>
|
<script>
|
||||||
const phone = ''
|
const phone = ''
|
||||||
const password = ''
|
const password = ''
|
||||||
const port = 3000
|
|
||||||
let cookieToken = ''
|
let cookieToken = ''
|
||||||
if (!phone || !password) {
|
if (!phone || !password) {
|
||||||
const msg = '请设置你的手机号码和密码'
|
const msg = '请设置你的手机号码和密码'
|
||||||
@ -33,14 +34,14 @@
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
const res = await axios({
|
const res = await axios({
|
||||||
url: `http://localhost:${port}/user/detail?uid=32953014×tamp=${Date.now()}`,
|
url: `/user/detail?uid=32953014×tamp=${Date.now()}`,
|
||||||
withCredentials: true, //关键
|
withCredentials: true, //关键
|
||||||
})
|
})
|
||||||
document.querySelector('#avatar').src = res.data.profile.avatarUrl
|
document.querySelector('#avatar').src = res.data.profile.avatarUrl
|
||||||
}
|
}
|
||||||
async function login() {
|
async function login() {
|
||||||
const res = await axios({
|
const res = await axios({
|
||||||
url: `http://localhost:${port}/login/cellphone?phone=${phone}&password=${password}`,
|
url: `/login/cellphone?phone=${phone}&password=${password}`,
|
||||||
withCredentials: true, //关键
|
withCredentials: true, //关键
|
||||||
})
|
})
|
||||||
cookieToken = res.data.cookie
|
cookieToken = res.data.cookie
|
||||||
@ -77,4 +78,5 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@ -1,11 +1,13 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html lang="zh">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<title>网易云音乐 API</title>
|
<title>网易云音乐 API</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>网易云音乐 API</h1>
|
<h1>网易云音乐 API</h1>
|
||||||
当你看到这个页面时,这个服务已经成功跑起来了~
|
当你看到这个页面时,这个服务已经成功跑起来了~
|
||||||
@ -17,7 +19,8 @@
|
|||||||
<li>3. <a href="/dj/program?rid=336355127">电台节目</a></li>
|
<li>3. <a href="/dj/program?rid=336355127">电台节目</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<style>
|
<style>
|
||||||
html,body{
|
html,
|
||||||
|
body {
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -27,22 +30,29 @@
|
|||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
color: rgb(100, 100, 100);
|
color: rgb(100, 100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #42b983;
|
color: #42b983;
|
||||||
}
|
}
|
||||||
ul,li{
|
|
||||||
|
ul,
|
||||||
|
li {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
margin-left: -40px;
|
margin-left: -40px;
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
li {
|
li {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@ -1,10 +1,12 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="zh">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>歌单封面上传</title>
|
<title>歌单封面上传</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<input id="file" type="file" name="filename" />
|
<input id="file" type="file" name="filename" />
|
||||||
@ -15,7 +17,6 @@
|
|||||||
const phone = ''
|
const phone = ''
|
||||||
const password = ''
|
const password = ''
|
||||||
const playlist_id = ''
|
const playlist_id = ''
|
||||||
const port = 3000
|
|
||||||
let cookieToken = ''
|
let cookieToken = ''
|
||||||
if (!phone || !password) {
|
if (!phone || !password) {
|
||||||
const msg = '请设置你的手机号码和密码'
|
const msg = '请设置你的手机号码和密码'
|
||||||
@ -40,13 +41,13 @@
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
const res = await axios({
|
const res = await axios({
|
||||||
url: `http://localhost:${port}/playlist/detail?id=${playlist_id}×tamp=${Date.now()}`,
|
url: `/playlist/detail?id=${playlist_id}×tamp=${Date.now()}`,
|
||||||
})
|
})
|
||||||
document.querySelector('#playlist_cover').src = res.data.playlist.coverImgUrl
|
document.querySelector('#playlist_cover').src = res.data.playlist.coverImgUrl
|
||||||
}
|
}
|
||||||
async function login() {
|
async function login() {
|
||||||
const res = await axios({
|
const res = await axios({
|
||||||
url: `http://localhost:${port}/login/cellphone?phone=${phone}&password=${password}`,
|
url: `/login/cellphone?phone=${phone}&password=${password}`,
|
||||||
withCredentials: true, //关键
|
withCredentials: true, //关键
|
||||||
})
|
})
|
||||||
cookieToken = res.data.cookie
|
cookieToken = res.data.cookie
|
||||||
@ -83,4 +84,5 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="zh">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
@ -14,21 +15,20 @@
|
|||||||
<script>
|
<script>
|
||||||
const phone = ''
|
const phone = ''
|
||||||
const password = ''
|
const password = ''
|
||||||
const port = 3000
|
|
||||||
if (!phone || !password) {
|
if (!phone || !password) {
|
||||||
const msg = '请设置你的手机号码和密码'
|
const msg = '请设置你的手机号码和密码'
|
||||||
alert(msg)
|
alert(msg)
|
||||||
throw new Error(msg)
|
throw new Error(msg)
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `http://localhost:${port}/login/cellphone?phone=${phone}&password=${password}`,
|
url: `/login/cellphone?phone=${phone}&password=${password}`,
|
||||||
xhrFields: {
|
xhrFields: {
|
||||||
withCredentials: true //关键
|
withCredentials: true //关键
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
console.log(data)
|
console.log(data)
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `http://localhost:${port}/recommend/resource `,
|
url: `/recommend/resource `,
|
||||||
xhrFields: {
|
xhrFields: {
|
||||||
withCredentials: true //关键
|
withCredentials: true //关键
|
||||||
},
|
},
|
||||||
@ -46,12 +46,12 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
axios({
|
axios({
|
||||||
url: `http://localhost:${port}/login/cellphone?phone=${phone}&password=${password}`,
|
url: `/login/cellphone?phone=${phone}&password=${password}`,
|
||||||
withCredentials: true //关键
|
withCredentials: true //关键
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
console.log(res.data)
|
console.log(res.data)
|
||||||
axios({
|
axios({
|
||||||
url: `http://localhost:${port}/recommend/resource`,
|
url: `/recommend/resource`,
|
||||||
withCredentials: true //关键
|
withCredentials: true //关键
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
console.log(res.data)
|
console.log(res.data)
|
||||||
@ -59,4 +59,5 @@
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@ -6,32 +6,38 @@ const zlib = require('zlib')
|
|||||||
|
|
||||||
// request.debug = true // 开启可看到更详细信息
|
// request.debug = true // 开启可看到更详细信息
|
||||||
|
|
||||||
const chooseUserAgent = ua => {
|
const chooseUserAgent = (ua = false) => {
|
||||||
const userAgentList = [
|
// UA 列表要经常更新啊
|
||||||
'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',
|
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',
|
mobile: [
|
||||||
'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',
|
// iOS 13.5.1 14.0 beta with safari
|
||||||
'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 (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 (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 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.',
|
||||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Mobile/14F89;GameHelper',
|
// iOS with qq micromsg
|
||||||
'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 (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 (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 (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',
|
||||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:46.0) Gecko/20100101 Firefox/46.0',
|
// Android -> Huawei Xiaomi
|
||||||
'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 (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 (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 (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',
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:46.0) Gecko/20100101 Firefox/46.0',
|
// Android + qq micromsg
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
|
'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'
|
'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 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]
|
|
||||||
}
|
}
|
||||||
|
let realUserAgentList = userAgentList[ua] || (userAgentList.mobile).concat(userAgentList.pc)
|
||||||
|
return (['mobile', 'pc', false].indexOf(ua) > -1) ? realUserAgentList[Math.floor(Math.random() * realUserAgentList.length)] : ua
|
||||||
|
}
|
||||||
const createRequest = (method, url, data, options) => {
|
const createRequest = (method, url, data, options) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let headers = { 'User-Agent': chooseUserAgent(options.ua) }
|
let headers = { 'User-Agent': chooseUserAgent(options.ua) }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user