mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 05:38:04 +00:00
fix: add netease_api
This commit is contained in:
parent
fc0367c9b4
commit
0b701d23da
304 changed files with 27205 additions and 1 deletions
82
netease_api/public/avatar_update.html
Normal file
82
netease_api/public/avatar_update.html
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>更新头像</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<input id="file" type="file" />
|
||||
<img id="avatar" style="height: 200px; width: 200px; border-radius: 50%" />
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js
|
||||
"></script>
|
||||
<script>
|
||||
const phone = ''
|
||||
const password = ''
|
||||
let cookieToken = ''
|
||||
if (!phone || !password) {
|
||||
const msg = '请设置你的手机号码和密码'
|
||||
alert(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
|
||||
main()
|
||||
login()
|
||||
async function main() {
|
||||
document.querySelector('input[type="file"]').addEventListener(
|
||||
'change',
|
||||
function (e) {
|
||||
var file = this.files[0]
|
||||
upload(file)
|
||||
},
|
||||
false,
|
||||
)
|
||||
const res = await axios({
|
||||
url: `/user/detail?uid=32953014×tamp=${Date.now()}`,
|
||||
withCredentials: true, //关键
|
||||
})
|
||||
document.querySelector('#avatar').src = res.data.profile.avatarUrl
|
||||
}
|
||||
async function login() {
|
||||
const res = await axios({
|
||||
url: `/login/cellphone?phone=${phone}&password=${password}`,
|
||||
withCredentials: true, //关键
|
||||
})
|
||||
cookieToken = res.data.cookie
|
||||
}
|
||||
async function upload(file) {
|
||||
var formData = new FormData()
|
||||
formData.append('imgFile', file)
|
||||
const imgSize = await getImgSize(file)
|
||||
const res = await axios({
|
||||
method: 'post',
|
||||
url: `http://localhost:3000/avatar/upload?cookie=${cookieToken}&imgSize=${
|
||||
imgSize.width
|
||||
}&imgX=0&imgY=0×tamp=${Date.now()}`,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
data: formData,
|
||||
})
|
||||
document.querySelector('#avatar').src = res.data.data.url
|
||||
}
|
||||
function getImgSize(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let reader = new FileReader()
|
||||
reader.readAsDataURL(file)
|
||||
reader.onload = function (theFile) {
|
||||
let image = new Image()
|
||||
image.src = theFile.target.result
|
||||
image.onload = function () {
|
||||
resolve({
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
78
netease_api/public/cloud.html
Normal file
78
netease_api/public/cloud.html
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>云盘上传</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<input id="file" type="file" multiple/>
|
||||
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js"></script>
|
||||
<script>
|
||||
const phone = '' // 这里填手机号
|
||||
const password = '' // 这里填密码
|
||||
const fileUpdateTime = {}
|
||||
let fileLength = 0
|
||||
let cookieToken = ''
|
||||
if (!phone || !password) {
|
||||
const msg = '请设置你的手机号码和密码'
|
||||
alert(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
login()
|
||||
main()
|
||||
async function login() {
|
||||
const res = await axios({
|
||||
url: `/login/cellphone?phone=${phone}&password=${encodeURIComponent(password)}`,
|
||||
withCredentials: true, //关键
|
||||
})
|
||||
cookieToken = res.data.cookie
|
||||
}
|
||||
function main() {
|
||||
document
|
||||
.querySelector('input[type="file"]')
|
||||
.addEventListener('change', function (e) {
|
||||
console.log(this.files)
|
||||
let currentIndx = 0
|
||||
fileLength = this.files.length
|
||||
for (const item of this.files) {
|
||||
currentIndx += 1
|
||||
upload(item, currentIndx)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function upload(file, currentIndx) {
|
||||
var formData = new FormData()
|
||||
formData.append('songFile', file)
|
||||
axios({
|
||||
method: 'post',
|
||||
url: `http://localhost:3000/cloud?time=${Date.now()}`,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
data: formData,
|
||||
}).then(res => {
|
||||
console.log(`${file.name} 上传成功`)
|
||||
if (currentIndx >= fileLength) { console.log('上传完毕') }
|
||||
}).catch(async err => {
|
||||
console.log(err)
|
||||
console.log(fileUpdateTime)
|
||||
fileUpdateTime[file.name] ? fileUpdateTime[file.name] += 1 : fileUpdateTime[file.name] = 1
|
||||
if (fileUpdateTime[file.name] >= 4) {
|
||||
console.error(`丢,这首歌怎么都传不上:${file.name}`)
|
||||
return
|
||||
} else {
|
||||
console.error(`${file.name} 失败 ${fileUpdateTime[file.name]} 次`)
|
||||
}
|
||||
await login()
|
||||
upload(file, currentIndx)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
58
netease_api/public/index.html
Normal file
58
netease_api/public/index.html
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>网易云音乐 API</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>网易云音乐 API</h1>
|
||||
当你看到这个页面时,这个服务已经成功跑起来了~
|
||||
<a href="https://neteasecloudmusicapi.vercel.app">查看文档</a>
|
||||
<h2>例子:</h2>
|
||||
<ul>
|
||||
<li>1. <a href="/search?keywords=海阔天空">搜索</a></li>
|
||||
<li>2. <a href="/comment/music?id=186016&limit=1">歌曲评论</a></li>
|
||||
<li>3. <a href="/dj/program?rid=336355127">电台节目</a></li>
|
||||
</ul>
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #ffffff;
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
* {
|
||||
color: rgb(100, 100, 100);
|
||||
}
|
||||
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
|
||||
ul,
|
||||
li {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
ul {
|
||||
margin-left: -40px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
li {
|
||||
list-style: none;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
89
netease_api/public/playlist_cover_update.html
Normal file
89
netease_api/public/playlist_cover_update.html
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>歌单封面上传</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<input id="file" type="file" name="filename" />
|
||||
<img
|
||||
id="playlist_cover"
|
||||
style="height: 200px; width: 200px; border-radius: 50%"
|
||||
/>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js"></script>
|
||||
<script>
|
||||
const phone = ''
|
||||
const password = ''
|
||||
const playlist_id = ''
|
||||
let cookieToken = ''
|
||||
if (!phone || !password) {
|
||||
const msg = '请设置你的手机号码和密码'
|
||||
alert(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
if (!playlist_id) {
|
||||
const msg = '请设置你的歌单id'
|
||||
alert(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
|
||||
main()
|
||||
login()
|
||||
async function main() {
|
||||
document.querySelector('input[type="file"]').addEventListener(
|
||||
'change',
|
||||
function (e) {
|
||||
var file = this.files[0]
|
||||
upload(file)
|
||||
},
|
||||
false,
|
||||
)
|
||||
const res = await axios({
|
||||
url: `/playlist/detail?id=${playlist_id}×tamp=${Date.now()}`,
|
||||
})
|
||||
document.querySelector('#playlist_cover').src = res.data.playlist.coverImgUrl
|
||||
}
|
||||
async function login() {
|
||||
const res = await axios({
|
||||
url: `/login/cellphone?phone=${phone}&password=${password}`,
|
||||
withCredentials: true, //关键
|
||||
})
|
||||
cookieToken = res.data.cookie
|
||||
}
|
||||
async function upload(file) {
|
||||
var formData = new FormData()
|
||||
formData.append('imgFile', file)
|
||||
const imgSize = await getImgSize(file)
|
||||
const res = await axios({
|
||||
method: 'post',
|
||||
url: `http://localhost:3000/playlist/cover/update?id=${playlist_id}&cookie=${cookieToken}&imgSize=${
|
||||
imgSize.width
|
||||
}&imgX=0&imgY=0×tamp=${Date.now()}`,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
data: formData,
|
||||
})
|
||||
document.querySelector('#playlist_cover').src = res.data.data.url
|
||||
}
|
||||
function getImgSize(file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let reader = new FileReader()
|
||||
reader.readAsDataURL(file)
|
||||
reader.onload = function (theFile) {
|
||||
let image = new Image()
|
||||
image.src = theFile.target.result
|
||||
image.onload = function () {
|
||||
resolve({
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
66
netease_api/public/qrlogin.html
Normal file
66
netease_api/public/qrlogin.html
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>二维码登录</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<img id="qrImg" />
|
||||
<div id="info" class="info"></div>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js
|
||||
"></script>
|
||||
<script>
|
||||
async function checkStatus(key) {
|
||||
const res = await axios({
|
||||
url: `/login/qr/check?key=${key}&timerstamp=${Date.now()}`,
|
||||
withCredentials: true, //关键
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
async function getLoginStatus() {
|
||||
const res = await axios({
|
||||
url: `/login/status?timerstamp=${Date.now()}`,
|
||||
withCredentials: true, //关键
|
||||
})
|
||||
document.querySelector('#info').innerText = JSON.stringify(res.data, null, 2)
|
||||
}
|
||||
async function login() {
|
||||
let timer
|
||||
let timestamp = Date.now()
|
||||
this.getLoginStatus()
|
||||
const res = await axios({
|
||||
url: `/login/qr/key?timerstamp=${Date.now()}`,
|
||||
withCredentials: true, //关键
|
||||
})
|
||||
const key = res.data.data.unikey
|
||||
const res2 = await axios({
|
||||
url: `/login/qr/create?key=${key}&qrimg=true&timerstamp=${Date.now()}`,
|
||||
withCredentials: true, //关键
|
||||
})
|
||||
document.querySelector('#qrImg').src = res2.data.data.qrimg
|
||||
|
||||
timer = setInterval(async () => {
|
||||
const statusRes = await this.checkStatus(key)
|
||||
if (statusRes.code === 800) {
|
||||
alert('二维码已过期,请重新获取')
|
||||
clearInterval(timer)
|
||||
}
|
||||
if (statusRes.code === 803) {
|
||||
// 这一步会返回cookie
|
||||
clearInterval(timer)
|
||||
alert('授权登录成功')
|
||||
await this.getLoginStatus()
|
||||
}
|
||||
}, 3000)
|
||||
}
|
||||
login()
|
||||
</script>
|
||||
<style>
|
||||
.info{
|
||||
white-space: pre;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
63
netease_api/public/test.html
Normal file
63
netease_api/public/test.html
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>test</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>请在控制台看结果</p>
|
||||
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
|
||||
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
|
||||
<script>
|
||||
const phone = ''
|
||||
const password = ''
|
||||
if (!phone || !password) {
|
||||
const msg = '请设置你的手机号码和密码'
|
||||
alert(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
$.ajax({
|
||||
url: `/login/cellphone?phone=${phone}&password=${password}`,
|
||||
xhrFields: {
|
||||
withCredentials: true, //关键
|
||||
},
|
||||
success: function (data) {
|
||||
console.log(data)
|
||||
$.ajax({
|
||||
url: `/recommend/resource `,
|
||||
xhrFields: {
|
||||
withCredentials: true, //关键
|
||||
},
|
||||
success: function (data) {
|
||||
console.log(data)
|
||||
},
|
||||
error: function (err) {
|
||||
console.log(err)
|
||||
},
|
||||
})
|
||||
},
|
||||
error: function (err) {
|
||||
console.log(err)
|
||||
},
|
||||
})
|
||||
|
||||
axios({
|
||||
url: `/login/cellphone?phone=${phone}&password=${password}`,
|
||||
withCredentials: true, //关键
|
||||
}).then(function (res) {
|
||||
console.log(res.data)
|
||||
axios({
|
||||
url: `/recommend/resource`,
|
||||
withCredentials: true, //关键
|
||||
}).then(function (res) {
|
||||
console.log(res.data)
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue