From 03781ea692c406cd0213b29a3e12361177dbae9f Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 2 Mar 2024 15:04:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dkg=E6=9C=80=E6=96=B0=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=88@helloplhm-qwq=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 5 +++-- src/renderer/utils/musicSdk/kg/comment.js | 6 +++++- src/renderer/utils/musicSdk/kg/musicInfo.js | 8 ++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 49563f47..be44d054 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -5,14 +5,15 @@ ### 优化 - 主题设置默认折叠其他主题以优化进入设置界面时的性能 -- 不再丢弃kg源逐行歌词 +- 不再丢弃kg源逐行歌词(@helloplhm-qwq) - 支持kw源排行榜显示大小(revert @Folltoshe #1460) ### 修复 - 修复某些情况下歌曲加载时间过长时不会自动跳到下一首的问题 - 修复mg歌词在某些情况下获取失败的问题(#1783) -- 修复mg歌单搜索 +- 修复mg歌单搜索(@helloplhm-qwq) +- 修复kg最新评论无法获取的问题(@helloplhm-qwq) - 修复更新超时弹窗在非更新阶段意外弹出的问题(#1797) ### 其他 diff --git a/src/renderer/utils/musicSdk/kg/comment.js b/src/renderer/utils/musicSdk/kg/comment.js index e4493721..f9e3e519 100644 --- a/src/renderer/utils/musicSdk/kg/comment.js +++ b/src/renderer/utils/musicSdk/kg/comment.js @@ -1,6 +1,7 @@ import { httpFetch } from '../../request' import { decodeName, dateFormat2 } from '../../index' import { signatureParams } from './util' +import { getMusicInfoRaw } from './musicInfo' export default { _requestObj: null, @@ -8,8 +9,11 @@ export default { async getComment({ hash }, page = 1, limit = 20) { if (this._requestObj) this._requestObj.cancelHttp() + const res_id = (await getMusicInfoRaw(hash)).classification?.[0]?.res_id + if (!res_id) throw new Error('获取评论失败') + let timestamp = Date.now() - const params = `appid=1005&clienttime=${timestamp}&clienttoken=0&clientver=11409&code=fc4be23b4e972707f36b8a828a93ba8a&dfid=0&extdata=${hash}&kugouid=0&mid=16249512204336365674023395779019&mixsongid=0&p=${page}&pagesize=${limit}&uuid=0&ver=10` + const params = `appid=1005&clienttime=${timestamp}&clienttoken=0&clientver=11409&code=fc4be23b4e972707f36b8a828a93ba8a&dfid=0&extdata=${hash}&kugouid=0&mid=16249512204336365674023395779019&mixsongid=${res_id}&p=${page}&pagesize=${limit}&uuid=0&ver=10` const _requestObj = httpFetch(`http://m.comment.service.kugou.com/r/v1/rank/newest?${params}&signature=${signatureParams(params)}`, { headers: { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.24', diff --git a/src/renderer/utils/musicSdk/kg/musicInfo.js b/src/renderer/utils/musicSdk/kg/musicInfo.js index f23862f9..9f826803 100644 --- a/src/renderer/utils/musicSdk/kg/musicInfo.js +++ b/src/renderer/utils/musicSdk/kg/musicInfo.js @@ -13,7 +13,7 @@ const createGetMusicInfosTask = (hashs) => { dfid: '-', clienttime: Date.now(), key: 'OIlwieks28dk2k092lksi2UIkp', - fields: 'album_info,author_name,audio_info,ori_audio_name,base,songname', + fields: 'album_info,author_name,audio_info,ori_audio_name,base,songname,classification', } let list = hashs let tasks = [] @@ -103,8 +103,12 @@ export const getMusicInfos = async(hashs) => { return filterMusicInfoList(await Promise.all(createGetMusicInfosTask(hashs)).then(data => data.flat())) } +export const getMusicInfoRaw = async(hash) => { + return Promise.all(createGetMusicInfosTask([{ hash }])).then(data => data.flat()[0]) +} + export const getMusicInfo = async(hash) => { - return getMusicInfos([hash]).then(data => data[0]) + return getMusicInfos([{ hash }]).then(data => data[0]) } export const getMusicInfosByList = (list) => {