From 16a0b849e47592e667ef679756734227cc126e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E7=8B=B8=E8=8A=B1=E5=96=B5?= <94218819+helloplhm-qwq@users.noreply.github.com> Date: Sun, 5 Mar 2023 15:27:48 +0800 Subject: [PATCH] =?UTF-8?q?kg=E6=BA=90=E8=AF=84=E8=AE=BA=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=8C=E7=83=AD=E9=97=A8=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=AE=8C=E6=95=B4=E6=94=AF=E6=8C=81|=E8=BF=99=E6=AC=A1?= =?UTF-8?q?=E6=89=8D=E6=98=AF=E5=AF=B9=E7=9A=84=EF=BC=8C=E4=B8=8A=E6=AC=A1?= =?UTF-8?q?=E6=98=AF=E6=90=9C=E7=B4=A2=E7=9A=84HiRes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/utils/musicSdk/kg/comment.js | 26 +++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/renderer/utils/musicSdk/kg/comment.js b/src/renderer/utils/musicSdk/kg/comment.js index a2178e0b..97a80528 100644 --- a/src/renderer/utils/musicSdk/kg/comment.js +++ b/src/renderer/utils/musicSdk/kg/comment.js @@ -1,27 +1,35 @@ import { httpFetch } from '../../request' import { decodeName, dateFormat2 } from '../../index' +import { toMD5 } from '../utils' export default { _requestObj: null, _requestObj2: null, - async getComment({ hash }, page = 1, limit = 20) { + async getComment({ hash, songmid }, page = 1, limit = 20) { if (this._requestObj) this._requestObj.cancelHttp() - const _requestObj = httpFetch(`http://comment.service.kugou.com/index.php?r=commentsv2/getCommentWithLike&code=fc4be23b4e972707f36b8a828a93ba8a&extdata=${hash}&p=${page}&pagesize=${limit}&ver=1.01&clientver=8373&appid=1001&kugouid=687373022&need_show_image=1`, { + let timestamp = Date.now() + let OIlwieks = '28dk2k092lksi2UIkp' + let sign_params = `OIlwieks${OIlwieks}appid=1005childrenid=${songmid}clienttime=${timestamp}clienttoken=0364933ef7daa8c0f150e91b49e6bc38ceaf106e6c49400c230936282b0a0dd8clientver=11409code=fc4be23b4e972707f36b8a828a93ba8adfid=347VvU1FGsNW0XwQu30ZZolsextdata=${hash}kugouid=0mid=162495122043363656740233957790194166813mixsongid=0p=${page}pagesize=${limit}uuid=0ver=10OIlwieks${OIlwieks}` + let signature = toMD5(sign_params) + const _requestObj = httpFetch(`http://m.comment.service.kugou.com/v1/cmtlist?dfid=347VvU1FGsNW0XwQu30ZZols&mid=162495122043363656740233957790194166813&signature=${signature}&clienttime=${timestamp}&uuid=0&extdata=${hash}&appid=1005&code=fc4be23b4e972707f36b8a828a93ba8a&childrenid=${songmid}&clientver=11409&p=${page}&mixsongid=0&clienttoken=0364933ef7daa8c0f150e91b49e6bc38ceaf106e6c49400c230936282b0a0dd8&pagesize=${limit}&ver=10&kugouid=0`, { headers: { - 'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi', + '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', }, }) const { body, statusCode } = await _requestObj.promise // console.log(body) if (statusCode != 200 || body.err_code !== 0) throw new Error('获取评论失败') - return { source: 'kg', comments: this.filterComment(body.list || []), total: body.count, page, limit, maxPage: Math.ceil(body.count / limit) || 1 } + return { source: 'kg', comments: this.filterComment(body.list || []), total: body.count, page, limit, maxPage: body.maxPage } }, - async getHotComment({ hash, songmid }, page = 1, limit = 100) { + async getHotComment({ hash, songmid }, page = 1, limit = 20) { // console.log(songmid) if (this._requestObj2) this._requestObj2.cancelHttp() - - const _requestObj2 = httpFetch(`http://comment.service.kugou.com/index.php?r=commentsv2/getCommentWithLike&code=fc4be23b4e972707f36b8a828a93ba8a&extdata=${hash}&p=${page}&pagesize=${limit}&ver=1.01&clientver=8373&appid=1001&kugouid=687373022&need_show_image=1`, { + let timestamp = Date.now() + let OIlwieks = '28dk2k092lksi2UIkp' + let sign_params = `OIlwieks${OIlwieks}appid=1005childrenid=${songmid}clienttime=${timestamp}clienttoken=0364933ef7daa8c0f150e91b49e6bc38ceaf106e6c49400c230936282b0a0dd8clientver=11409code=fc4be23b4e972707f36b8a828a93ba8adfid=347VvU1FGsNW0XwQu30ZZolsextdata=${hash}kugouid=0mid=162495122043363656740233957790194166813mixsongid=0p=${page}pagesize=${limit}uuid=0ver=10OIlwieks${OIlwieks}` + let signature = toMD5(sign_params) + const _requestObj2 = httpFetch(`http://m.comment.service.kugou.com/v1/weightlist?dfid=347VvU1FGsNW0XwQu30ZZols&mid=162495122043363656740233957790194166813&signature=${signature}&clienttime=${timestamp}&uuid=0&extdata=${hash}&appid=1005&code=fc4be23b4e972707f36b8a828a93ba8a&childrenid=${songmid}&clientver=11409&p=${page}&mixsongid=0&clienttoken=0364933ef7daa8c0f150e91b49e6bc38ceaf106e6c49400c230936282b0a0dd8&pagesize=${limit}&ver=10&kugouid=0`, { headers: { 'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi', }, @@ -29,8 +37,8 @@ export default { const { body, statusCode } = await _requestObj2.promise // console.log(body) if (statusCode != 200 || body.err_code !== 0) throw new Error('获取热门评论失败') - const total = body.weightList?.length ?? 0 - return { source: 'kg', comments: this.filterComment(body.weightList || []), total, page, limit, maxPage: 1 } + const total = body.count ?? 0 + return { source: 'kg', comments: this.filterComment(body.list || []), total, page, limit, maxPage: Math.ceil(body.count / limit) || 1 } }, async getReplyComment({ songmid, audioId }, replyId, page = 1, limit = 100) { if (this._requestObj2) this._requestObj2.cancelHttp()