添加搜索重试
parent
1e53508d67
commit
4bfbdeb9a5
|
@ -305,7 +305,8 @@ export default {
|
|||
return `https://y.qq.com/n/ryqq/playlist/${id}`
|
||||
},
|
||||
|
||||
search(text, page, limit = 20) {
|
||||
search(text, page, limit = 20, retryNum = 0) {
|
||||
if (retryNum > 5) throw new Error('max retry')
|
||||
return httpFetch(`http://c.y.qq.com/soso/fcgi-bin/client_music_search_songlist?page_no=${page - 1}&num_per_page=${limit}&format=json&query=${encodeURIComponent(text)}&remoteplace=txt.yqq.playlist&inCharset=utf8&outCharset=utf-8`, {
|
||||
headers: {
|
||||
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
|
||||
|
@ -313,7 +314,7 @@ export default {
|
|||
},
|
||||
})
|
||||
.promise.then(({ body }) => {
|
||||
if (body.code != 0) throw new Error('filed')
|
||||
if (body.code != 0) return this.search(text, page, limit, ++retryNum)
|
||||
// console.log(body.data.list)
|
||||
return {
|
||||
list: body.data.list.map(item => {
|
||||
|
|
Loading…
Reference in New Issue