This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from rccoder/master
add getArtistAblums and getAblums & Update README & Update test & rep…
- Loading branch information
Showing
14 changed files
with
345 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,15 @@ | ||
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} |
Oops, something went wrong.