mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-05-23 22:37:41 +08:00
update
This commit is contained in:
parent
51bb402376
commit
774de65ca5
@ -19,17 +19,17 @@ api.search('年度之歌')
|
||||
# api
|
||||
## search
|
||||
```js
|
||||
api.search(name:String, [limit:Nnumber default:3, offset:Number default:0])
|
||||
api.search(name:String, [callback:function,limit:Nnumber default:3, offset:Number default:0])
|
||||
```
|
||||
|
||||
## lrc
|
||||
```js
|
||||
api.lrc(id:Number, [lv:Number default:-1])
|
||||
api.lrc(id:Number, [callback:function,lv:Number default:-1])
|
||||
```
|
||||
|
||||
## song
|
||||
```js
|
||||
api.song(id:Number)
|
||||
api.song(id:Number,[callback:function])
|
||||
```
|
||||
|
||||
[github](https://github.com/Binaryify/NeteaseCloudMusicApi)
|
||||
|
32
app.js
32
app.js
@ -13,34 +13,42 @@ let globalOption = {
|
||||
}
|
||||
|
||||
let api = {
|
||||
search: (name = null, limit = 3, offset = 0) => {
|
||||
search: (name = null,callback=null, limit = 3, offset = 0) => {
|
||||
let option = deepCopy(globalOption);
|
||||
let url = origin + '/api/search/suggest/web'
|
||||
let body = 's=' + name + '&limit=' + limit + '&type=1&offset=' + offset
|
||||
let method = 'POST'
|
||||
Object.assign(option, { url, body, method })
|
||||
request(option, callback);
|
||||
request(option, (error, response, body)=>{
|
||||
if (!error && response.statusCode == 200) {
|
||||
let info = JSON.parse(body);
|
||||
callback&&callback(JSON.stringify(info, '', 2))
|
||||
}
|
||||
})
|
||||
},
|
||||
song: (id) => {
|
||||
song: (id,callback=null) => {
|
||||
let option = deepCopy(globalOption);
|
||||
let url = origin + '/api/song/detail?ids=%5B' + id + '%5d'
|
||||
let method = 'GET'
|
||||
Object.assign(option, { url, method })
|
||||
request(option, callback);
|
||||
request(option, (error, response, body)=>{
|
||||
if (!error && response.statusCode == 200) {
|
||||
let info = JSON.parse(body);
|
||||
callback&&callback(JSON.stringify(info, '', 2))
|
||||
}
|
||||
})
|
||||
},
|
||||
lrc: (id, lv = -1) => {
|
||||
lrc: (id,callback=null, lv = -1) => {
|
||||
let option = deepCopy(globalOption);
|
||||
let url = origin + '/api/song/lyric?lv=' + lv + '&id=' + id
|
||||
let method = 'GET'
|
||||
Object.assign(option, { url, method })
|
||||
request(option, callback);
|
||||
}
|
||||
}
|
||||
function callback(error, response, body) {
|
||||
// console.log('callback')
|
||||
request(option, (error, response, body)=>{
|
||||
if (!error && response.statusCode == 200) {
|
||||
var info = JSON.parse(body);
|
||||
console.log(JSON.stringify(info, '', 2))
|
||||
let info = JSON.parse(body);
|
||||
callback&&callback(JSON.stringify(info, '', 2))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
export {api}
|
36
build/app.js
36
build/app.js
@ -27,38 +27,50 @@ var globalOption = {
|
||||
var api = {
|
||||
search: function search() {
|
||||
var name = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0];
|
||||
var limit = arguments.length <= 1 || arguments[1] === undefined ? 3 : arguments[1];
|
||||
var offset = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2];
|
||||
var callback = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
|
||||
var limit = arguments.length <= 2 || arguments[2] === undefined ? 3 : arguments[2];
|
||||
var offset = arguments.length <= 3 || arguments[3] === undefined ? 0 : arguments[3];
|
||||
|
||||
var option = deepCopy(globalOption);
|
||||
var url = origin + '/api/search/suggest/web';
|
||||
var body = 's=' + name + '&limit=' + limit + '&type=1&offset=' + offset;
|
||||
var method = 'POST';
|
||||
Object.assign(option, { url: url, body: body, method: method });
|
||||
(0, _request2.default)(option, callback);
|
||||
(0, _request2.default)(option, function (error, response, body) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
var info = JSON.parse(body);
|
||||
callback && callback(JSON.stringify(info, '', 2));
|
||||
}
|
||||
});
|
||||
},
|
||||
song: function song(id) {
|
||||
var callback = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
|
||||
|
||||
var option = deepCopy(globalOption);
|
||||
var url = origin + '/api/song/detail?ids=%5B' + id + '%5d';
|
||||
var method = 'GET';
|
||||
Object.assign(option, { url: url, method: method });
|
||||
(0, _request2.default)(option, callback);
|
||||
(0, _request2.default)(option, function (error, response, body) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
var info = JSON.parse(body);
|
||||
callback && callback(JSON.stringify(info, '', 2));
|
||||
}
|
||||
});
|
||||
},
|
||||
lrc: function lrc(id) {
|
||||
var lv = arguments.length <= 1 || arguments[1] === undefined ? -1 : arguments[1];
|
||||
var callback = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
|
||||
var lv = arguments.length <= 2 || arguments[2] === undefined ? -1 : arguments[2];
|
||||
|
||||
var option = deepCopy(globalOption);
|
||||
var url = origin + '/api/song/lyric?lv=' + lv + '&id=' + id;
|
||||
var method = 'GET';
|
||||
Object.assign(option, { url: url, method: method });
|
||||
(0, _request2.default)(option, callback);
|
||||
}
|
||||
};
|
||||
function callback(error, response, body) {
|
||||
// console.log('callback')
|
||||
(0, _request2.default)(option, function (error, response, body) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
var info = JSON.parse(body);
|
||||
console.log(JSON.stringify(info, '', 2));
|
||||
callback && callback(JSON.stringify(info, '', 2));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.api = api;
|
||||
|
@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "NeteaseCloudMusicApi",
|
||||
"version": "1.0.1",
|
||||
"description": "",
|
||||
"version": "1.0.8",
|
||||
"description": "网易云音乐nodejs版接口模块",
|
||||
"main": "build/app.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "babel app.js -o build/app.js",
|
||||
"check": "node build/test.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"keywords": ["NeteaseCloudMusic","网易云音乐"],
|
||||
"author": "traveller",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user