mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-07-05 00:48:55 +08:00
improve
This commit is contained in:
parent
480b1696eb
commit
642d6f5353
13
CHANGELOG.MD
13
CHANGELOG.MD
@ -1,7 +1,16 @@
|
|||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
### 2.8.3 | 2018.01.12
|
||||||
|
|
||||||
|
优化部分功能和文档
|
||||||
|
|
||||||
|
### 2.8.2 | 2018.01.05
|
||||||
|
|
||||||
|
增加 Dockerfile,支持以 Docker 容器模式运行
|
||||||
|
|
||||||
### 2.8.1 | 2018.01.04
|
### 2.8.1 | 2018.01.04
|
||||||
|
|
||||||
添加了proxy功能
|
添加了 proxy 功能
|
||||||
|
|
||||||
### 2.8.0 | 2018.01.04
|
### 2.8.0 | 2018.01.04
|
||||||
|
|
||||||
@ -9,7 +18,7 @@
|
|||||||
|
|
||||||
### 2.7.9 | 2017.12.11
|
### 2.7.9 | 2017.12.11
|
||||||
|
|
||||||
更新排行榜接口,新增云音乐ACG音乐榜,云音乐嘻哈榜
|
更新排行榜接口 , 新增云音乐 ACG 音乐榜 , 云音乐嘻哈榜
|
||||||
|
|
||||||
### 2.7.7 | 2017.11.27
|
### 2.7.7 | 2017.11.27
|
||||||
|
|
||||||
|
23
app.js
23
app.js
@ -6,17 +6,18 @@ const app = express();
|
|||||||
let cache = apicache.middleware;
|
let cache = apicache.middleware;
|
||||||
|
|
||||||
// 跨域设置
|
// 跨域设置
|
||||||
// app.all('*', function (req, res, next) {
|
app.all("*", function(req, res, next) {
|
||||||
// if (req.path !== '/' && !req.path.includes('.')) {
|
if (req.path !== "/" && !req.path.includes(".")) {
|
||||||
// res.header('Access-Control-Allow-Credentials', true)
|
res.header("Access-Control-Allow-Credentials", true);
|
||||||
// // 这里获取 origin 请求头 而不是用 *
|
// 这里获取 origin 请求头 而不是用 *
|
||||||
// res.header('Access-Control-Allow-Origin', req.headers['origin'] || '*')
|
res.header("Access-Control-Allow-Origin", req.headers["origin"] || "*");
|
||||||
// res.header('Access-Control-Allow-Headers', 'X-Requested-With')
|
res.header("Access-Control-Allow-Headers", "X-Requested-With");
|
||||||
// res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS')
|
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
|
||||||
// res.header('Content-Type', 'application/json;charset=utf-8')
|
res.header("Content-Type", "application/json;charset=utf-8");
|
||||||
// }
|
}
|
||||||
// next()
|
next();
|
||||||
// })
|
});
|
||||||
|
|
||||||
const onlyStatus200 = (req, res) => res.statusCode === 200;
|
const onlyStatus200 = (req, res) => res.statusCode === 200;
|
||||||
|
|
||||||
app.use(cache("2 minutes", onlyStatus200));
|
app.use(cache("2 minutes", onlyStatus200));
|
||||||
|
1059
docs/README.md
1059
docs/README.md
File diff suppressed because it is too large
Load Diff
41
public/test.html
Normal file
41
public/test.html
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<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>
|
||||||
|
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
|
||||||
|
<script>
|
||||||
|
$.ajax({
|
||||||
|
url: "http://localhost:3000/login/cellphone?phone=phone&password=password",
|
||||||
|
xhrFields: {
|
||||||
|
withCredentials: true
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
console.log(data)
|
||||||
|
$.ajax({
|
||||||
|
url: "http://localhost:3000/recommend/songs ",
|
||||||
|
xhrFields: {
|
||||||
|
withCredentials: true
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
console.log(data)
|
||||||
|
},
|
||||||
|
error: function (err) {
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
error: function (err) {
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -1,34 +1,34 @@
|
|||||||
const express = require('express')
|
const express = require("express");
|
||||||
const crypto = require('crypto')
|
const crypto = require("crypto");
|
||||||
const router = express()
|
const router = express();
|
||||||
const { createWebAPIRequest } = require('../util/util')
|
const { createWebAPIRequest } = require("../util/util");
|
||||||
|
|
||||||
router.get('/', (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
const phone = req.query.phone
|
const phone = req.query.phone;
|
||||||
const cookie = req.get('Cookie') ? req.get('Cookie') : ''
|
const cookie = req.get("Cookie") ? req.get("Cookie") : "";
|
||||||
const md5sum = crypto.createHash('md5')
|
const md5sum = crypto.createHash("md5");
|
||||||
md5sum.update(req.query.password)
|
md5sum.update(req.query.password);
|
||||||
const data = {
|
const data = {
|
||||||
phone: phone,
|
phone: phone,
|
||||||
password: md5sum.digest('hex'),
|
password: md5sum.digest("hex"),
|
||||||
rememberLogin: 'true'
|
rememberLogin: "true"
|
||||||
}
|
};
|
||||||
createWebAPIRequest(
|
createWebAPIRequest(
|
||||||
'music.163.com',
|
"music.163.com",
|
||||||
'/weapi/login/cellphone',
|
"/weapi/login/cellphone",
|
||||||
'POST',
|
"POST",
|
||||||
data,
|
data,
|
||||||
cookie,
|
cookie,
|
||||||
(music_req, cookie) => {
|
(music_req, cookie) => {
|
||||||
// console.log(music_req)
|
cookie =
|
||||||
cookie = cookie&&cookie.map(x => x.replace("Domain=.music.163.com", ""))
|
cookie && cookie.map(x => x.replace("Domain=.music.163.com", ""));
|
||||||
res.set({
|
res.set({
|
||||||
'Set-Cookie': cookie
|
"Set-Cookie": cookie
|
||||||
})
|
});
|
||||||
res.send(music_req)
|
res.send(music_req);
|
||||||
},
|
},
|
||||||
err => res.status(502).send('fetch error')
|
err => res.status(502).send("fetch error")
|
||||||
)
|
);
|
||||||
})
|
});
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router;
|
||||||
|
@ -1,36 +1,29 @@
|
|||||||
const http = require('http')
|
const http = require("http");
|
||||||
const express = require('express')
|
const express = require("express");
|
||||||
const router = express()
|
const router = express();
|
||||||
const { createWebAPIRequest } = require('../util/util')
|
const { createWebAPIRequest } = require("../util/util");
|
||||||
|
|
||||||
router.get('/', (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
const cookie = req.get('Cookie') ? req.get('Cookie') : ''
|
const cookie = req.get("Cookie") ? req.get("Cookie") : "";
|
||||||
let detail, imgurl
|
|
||||||
const data = {
|
const data = {
|
||||||
id: req.query.id,
|
id: req.query.id,
|
||||||
offset: 0,
|
csrf_token: ""
|
||||||
total: true,
|
};
|
||||||
limit: 1000,
|
|
||||||
n: 1000,
|
|
||||||
csrf_token: ''
|
|
||||||
}
|
|
||||||
|
|
||||||
createWebAPIRequest(
|
createWebAPIRequest(
|
||||||
'music.163.com',
|
"music.163.com",
|
||||||
'/weapi/v3/playlist/detail',
|
"/weapi/v3/playlist/detail",
|
||||||
'POST',
|
"POST",
|
||||||
data,
|
data,
|
||||||
cookie,
|
cookie,
|
||||||
music_req => {
|
music_req => {
|
||||||
console.log(music_req)
|
// console.log(music_req)
|
||||||
// detail = music_req
|
res.send(music_req);
|
||||||
res.send(music_req)
|
|
||||||
// mergeRes()
|
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
res.status(502).send('fetch error')
|
res.status(502).send("fetch error");
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
|
|
||||||
// FIXME:i dont know the api to get coverimgurl
|
// FIXME:i dont know the api to get coverimgurl
|
||||||
// so i get it by parsing html
|
// so i get it by parsing html
|
||||||
@ -62,6 +55,6 @@ router.get('/', (req, res) => {
|
|||||||
// res.send(detail)
|
// res.send(detail)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
})
|
});
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router;
|
||||||
|
@ -1,24 +1,27 @@
|
|||||||
const express = require('express')
|
const express = require("express");
|
||||||
const router = express()
|
const router = express();
|
||||||
const { createWebAPIRequest } = require('../util/util')
|
const { createWebAPIRequest } = require("../util/util");
|
||||||
|
|
||||||
router.get('/', (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
const cookie = req.get('Cookie') ? req.get('Cookie') : ''
|
const cookie = req.get("Cookie") ? req.get("Cookie") : "";
|
||||||
const data = {
|
const data = {
|
||||||
offset: 0,
|
offset: req.query.offset || 0,
|
||||||
uid: req.query.uid,
|
uid: req.query.uid,
|
||||||
limit: 1000,
|
limit: req.query.limit || 30, //貌似无效
|
||||||
csrf_token: ''
|
csrf_token: ""
|
||||||
}
|
};
|
||||||
createWebAPIRequest(
|
createWebAPIRequest(
|
||||||
'music.163.com',
|
"music.163.com",
|
||||||
'/weapi/user/playlist',
|
"/weapi/user/playlist",
|
||||||
'POST',
|
"POST",
|
||||||
data,
|
data,
|
||||||
cookie,
|
cookie,
|
||||||
music_req => res.send(music_req),
|
music_req => {
|
||||||
err => res.status(502).send('fetch error')
|
res.send(music_req);
|
||||||
)
|
// console.log(JSON.parse(music_req))
|
||||||
})
|
},
|
||||||
|
err => res.status(502).send("fetch error")
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user