提交 7890e4a0 编写于 作者: R rccoder

add getArtistAblums and getAblums & Update README & Update test & replan directory

上级 5fb70c37
......@@ -29,21 +29,33 @@ api.search('年度之歌',data => {
## API
### search
``` javascript
api.search(name:String,[callback:function,limit:Nnumber default:3, offset:Number default:0])
```
``` javascript
api.search(name:String,[callback:function,limit:Number default:3, offset:Number default:0])
```
### lrc
``` javascript
``` javascript
api.lrc(id:Number,[callback:function,lv:Number default:-1])
```
```
### song
``` javascript
``` javascript
api.song(id:Number,[callback:function])
```
## Download
```
### getArtistAlbums
``` javascript
api.getArtistAlbums(id:Number,[callback:function,limit:Number default:3, offset:Number default:0])
```
## getAlbums
``` javascript
api.getAlbums(id:Number,[callback:function])
```
[github](https://github.com/Binaryify/NeteaseCloudMusicApi)
[npm](https://www.npmjs.com/package/NeteaseCloudMusicApi)
## License
[The MIT License (MIT)]('./LICENSE')
......@@ -5,74 +5,22 @@ Object.defineProperty(exports, "__esModule", {
});
exports.api = undefined;
var _request = require('request');
var _search = require('./component/search');
var _request2 = _interopRequireDefault(_request);
var _song = require('./component/song');
var _config = require('./config');
var _lrc = require('./component/lrc');
var _util = require('./util');
var _getArtistAlbums = require('./component/getArtistAlbums');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _getAlbums = require('./component/getAlbums');
var api = {
search: function search() {
var name = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0];
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];
search: _search.search,
song: _song.song,
lrc: _lrc.lrc,
getArtistAlbums: _getArtistAlbums.getArtistAlbums,
getAlbums: _getAlbums.getAlbums
var option = (0, _util.deepCopy)(_config.globalOption);
var url = _config.origin + '/api/search/suggest/web';
var form = {
s: name,
limit: limit,
type: 1,
offset: offset
};
var method = 'POST';
Object.assign(option, { url: url, form: form, method: method });
(0, _request2.default)(option, function (error, response, body) {
if (!error && response.statusCode == 200) {
var info = JSON.parse(body);
callback && callback(JSON.stringify(info, '', 2));
} else {
console.log(error);
}
});
},
song: function song(id) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
var option = (0, _util.deepCopy)(_config.globalOption);
var url = _config.origin + '/api/song/detail?ids=%5B' + id + '%5d';
var method = 'GET';
Object.assign(option, { url: url, method: method });
(0, _request2.default)(option, function (error, response, body) {
if (!error && response.statusCode == 200) {
var info = JSON.parse(body);
callback && callback(JSON.stringify(info, '', 2));
} else {
console.log(error);
}
});
},
lrc: function lrc(id) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
var lv = arguments.length <= 2 || arguments[2] === undefined ? -1 : arguments[2];
var option = (0, _util.deepCopy)(_config.globalOption);
var url = _config.origin + '/api/song/lyric?lv=' + lv + '&id=' + id;
var method = 'GET';
Object.assign(option, { url: url, method: method });
(0, _request2.default)(option, function (error, response, body) {
if (!error && response.statusCode == 200) {
var info = JSON.parse(body);
callback && callback(JSON.stringify(info, '', 2));
} else {
console.log(error);
}
});
}
};
exports.api = api;
\ No newline at end of file
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getAlbums = undefined;
var _request = require('request');
var _request2 = _interopRequireDefault(_request);
var _config = require('../config');
var _util = require('../util');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var getAlbums = function getAlbums(id, callback) {
var option = (0, _util.deepCopy)(_config.globalOption);
var url = _config.origin + '/api/album/' + id;
var method = 'get';
Object.assign(option, { url: url, method: method });
(0, _request2.default)(option, function (err, res, body) {
if (!err && res.statusCode == 200) {
var info = JSON.parse(body);
callback && callback(JSON.stringify(info, '', 2));
} else {
console.error(err);
}
});
};
exports.getAlbums = getAlbums;
\ No newline at end of file
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getArtistAlbums = undefined;
var _request = require('request');
var _request2 = _interopRequireDefault(_request);
var _config = require('../config');
var _util = require('../util');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var getArtistAlbums = function getArtistAlbums(id, callback) {
var limit = arguments.length <= 2 || arguments[2] === undefined ? 3 : arguments[2];
var offset = arguments.length <= 3 || arguments[3] === undefined ? 0 : arguments[3];
var option = (0, _util.deepCopy)(_config.globalOption);
var url = _config.origin + '/api/artist/albums/' + id + '?offset=' + offset + '&limit=' + limit;
var method = 'GET';
Object.assign(option, { url: url, method: method });
(0, _request2.default)(option, function (err, res, body) {
if (!err && res.statusCode == 200) {
var info = JSON.parse(body);
callback && callback(JSON.stringify(info, '', 2));
} else {
console.error(err);
}
});
};
exports.getArtistAlbums = getArtistAlbums;
\ No newline at end of file
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.lrc = undefined;
var _request = require('request');
var _request2 = _interopRequireDefault(_request);
var _config = require('../config');
var _util = require('../util');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var lrc = function lrc(id) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
var lv = arguments.length <= 2 || arguments[2] === undefined ? -1 : arguments[2];
var option = (0, _util.deepCopy)(_config.globalOption);
var url = _config.origin + '/api/song/lyric?lv=' + lv + '&id=' + id;
var method = 'GET';
Object.assign(option, { url: url, method: method });
(0, _request2.default)(option, function (err, res, body) {
if (!err && res.statusCode == 200) {
var info = JSON.parse(body);
callback && callback(JSON.stringify(info, '', 2));
} else {
console.error(err);
}
});
};
exports.lrc = lrc;
\ No newline at end of file
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.search = undefined;
var _request = require('request');
var _request2 = _interopRequireDefault(_request);
var _config = require('../config');
var _util = require('../util');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var search = function search() {
var name = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0];
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 = (0, _util.deepCopy)(_config.globalOption);
var url = _config.origin + '/api/search/suggest/web';
var form = {
s: name,
limit: limit,
type: 1,
offset: offset
};
var method = 'POST';
Object.assign(option, { url: url, form: form, method: method });
(0, _request2.default)(option, function (err, res, body) {
if (!err && res.statusCode == 200) {
var info = JSON.parse(body);
callback && callback(JSON.stringify(info, '', 2));
} else {
console.error(err);
}
});
};
exports.search = search;
\ No newline at end of file
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.song = undefined;
var _request = require('request');
var _request2 = _interopRequireDefault(_request);
var _config = require('../config');
var _util = require('../util');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var song = function song(id) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1];
var option = (0, _util.deepCopy)(_config.globalOption);
var url = _config.origin + '/api/song/detail?ids=%5B' + id + '%5d';
var method = 'GET';
Object.assign(option, { url: url, method: method });
(0, _request2.default)(option, function (err, res, body) {
if (!err && res.statusCode == 200) {
var info = JSON.parse(body);
callback && callback(JSON.stringify(info, '', 2));
} else {
console.error(err);
}
});
};
exports.song = song;
\ No newline at end of file
import request from 'request'
import { origin, globalOption } from './config'
import { deepCopy } from './util'
import { search } from './component/search'
import { song } from './component/song'
import { lrc } from './component/lrc'
import { getArtistAlbums } from './component/getArtistAlbums'
import { getAlbums } from './component/getAlbums'
let api = {
search: (name = null, callback = null, limit = 3, offset = 0) => {
let option = deepCopy(globalOption)
let url = origin + '/api/search/suggest/web'
let form = {
s: name,
limit,
type: 1,
offset
}
let method = 'POST'
Object.assign(option, { url, form, method })
request(option, (error, response, body) => {
if (!error && response.statusCode == 200) {
let info = JSON.parse(body);
callback && callback(JSON.stringify(info, '', 2))
} else {
console.log(error)
}
})
},
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, (error, response, body) => {
if (!error && response.statusCode == 200) {
let info = JSON.parse(body);
callback && callback(JSON.stringify(info, '', 2))
} else {
console.log(error)
}
})
},
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, (error, response, body) => {
if (!error && response.statusCode == 200) {
let info = JSON.parse(body);
callback && callback(JSON.stringify(info, '', 2))
} else {
console.log(error)
}
})
}
search: search,
song: song,
lrc: lrc,
getArtistAlbums: getArtistAlbums,
getAlbums: getAlbums
}
export {api}
import request from 'request'
import { origin, globalOption } from '../config'
import { deepCopy } from '../util'
const getAlbums = (id, callback) => {
const option = deepCopy(globalOption)
const url = `${origin}/api/album/${id}`
const method = 'get'
Object.assign(option, {url, method})
request(option, (err, res, body) => {
if(!err && res.statusCode == 200) {
let info = JSON.parse(body)
callback && callback(JSON.stringify(info, '', 2))
} else {
console.error(err);
}
})
}
export { getAlbums }
import request from 'request'
import { origin, globalOption } from '../config'
import { deepCopy } from '../util'
const getArtistAlbums = (id, callback, limit = 3, offset = 0) => {
const option = deepCopy(globalOption)
const url = `${origin}/api/artist/albums/${id}?offset=${offset}&limit=${limit}`
const method = 'GET'
Object.assign(option, {url, method})
request(option, (err, res, body) => {
if(!err && res.statusCode == 200) {
let info = JSON.parse(body)
callback && callback(JSON.stringify(info, '', 2))
} else {
console.error(err);
}
})
}
export { getArtistAlbums }
import request from 'request'
import { origin, globalOption } from '../config'
import { deepCopy } from '../util'
const lrc = (id, callback = null, lv = -1) => {
const option = deepCopy(globalOption)
const url = `${origin}/api/song/lyric?lv=${lv}&id=${id}`
const method = 'GET'
Object.assign(option, { url, method })
request(option, (err, res, body) => {
if (!err && res.statusCode == 200) {
let info = JSON.parse(body)
callback && callback(JSON.stringify(info, '', 2))
} else {
console.error(err)
}
})
}
export { lrc }
import request from 'request'
import { origin, globalOption } from '../config'
import { deepCopy } from '../util'
const search = (name = null, callback = null, limit = 3, offset = 0) => {
const option = deepCopy(globalOption)
const url = `${origin}/api/search/suggest/web`
const form = {
s: name,
limit,
type: 1,
offset
}
const method = 'POST'
Object.assign(option, { url, form, method })
request(option, (err, res, body) => {
if (!err && res.statusCode == 200) {
let info = JSON.parse(body);
callback && callback(JSON.stringify(info, '', 2))
} else {
console.error(err)
}
})
}
export { search }
import request from 'request'
import { origin, globalOption } from '../config'
import { deepCopy } from '../util'
const song = (id, callback = null) => {
const option = deepCopy(globalOption)
const url = `${origin}/api/song/detail?ids=%5B${id}%5d`
const method = 'GET'
Object.assign(option, { url, method })
request(option, (err, res, body) => {
if (!err && res.statusCode == 200) {
let info = JSON.parse(body);
callback && callback(JSON.stringify(info, '', 2))
} else {
console.error(err)
}
})
}
export { song }
import { api } from '../src/app.js'
api.search("年度之歌",data=>{
api.search("年度之歌",data => {
console.log("################Search API#################")
console.log(data)
})
api.song('308169',data=>{
api.song('308169',data => {
console.log("################Song API#################")
console.log(data)
})
api.lrc('5243023',data => {
console.log("################Lrc API#################")
console.log(data)
})
api.lrc('5243023',data=>{
api.getArtistAlbums('9952', data => {
console.log('####################Artist Albums##############')
console.log(data)
})
api.getAlbums('32311', data => {
console.log("####################Albums####################")
console.log(data)
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册