lyswhut/lx-music-desktop · error · Error
获取回复评论失败
Error message
获取回复评论失败
What it means
Kugou reply-thread comment fetcher in kg/comment.js:60. Hits comment.service.kugou.com /index.php?r=commentsv2/getReplyWithLike with an Android COMMENT UA. Requires HTTP 200 and body.err_code === 0; otherwise throws '获取回复评论失败' (failed to fetch reply comments). Notably, songmid is remapped (audioId.split('_')[0]) when its length is 32 to work around a KG id-storage change.
Source
Thrown at src/renderer/utils/musicSdk/kg/comment.js:60
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取热门评论失败')
const total = body.count ?? 0
return { source: 'kg', comments: this.filterComment(body.list || []), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }
},
async getReplyComment({ songmid, audioId }, replyId, page = 1, limit = 100) {
if (this._requestObj2) this._requestObj2.cancelHttp()
songmid = songmid.length == 32 // 修复歌曲ID存储变更导致图片获取失败的问题
? audioId.split('_')[0]
: songmid
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}`, {
headers: {
'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi',
},
})
const { body, statusCode } = await _requestObj2.promise
// console.log(body)
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取回复评论失败')
return { source: 'kg', comments: this.filterComment(body.list || []) }
},
replaceAt(raw, atList) {
atList.forEach((atobj) => {
raw = raw.replaceAll(`[at=${atobj.id}]`, `@${atobj.name} `)
})
return raw
},
filterComment(rawList) {
return rawList.map(item => {
let data = {
id: item.id,
text: decodeName((item.atlist ? this.replaceAt(item.content, item.atlist) : item.content) || ''),
images: item.images ? item.images.map(i => i.url) : [],
location: item.location,
time: item.addtime,
timeStr: dateFormat2(new Date(item.addtime).getTime()),
userName: item.user_name,View on GitHub (pinned to 9c364b482e)
Solutions
- Verify the 32-char songmid remap (audioId.split('_')[0]) still matches KG's current childrenid format.
- Confirm the replyId is still valid (re-fetch the parent comment if stale).
- Treat a missing-thread err_code as an empty list instead of throwing.
- Retry with backoff and degrade to 'no replies' in the UI.
Example fix
// before
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取回复评论失败')
// after - include diagnostics
if (statusCode != 200 || body.err_code !== 0) {
throw new Error(`获取回复评论失败 (status=${statusCode}, err_code=${body?.err_code}, tid=${replyId})`)
} Defensive patterns
Strategy: fallback
Validate before calling
// validate replyId and remapped songmid before calling
const validReplyTarget = ({ songmid, audioId }, replyId) =>
typeof replyId === 'string' && replyId !== '' &&
(songmid == null || typeof songmid === 'string') &&
(audioId == null || typeof audioId === 'string') Type guard
const isReplyThreadRef = (ref) => ref != null && typeof ref === 'object' && (typeof ref.songmid === 'string' || ref.songmid == null) && typeof ref.replyId !== 'undefined'
Try / catch
async function loadKgReplies(ref, replyId, page, limit) {
try {
return await kgComment.getReplyComment(ref, replyId, page, limit)
} catch (e) {
return { source: 'kg', comments: [], error: e.message } // show 'no replies' in UI
}
} Prevention
- Verify the 32-char songmid remap (audioId.split('_')[0]) still matches KG's childrenid format.
- Drop stale replyIds by re-fetching the parent comment before loading replies.
- Treat a missing-thread err_code as an empty list, not an error.
When it happens
Trigger: Non-200 or err_code != 0; the 32-char songmid remap produces an invalid childrenid; the replyId points at a deleted/hidden thread; the hardcoded Android COMMENT UA is blocked; signature drift on the `code` param.
Common situations: The reply thread was removed by Kugou; a stale replyId cached client-side; the songmid remap logic mismatches KG's current id format; rate-limiting.
Related errors
AI-assisted analysis of lyswhut/lx-music-desktop@9c364b482e (2026-08-12).
Data as JSON: /api/errors/9631f3fcc8e0574a.
Report an issue: GitHub.