diff --git a/publish/changeLog.md b/publish/changeLog.md index 7b1cba9..68020bc 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -4,3 +4,7 @@ - 优化切歌时桌面歌词的切换动画显示 - 暂停播放时自动隐藏桌面歌词 - 在我的列表-列表名左侧添加了一个图标,以表示此处可以点击切换列表 + +### 修复 + +- 修复tx源搜索失效的问题 diff --git a/src/utils/music/tx/hotSearch.js b/src/utils/music/tx/hotSearch.js index f1451e2..25afd8c 100644 --- a/src/utils/music/tx/hotSearch.js +++ b/src/utils/music/tx/hotSearch.js @@ -6,18 +6,49 @@ export default { if (this._requestObj) this._requestObj.cancelHttp() if (retryNum > 2) return Promise.reject(new Error('try max num')) - const _requestObj = httpFetch('https://c.y.qq.com/splcloud/fcgi-bin/gethotkey.fcg', { - method: 'get', + // const _requestObj = httpFetch('https://c.y.qq.com/splcloud/fcgi-bin/gethotkey.fcg', { + // method: 'get', + // headers: { + // Referer: 'https://y.qq.com/portal/player.html', + // }, + // }) + const _requestObj = httpFetch('https://u.y.qq.com/cgi-bin/musicu.fcg', { + method: 'post', + body: { + comm: { + ct: '19', + cv: '1803', + guid: '0', + patch: '118', + psrf_access_token_expiresAt: 0, + psrf_qqaccess_token: '', + psrf_qqopenid: '', + psrf_qqunionid: '', + tmeAppID: 'qqmusic', + tmeLoginType: 0, + uin: '0', + wid: '0', + }, + hotkey: { + method: 'GetHotkeyForQQMusicPC', + module: 'tencent_musicsoso_hotkey.HotkeyService', + param: { + search_id: '', + uin: 0, + }, + }, + }, headers: { Referer: 'https://y.qq.com/portal/player.html', }, }) const { body, statusCode } = await _requestObj.promise + // console.log(body) if (statusCode != 200 || body.code !== 0) throw new Error('获取热搜词失败') // console.log(body) - return { source: 'tx', list: this.filterList(body.data.hotkey) } + return { source: 'tx', list: this.filterList(body.hotkey.data.vec_hotkey) } }, filterList(rawList) { - return rawList.map(item => item.k) + return rawList.map(item => item.query) }, } diff --git a/src/utils/music/tx/musicSearch.js b/src/utils/music/tx/musicSearch.js index 5bda4df..bc6b2e1 100644 --- a/src/utils/music/tx/musicSearch.js +++ b/src/utils/music/tx/musicSearch.js @@ -14,7 +14,7 @@ export default { musicSearch(str, page, limit, retryNum = 0) { if (retryNum > 5) return Promise.reject(new Error('搜索失败')) // searchRequest = httpFetch(`https://c.y.qq.com/soso/fcgi-bin/client_search_cp?ct=24&qqmusic_ver=1298&new_json=1&remoteplace=sizer.yqq.song_next&searchid=49252838123499591&t=0&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=${page}&n=${limit}&w=${encodeURIComponent(str)}&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq&needNewCode=0`) - const searchRequest = httpFetch(`https://c.y.qq.com/soso/fcgi-bin/client_search_cp?ct=24&qqmusic_ver=1298&remoteplace=txt.yqq.top&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=${page}&n=${limit}&w=${encodeURIComponent(str)}&cv=4747474&ct=24&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0&uin=0&hostUin=0&loginUin=0`) + const searchRequest = httpFetch(`http://shc.y.qq.com/soso/fcgi-bin/client_search_cp?ct=24&qqmusic_ver=1298&remoteplace=txt.yqq.top&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=${page}&n=${limit}&w=${encodeURIComponent(str)}&cv=4747474&ct=24&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0&uin=0&hostUin=0&loginUin=0`) // searchRequest = httpFetch(`http://ioscdn.kugou.com/api/v3/search/song?keyword=${encodeURIComponent(str)}&page=${page}&pagesize=${this.limit}&showtype=10&plat=2&version=7910&tag=1&correct=1&privilege=1&sver=5`) return searchRequest.promise.then(({ body }) => { if (body.code !== this.successCode) return this.musicSearch(str, page, limit, ++retryNum)