Skip to content

Commit 4bfbdeb

Browse files
committed
添加搜索重试
1 parent 1e53508 commit 4bfbdeb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/renderer/utils/musicSdk/tx/songList.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,16 @@ export default {
305305
return `https://y.qq.com/n/ryqq/playlist/${id}`
306306
},
307307

308-
search(text, page, limit = 20) {
308+
search(text, page, limit = 20, retryNum = 0) {
309+
if (retryNum > 5) throw new Error('max retry')
309310
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`, {
310311
headers: {
311312
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
312313
Referer: 'http://y.qq.com/portal/search.html',
313314
},
314315
})
315316
.promise.then(({ body }) => {
316-
if (body.code != 0) throw new Error('filed')
317+
if (body.code != 0) return this.search(text, page, limit, ++retryNum)
317318
// console.log(body.data.list)
318319
return {
319320
list: body.data.list.map(item => {

0 commit comments

Comments
 (0)