lyswhut/lx-music-desktop · error · Error
获取评论失败
Error message
获取评论失败
What it means
Thrown by QQ Music's getComment when the legacy comment endpoint at http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg returns non-200 or body.code !== 0 (numeric zero). Uses a POST with form-encoded body. The HTTP scheme is plain http (not https). Requires a songId resolved from songmid via getSongId/getMusicInfo. Reads body.comment.commentlist and body.comment.commenttotal.
Source
Thrown at src/renderer/utils/musicSdk/tx/comment.js:114
method: 'POST',
headers: {
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
},
form: {
uin: '0',
format: 'json',
cid: '205360772',
reqtype: '2',
biztype: '1',
topid: songId,
cmd: '8',
needmusiccrit: '1',
pagenum: page - 1,
pagesize: limit,
},
})
const { body, statusCode } = await _requestObj.promise
if (statusCode != 200 || body.code !== 0) throw new Error('获取评论失败')
// console.log(body, statusCode)
const comment = body.comment
return {
source: 'tx',
comments: this.filterNewComment(comment.commentlist),
total: comment.commenttotal,
page,
limit,
maxPage: Math.ceil(comment.commenttotal / limit) || 1,
}
},
async getHotComment(mInfo, page = 1, limit = 20) {
// const _requestObj2 = httpFetch('http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg', {
// method: 'POST',
// headers: {
// 'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
// },
// form: {View on GitHub (pinned to 9c364b482e)
Solutions
- Log body.code and statusCode before the throw to identify the failure type.
- Verify the resolved songId is valid by checking getSongId's return value.
- Consider migrating to the newer https://u.y.qq.com/cgi-bin/musicu.fcg endpoint (as getHotComment already uses).
- Retry with backoff for transient rate-limiting.
- Switch the URL from http:// to https:// if the environment blocks plain HTTP.
Example fix
// before
const { body, statusCode } = await _requestObj.promise
if (statusCode != 200 || body.code !== 0) throw new Error('获取评论失败')
// after
const { body, statusCode } = await _requestObj.promise
if (statusCode != 200 || !body || body.code !== 0) {
console.warn('tx getComment failed', { statusCode, code: body?.code })
throw new Error('获取评论失败')
} Defensive patterns
Strategy: try-catch
Validate before calling
function hasTxSongId(mInfo) {
return mInfo != null && (!!mInfo.songId || !!mInfo.songmid)
} Type guard
function isTxCommentResponse(body) {
return body != null && typeof body === 'object' && body.code === 0 && body.comment != null
} Try / catch
try {
const result = await txComment.getComment(mInfo, page, limit)
} catch (err) {
if (err.message === '获取评论失败') {
console.warn('QQ Music comments unavailable for', mInfo.songmid)
return { source: 'tx', comments: [], total: 0, page, limit, maxPage: 1 }
}
throw err
} Prevention
- Verify songId resolution succeeds before calling getComment.
- Log body.code to distinguish API errors from transport failures.
- Consider migrating from the legacy fcg endpoint to the newer musicu.fcg endpoint.
- Be aware the URL uses plain HTTP — test in your network environment.
- Retry with backoff for transient rate-limiting.
When it happens
Trigger: Calling getComment(mInfo, page, limit) where songId resolution fails or returns an invalid ID. The fcg_global_comment endpoint is rate-limited or deprecated by Tencent. Plain HTTP is intercepted or blocked. body.code is a non-zero error code (e.g., song has no comments or is region-restricted).
Common situations: Tencent deprecates the legacy fcg_global_comment_h5.fcg endpoint in favor of the newer musicu.fcg API. ISP or GFW interference with c.y.qq.com over HTTP. Region restrictions on certain songs. songId from getMusicInfo is stale or invalid.
Related errors
AI-assisted analysis of lyswhut/lx-music-desktop@9c364b482e (2026-08-12).
Data as JSON: /api/errors/bbf62564adf6a0a4.
Report an issue: GitHub.