Skip to content

Commit

Permalink
添加搜索重试
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Mar 26, 2023
1 parent 1e53508 commit 4bfbdeb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/renderer/utils/musicSdk/tx/songList.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,16 @@ 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)',
Referer: 'http://y.qq.com/portal/search.html',
},
})
.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 => {
Expand Down

0 comments on commit 4bfbdeb

Please sign in to comment.