mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-07-03 22:32:09 +08:00
update
This commit is contained in:
parent
f3404ce41f
commit
2093fea6a1
29
app.js
29
app.js
@ -1,5 +1,5 @@
|
|||||||
import request from 'request'
|
import request from 'request'
|
||||||
const deepCopy=(obj)=>JSON.parse(JSON.stringify(obj))
|
const deepCopy = (obj) => JSON.parse(JSON.stringify(obj))
|
||||||
const origin = 'http://music.163.com'
|
const origin = 'http://music.163.com'
|
||||||
let globalOption = {
|
let globalOption = {
|
||||||
headers: {
|
headers: {
|
||||||
@ -9,40 +9,45 @@ let globalOption = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let api = {
|
let api = {
|
||||||
search: (name = null,callback=null, limit = 3, offset = 0) => {
|
search: (name = null, callback = null, limit = 3, offset = 0) => {
|
||||||
let option = deepCopy(globalOption);
|
let option = deepCopy(globalOption);
|
||||||
let url = origin + '/api/search/suggest/web'
|
let url = origin + '/api/search/suggest/web'
|
||||||
let body = 's=' + name + '&limit=' + limit + '&type=1&offset=' + offset
|
let form = {
|
||||||
|
s: name,
|
||||||
|
limit,
|
||||||
|
type: 1,
|
||||||
|
offset
|
||||||
|
}
|
||||||
let method = 'POST'
|
let method = 'POST'
|
||||||
Object.assign(option, { url, body, method })
|
Object.assign(option, { url, form, method })
|
||||||
request(option, (error, response, body)=>{
|
request(option, (error, response, body) => {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
let info = JSON.parse(body);
|
let info = JSON.parse(body);
|
||||||
callback&&callback(JSON.stringify(info, '', 2))
|
callback && callback(JSON.stringify(info, '', 2))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
song: (id,callback=null) => {
|
song: (id, callback = null) => {
|
||||||
let option = deepCopy(globalOption);
|
let option = deepCopy(globalOption);
|
||||||
let url = origin + '/api/song/detail?ids=%5B' + id + '%5d'
|
let url = origin + '/api/song/detail?ids=%5B' + id + '%5d'
|
||||||
let method = 'GET'
|
let method = 'GET'
|
||||||
Object.assign(option, { url, method })
|
Object.assign(option, { url, method })
|
||||||
request(option, (error, response, body)=>{
|
request(option, (error, response, body) => {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
let info = JSON.parse(body);
|
let info = JSON.parse(body);
|
||||||
callback&&callback(JSON.stringify(info, '', 2))
|
callback && callback(JSON.stringify(info, '', 2))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
lrc: (id,callback=null, lv = -1) => {
|
lrc: (id, callback = null, lv = -1) => {
|
||||||
let option = deepCopy(globalOption);
|
let option = deepCopy(globalOption);
|
||||||
let url = origin + '/api/song/lyric?lv=' + lv + '&id=' + id
|
let url = origin + '/api/song/lyric?lv=' + lv + '&id=' + id
|
||||||
let method = 'GET'
|
let method = 'GET'
|
||||||
Object.assign(option, { url, method })
|
Object.assign(option, { url, method })
|
||||||
request(option, (error, response, body)=>{
|
request(option, (error, response, body) => {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
let info = JSON.parse(body);
|
let info = JSON.parse(body);
|
||||||
callback&&callback(JSON.stringify(info, '', 2))
|
callback && callback(JSON.stringify(info, '', 2))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,14 @@ var api = {
|
|||||||
|
|
||||||
var option = deepCopy(globalOption);
|
var option = deepCopy(globalOption);
|
||||||
var url = origin + '/api/search/suggest/web';
|
var url = origin + '/api/search/suggest/web';
|
||||||
var body = 's=' + name + '&limit=' + limit + '&type=1&offset=' + offset;
|
var form = {
|
||||||
|
s: name,
|
||||||
|
limit: limit,
|
||||||
|
type: 1,
|
||||||
|
offset: offset
|
||||||
|
};
|
||||||
var method = 'POST';
|
var method = 'POST';
|
||||||
Object.assign(option, { url: url, body: body, method: method });
|
Object.assign(option, { url: url, form: form, method: method });
|
||||||
(0, _request2.default)(option, function (error, response, body) {
|
(0, _request2.default)(option, function (error, response, body) {
|
||||||
if (!error && response.statusCode == 200) {
|
if (!error && response.statusCode == 200) {
|
||||||
var info = JSON.parse(body);
|
var info = JSON.parse(body);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "NeteaseCloudMusicApi",
|
"name": "NeteaseCloudMusicApi",
|
||||||
"version": "1.1.4",
|
"version": "1.1.7",
|
||||||
"description": "网易云音乐nodejs版接口模块",
|
"description": "网易云音乐nodejs版接口模块",
|
||||||
"main": "build/app.js",
|
"main": "build/app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user