mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-22 15:41:23 +08:00
add getArtistAblums and getAblums & Update README & Update test & replan directory
This commit is contained in:
+11
-51
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user