mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-20 22:51:23 +08:00
update
This commit is contained in:
+19
-22
@@ -4,32 +4,30 @@ import { deepCopy } from './util'
|
||||
|
||||
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'
|
||||
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)
|
||||
}
|
||||
})
|
||||
},
|
||||
song: (id, callback = null) => {
|
||||
let option = deepCopy(globalOption)
|
||||
let url = origin + '/api/song/detail?ids=%5B' + id + '%5d'
|
||||
let method = 'GET'
|
||||
let proxy = false
|
||||
Object.assign(option, { url, method, proxy })
|
||||
Object.assign(option, { url, method })
|
||||
request(option, (error, response, body) => {
|
||||
if (!error && response.statusCode == 200) {
|
||||
let info = JSON.parse(body);
|
||||
@@ -43,8 +41,7 @@ let api = {
|
||||
let option = deepCopy(globalOption)
|
||||
let url = origin + '/api/song/lyric?lv=' + lv + '&id=' + id
|
||||
let method = 'GET'
|
||||
let proxy = false
|
||||
Object.assign(option, { url, method, proxy })
|
||||
Object.assign(option, { url, method })
|
||||
request(option, (error, response, body) => {
|
||||
if (!error && response.statusCode == 200) {
|
||||
let info = JSON.parse(body);
|
||||
|
||||
+2
-1
@@ -5,7 +5,8 @@ const globalOption = {
|
||||
'Origin': origin,
|
||||
'Referer': origin,
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
},
|
||||
proxy:false
|
||||
}
|
||||
|
||||
export { origin, globalOption }
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
const deepCopy = (obj) => JSON.parse(JSON.stringify(obj))
|
||||
const deepCopy = obj => JSON.parse(JSON.stringify(obj))
|
||||
|
||||
export { deepCopy }
|
||||
|
||||
Reference in New Issue
Block a user