NeteaseCloudMusicApi
Advanced tools
Comparing version 1.2.2 to 1.2.3
108
build/app.js
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -19,55 +19,61 @@ exports.api = undefined; | ||
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: 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 (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 = (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)); | ||
} | ||
}); | ||
}, | ||
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/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)); | ||
} | ||
}); | ||
} | ||
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; | ||
exports.api = api; |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -9,7 +9,8 @@ var origin = 'http://music.163.com'; | ||
var globalOption = { | ||
headers: { | ||
'Origin': origin, | ||
'Referer': origin, | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
} | ||
headers: { | ||
'Origin': origin, | ||
'Referer': origin, | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
}, | ||
proxy: false | ||
}; | ||
@@ -16,0 +17,0 @@ |
@@ -0,0 +0,0 @@ "use strict"; |
{ | ||
"name": "NeteaseCloudMusicApi", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "网易云音乐nodejs版接口模块", | ||
@@ -10,3 +10,3 @@ "main": "build/app.js", | ||
}, | ||
"keywords": ["NeteaseCloudMusic","网易云音乐"], | ||
"keywords": ["NeteaseCloudMusic","网易云音乐","网易云"], | ||
"author": "traveller", | ||
@@ -13,0 +13,0 @@ "license": "ISC", |
# NeteaseCloudMusicApi | ||
<a href="https://www.npmjs.com/package/NeteaseCloudMusicApi"><img src="https://img.shields.io/npm/v/NeteaseCloudMusicApi.svg" alt="Version"></a> | ||
一个调用网易云音乐 API 的 node 模块 | ||
@@ -4,0 +4,0 @@ |
@@ -7,21 +7,20 @@ import request from 'request' | ||
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' | ||
let proxy = false | ||
Object.assign(option, { url, form, method, proxy }) | ||
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) | ||
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) | ||
} | ||
}) | ||
}, | ||
@@ -32,4 +31,3 @@ song: (id, callback = null) => { | ||
let method = 'GET' | ||
let proxy = false | ||
Object.assign(option, { url, method, proxy }) | ||
Object.assign(option, { url, method }) | ||
request(option, (error, response, body) => { | ||
@@ -48,4 +46,3 @@ if (!error && response.statusCode == 200) { | ||
let method = 'GET' | ||
let proxy = false | ||
Object.assign(option, { url, method, proxy }) | ||
Object.assign(option, { url, method }) | ||
request(option, (error, response, body) => { | ||
@@ -52,0 +49,0 @@ if (!error && response.statusCode == 200) { |
@@ -8,5 +8,6 @@ const origin = 'http://music.163.com' | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
} | ||
}, | ||
proxy:false | ||
} | ||
export { origin, globalOption } |
@@ -1,3 +0,3 @@ | ||
const deepCopy = (obj) => JSON.parse(JSON.stringify(obj)) | ||
const deepCopy = obj => JSON.parse(JSON.stringify(obj)) | ||
export { deepCopy } |
227
9617