change to library-songs retrieval method
This commit is contained in:
parent
f6bce2019d
commit
082137ed9d
4 changed files with 13283 additions and 166 deletions
|
@ -1,17 +1,32 @@
|
|||
const MusicKitTools = {
|
||||
async v3Continuous (href, options = {}, reqOptions = {}) {
|
||||
async v3Continuous ({
|
||||
href,
|
||||
options = {},
|
||||
reqOptions = {},
|
||||
onProgress = () => {},
|
||||
onError = () => {},
|
||||
onSuccess = () => {}
|
||||
} = {}) {
|
||||
let returnData = []
|
||||
async function sendReq(href, options) {
|
||||
const response = await app.mk.api.v3.music(href, options)
|
||||
const response = await app.mk.api.v3.music(href, options).catch(error => onError)
|
||||
|
||||
returnData = returnData.concat(response.data.data)
|
||||
if(response.data.next) {
|
||||
await sendReq(response.data.next, options)
|
||||
onProgress({
|
||||
response: response,
|
||||
total: returnData.length
|
||||
})
|
||||
try {
|
||||
await sendReq(response.data.next, options)
|
||||
}catch(e){
|
||||
await sendReq(response.data.next, options)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await sendReq(href, options)
|
||||
|
||||
onSuccess(returnData)
|
||||
return returnData
|
||||
},
|
||||
getHeader() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue