lyswhut/lx-music-desktop · error · Error
获取评论失败
Error message
获取评论失败
What it means
Thrown by Netease Cloud Music's getComment when the weapi-encrypted comment endpoint at https://music.163.com/weapi/comment/resource/comments/get returns non-200 or body.code !== 200 (numeric). Uses cursor-based pagination via cursorTools (a stateful cursor manager keyed by songmid). The weapi() function encrypts the request body with Netease's proprietary algorithm. Reads body.data.comments, body.data.totalCount, and body.data.cursor.
Solutions
- Log body.code and statusCode to distinguish encryption failure from rate-limiting.
- Verify the weapi encryption keys are up to date by testing other Netease weapi endpoints.
- Ensure cursorTools is keyed correctly by songmid and cleared when switching songs.
- Use a CN-based proxy/VPN if running from outside China.
- Retry with backoff for transient rate-limiting.
Example fix
// before
const { body, statusCode } = await _requestObj.promise
if (statusCode != 200 || body.code !== 200) throw new Error('获取评论失败')
// after
const { body, statusCode } = await _requestObj.promise
if (statusCode != 200 || !body || body.code !== 200) {
console.warn('wy getComment failed', { statusCode, code: body?.code, msg: body?.msg })
throw new Error('获取评论失败')
} Defensive patterns
Strategy: try-catch
Validate before calling
function hasWySongmid({ songmid }) {
return typeof songmid === 'string' && songmid.length > 0
} Type guard
function isWyCommentResponse(body) {
return body != null && typeof body === 'object' && body.code === 200 && body.data != null && body.data.comments != null
} Try / catch
try {
const result = await wyComment.getComment({ songmid }, page, limit)
} catch (err) {
if (err.message === '获取评论失败') {
console.warn('Netease comments unavailable for', songmid, '(check weapi keys / IP blocking)')
return { source: 'wy', comments: [], total: 0, page, limit, maxPage: 1 }
}
throw err
} Prevention
- Keep weapi encryption keys updated — Netease rotates them periodically.
- Ensure cursorTools is correctly keyed by songmid and cleared on song change.
- Use a CN-based proxy if running from outside China to avoid IP blocking.
- Log body.code and body.msg to diagnose encryption vs. rate-limiting.
- Retry with backoff for transient rate-limiting.
When it happens
Trigger: The weapi encryption is broken (Netease updates their encryption keys or algorithm). cursorTools returns an invalid/stale cursor for the given page. Rate-limiting or IP-banning by Netease (common for non-CN IPs). The songmid is invalid or the song has no comment thread. Network interference with music.163.com.
Common situations: Netease rotates their weapi secret/key, breaking all encrypted requests. Running the app from outside China triggers Netease IP-level blocking (returns non-200 or error code). The cursor state becomes corrupted when the user switches songs rapidly (cursorTools has stale data for a different songmid).
Related errors
AI-assisted analysis of lyswhut/lx-music-desktop@9c364b482e (2026-08-12).
Data as JSON: /api/errors/17936ec3e8be09b9.
Report an issue: GitHub.
Appendix: source
Thrown at src/renderer/utils/musicSdk/wy/comment.js:146
method: 'post',
headers: {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',
origin: 'https://music.163.com',
Refere: 'http://music.163.com/',
},
form: weapi({
cursor: cursorInfo.cursor,
offset: cursorInfo.offset,
orderType: cursorInfo.orderType,
pageNo: page,
pageSize: limit,
rid: id,
threadId: id,
}),
})
const { body, statusCode } = await _requestObj.promise
// console.log(body)
if (statusCode != 200 || body.code !== 200) throw new Error('获取评论失败')
cursorTools.setCursor(songmid, body.data.cursor, cursorInfo.orderType, cursorInfo.offset, page)
return { source: 'wy', comments: this.filterComment(body.data.comments), total: body.data.totalCount, page, limit, maxPage: Math.ceil(body.data.totalCount / limit) || 1 }
},
async getHotComment({ songmid }, page = 1, limit = 100) {
if (this._requestObj2) this._requestObj2.cancelHttp()
const id = 'R_SO_4_' + songmid
page = page - 1
const _requestObj2 = httpFetch(`https://music.163.com/weapi/v1/resource/hotcomments/${id}`, {
method: 'post',
headers: {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',
origin: 'https://music.163.com',
Refere: 'http://music.163.com/',
},
form: weapi({
rid: id,View on GitHub (pinned to 9c364b482e)