mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-07-05 04:38:54 +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
|
||||
|
||||
添加了proxy功能
|
||||
添加了 proxy 功能
|
||||
|
||||
### 2.8.0 | 2018.01.04
|
||||
|
||||
@ -9,7 +18,7 @@
|
||||
|
||||
### 2.7.9 | 2017.12.11
|
||||
|
||||
更新排行榜接口,新增云音乐ACG音乐榜,云音乐嘻哈榜
|
||||
更新排行榜接口 , 新增云音乐 ACG 音乐榜 , 云音乐嘻哈榜
|
||||
|
||||
### 2.7.7 | 2017.11.27
|
||||
|
||||
|
23
app.js
23
app.js
@ -6,17 +6,18 @@ const app = express();
|
||||
let cache = apicache.middleware;
|
||||
|
||||
// 跨域设置
|
||||
// app.all('*', function (req, res, next) {
|
||||
// if (req.path !== '/' && !req.path.includes('.')) {
|
||||
// res.header('Access-Control-Allow-Credentials', true)
|
||||
// // 这里获取 origin 请求头 而不是用 *
|
||||
// res.header('Access-Control-Allow-Origin', req.headers['origin'] || '*')
|
||||
// res.header('Access-Control-Allow-Headers', 'X-Requested-With')
|
||||
// res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS')
|
||||
// res.header('Content-Type', 'application/json;charset=utf-8')
|
||||
// }
|
||||
// next()
|
||||
// })
|
||||
app.all("*", function(req, res, next) {
|
||||
if (req.path !== "/" && !req.path.includes(".")) {
|
||||
res.header("Access-Control-Allow-Credentials", true);
|
||||
// 这里获取 origin 请求头 而不是用 *
|
||||
res.header("Access-Control-Allow-Origin", req.headers["origin"] || "*");
|
||||
res.header("Access-Control-Allow-Headers", "X-Requested-With");
|
||||
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
|
||||
res.header("Content-Type", "application/json;charset=utf-8");
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
const onlyStatus200 = (req, res) => res.statusCode === 200;
|
||||
|
||||
app.use(cache("2 minutes", onlyStatus200));
|
||||
|
1057
docs/README.md
1057
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 crypto = require('crypto')
|
||||
const router = express()
|
||||
const { createWebAPIRequest } = require('../util/util')
|
||||
const express = require("express");
|
||||
const crypto = require("crypto");
|
||||
const router = express();
|
||||
const { createWebAPIRequest } = require("../util/util");
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
const phone = req.query.phone
|
||||
const cookie = req.get('Cookie') ? req.get('Cookie') : ''
|
||||
const md5sum = crypto.createHash('md5')
|
||||
md5sum.update(req.query.password)
|
||||
router.get("/", (req, res) => {
|
||||
const phone = req.query.phone;
|
||||
const cookie = req.get("Cookie") ? req.get("Cookie") : "";
|
||||
const md5sum = crypto.createHash("md5");
|
||||
md5sum.update(req.query.password);
|
||||
const data = {
|
||||
phone: phone,
|
||||
password: md5sum.digest('hex'),
|
||||
rememberLogin: 'true'
|
||||
}
|
||||
password: md5sum.digest("hex"),
|
||||
rememberLogin: "true"
|
||||
};
|
||||
createWebAPIRequest(
|
||||
'music.163.com',
|
||||
'/weapi/login/cellphone',
|
||||
'POST',
|
||||
"music.163.com",
|
||||
"/weapi/login/cellphone",
|
||||
"POST",
|
||||
data,
|
||||
cookie,
|
||||
(music_req, cookie) => {
|
||||
// console.log(music_req)
|
||||
cookie = cookie&&cookie.map(x => x.replace("Domain=.music.163.com", ""))
|
||||
cookie =
|
||||
cookie && cookie.map(x => x.replace("Domain=.music.163.com", ""));
|
||||
res.set({
|
||||
'Set-Cookie': cookie
|
||||
})
|
||||
res.send(music_req)
|
||||
"Set-Cookie": cookie
|
||||
});
|
||||
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 express = require('express')
|
||||
const router = express()
|
||||
const { createWebAPIRequest } = require('../util/util')
|
||||
const http = require("http");
|
||||
const express = require("express");
|
||||
const router = express();
|
||||
const { createWebAPIRequest } = require("../util/util");
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
const cookie = req.get('Cookie') ? req.get('Cookie') : ''
|
||||
let detail, imgurl
|
||||
router.get("/", (req, res) => {
|
||||
const cookie = req.get("Cookie") ? req.get("Cookie") : "";
|
||||
const data = {
|
||||
id: req.query.id,
|
||||
offset: 0,
|
||||
total: true,
|
||||
limit: 1000,
|
||||
n: 1000,
|
||||
csrf_token: ''
|
||||
}
|
||||
csrf_token: ""
|
||||
};
|
||||
|
||||
createWebAPIRequest(
|
||||
'music.163.com',
|
||||
'/weapi/v3/playlist/detail',
|
||||
'POST',
|
||||
"music.163.com",
|
||||
"/weapi/v3/playlist/detail",
|
||||
"POST",
|
||||
data,
|
||||
cookie,
|
||||
music_req => {
|
||||
console.log(music_req)
|
||||
// detail = music_req
|
||||
res.send(music_req)
|
||||
// mergeRes()
|
||||
// console.log(music_req)
|
||||
res.send(music_req);
|
||||
},
|
||||
err => {
|
||||
res.status(502).send('fetch error')
|
||||
res.status(502).send("fetch error");
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// FIXME:i dont know the api to get coverimgurl
|
||||
// so i get it by parsing html
|
||||
@ -62,6 +55,6 @@ router.get('/', (req, res) => {
|
||||
// res.send(detail)
|
||||
// }
|
||||
// }
|
||||
})
|
||||
});
|
||||
|
||||
module.exports = router
|
||||
module.exports = router;
|
||||
|
@ -1,24 +1,27 @@
|
||||
const express = require('express')
|
||||
const router = express()
|
||||
const { createWebAPIRequest } = require('../util/util')
|
||||
const express = require("express");
|
||||
const router = express();
|
||||
const { createWebAPIRequest } = require("../util/util");
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
const cookie = req.get('Cookie') ? req.get('Cookie') : ''
|
||||
router.get("/", (req, res) => {
|
||||
const cookie = req.get("Cookie") ? req.get("Cookie") : "";
|
||||
const data = {
|
||||
offset: 0,
|
||||
offset: req.query.offset || 0,
|
||||
uid: req.query.uid,
|
||||
limit: 1000,
|
||||
csrf_token: ''
|
||||
}
|
||||
limit: req.query.limit || 30, //貌似无效
|
||||
csrf_token: ""
|
||||
};
|
||||
createWebAPIRequest(
|
||||
'music.163.com',
|
||||
'/weapi/user/playlist',
|
||||
'POST',
|
||||
"music.163.com",
|
||||
"/weapi/user/playlist",
|
||||
"POST",
|
||||
data,
|
||||
cookie,
|
||||
music_req => res.send(music_req),
|
||||
err => res.status(502).send('fetch error')
|
||||
)
|
||||
})
|
||||
music_req => {
|
||||
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