{"record":{"id":"ecba4f979552f37e","repo":"lyswhut/lx-music-desktop","slug":"error-ecba4f","errorCode":null,"errorMessage":"获取热门评论失败","messagePattern":"获取热门评论失败","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/utils/musicSdk/kg/comment.js","lineNumber":42,"sourceCode":"    // console.log(body)\n    if (statusCode != 200 || body.err_code !== 0) throw new Error('获取评论失败')\n    const total = body.count ?? 0\n    return { source: 'kg', comments: this.filterComment(body.list || []), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }\n  },\n  async getHotComment({ hash }, page = 1, limit = 20) {\n    // console.log(songmid)\n    if (this._requestObj2) this._requestObj2.cancelHttp()\n    let timestamp = Date.now()\n    const params = `dfid=0&mid=16249512204336365674023395779019&clienttime=${timestamp}&uuid=0&extdata=${hash}&appid=1005&code=fc4be23b4e972707f36b8a828a93ba8a&schash=${hash}&clientver=11409&p=${page}&clienttoken=&pagesize=${limit}&ver=10&kugouid=0`\n    // https://github.com/GitHub-ZC/wp_MusicApi/blob/bf9307dd138dc8ac6c4f7de29361209d4f5b665f/routes/v1/kugou/comment.js#L53\n    const _requestObj2 = httpFetch(`http://m.comment.service.kugou.com/r/v1/rank/topliked?${params}&signature=${signatureParams(params)}`, {\n      headers: {\n        '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',\n      },\n    })\n    const { body, statusCode } = await _requestObj2.promise\n    // console.log(body)\n    if (statusCode != 200 || body.err_code !== 0) throw new Error('获取热门评论失败')\n    const total = body.count ?? 0\n    return { source: 'kg', comments: this.filterComment(body.list || []), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }\n  },\n  async getReplyComment({ songmid, audioId }, replyId, page = 1, limit = 100) {\n    if (this._requestObj2) this._requestObj2.cancelHttp()\n\n    songmid = songmid.length == 32 // 修复歌曲ID存储变更导致图片获取失败的问题\n      ? audioId.split('_')[0]\n      : songmid\n\n    const _requestObj2 = httpFetch(`http://comment.service.kugou.com/index.php?r=commentsv2/getReplyWithLike&code=fc4be23b4e972707f36b8a828a93ba8a&p=${page}&pagesize=${limit}&ver=1.01&clientver=8373&kugouid=687373022&need_show_image=1&appid=1001&childrenid=${songmid}&tid=${replyId}`, {\n      headers: {\n        'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi',\n      },\n    })\n    const { body, statusCode } = await _requestObj2.promise\n    // console.log(body)\n    if (statusCode != 200 || body.err_code !== 0) throw new Error('获取回复评论失败')","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/lyswhut/lx-music-desktop/blob/9c364b482e5621a1d38b50e8610d2fb974457e6e/src/renderer/utils/musicSdk/kg/comment.js#L24-L60","documentation":"Kugou topliked (hot) comment fetcher in kg/comment.js:42 — sibling of [33] hitting /v1/rank/topliked with the same signed-params pattern and Edge UA. Requires HTTP 200 and body.err_code === 0; otherwise throws '获取热门评论失败' (failed to fetch hot comments). Triggered when loading the hot-comments view for a kg track.","triggerScenarios":"Same shape as [33]: non-200, err_code != 0, signature rejected, UA blocked, or the topliked route sunset by Kugou. Differs only in the endpoint path (/topliked vs /newest).","commonSituations":"Signature/header drift; Kugou rate-limiting; the topliked endpoint returning a different err_code for empty results; mid/code revoked.","solutions":["Apply the same signature/constant verification as for [33].","Retry with backoff for transient failures.","If topliked legitimately returns empty (no hot comments) with a non-zero code, treat that specific code as an empty-list result rather than an error.","Degrade to an empty hot-comments list in the UI on rejection."],"exampleFix":"// before\n    if (statusCode != 200 || body.err_code !== 0) throw new Error('获取热门评论失败')\n\n// after - distinguish empty from failure where possible\n    if (statusCode != 200 || body.err_code !== 0) {\n      throw new Error(`获取热门评论失败 (status=${statusCode}, err_code=${body?.err_code})`)\n    }","handlingStrategy":"retry","validationCode":"const isKgToplikedSuccess = (body) =>\n  body != null && typeof body === 'object' && body.err_code === 0","typeGuard":"const isKgToplikedSuccess = (body) =>\n  body != null && typeof body === 'object' && body.err_code === 0","tryCatchPattern":"async function loadKgHotComments(hash, page, limit) {\n  try {\n    return await kgComment.getHotComment({ hash }, page, limit)\n  } catch (e) {\n    return { source: 'kg', comments: [], total: 0, page, limit, maxPage: 1, error: e.message }\n  }\n}","preventionTips":["Share the same signature/constant hygiene as the newest-comments endpoint.","If topliked legitimately returns empty with a specific err_code, treat that code as empty rather than error.","Retry transient failures; degrade the hot-comments tab to empty on persistent failure."],"tags":["network","kugou","comments","third-party-api","signature"],"backgroundTag":null,"analyzedSha":"9c364b482e5621a1d38b50e8610d2fb974457e6e","analyzedAt":"2026-08-12T15:14:48.244Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}