mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-07-07 00:02:06 +08:00
update
This commit is contained in:
34
app.js
34
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')
|
||||
if (!error && response.statusCode == 200) {
|
||||
var info = JSON.parse(body);
|
||||
console.log(JSON.stringify(info, '', 2))
|
||||
request(option, (error, response, body)=>{
|
||||
if (!error && response.statusCode == 200) {
|
||||
let info = JSON.parse(body);
|
||||
callback&&callback(JSON.stringify(info, '', 2))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
export {api}
|
Reference in New Issue
Block a user