lyswhut/lx-music-desktop · error · Error
获取歌曲详情失败
Error message
获取歌曲详情失败
What it means
Thrown by Netease's musicDetail.getList when the song detail endpoint at https://music.163.com/weapi/v3/song/detail returns non-200 or body.code !== 200. Uses weapi encryption with a batch of song IDs (c and ids arrays). Has a retry guard (retryNum > 2) that fires first. Takes an array of ids and constructs the weapi form by JSON-stringifying them. Reads the entire body via filterList(body).
Source
Thrown at src/renderer/utils/musicSdk/wy/musicDetail.js:108
// console.log(list)
return list
},
async getList(ids = [], retryNum = 0) {
if (retryNum > 2) return Promise.reject(new Error('try max num'))
const requestObj = httpFetch('https://music.163.com/weapi/v3/song/detail', {
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',
},
form: weapi({
c: '[' + ids.map(id => ('{"id":' + id + '}')).join(',') + ']',
ids: '[' + ids.join(',') + ']',
}),
})
const { body, statusCode } = await requestObj.promise
if (statusCode != 200 || body.code !== 200) throw new Error('获取歌曲详情失败')
// console.log(body)
return { source: 'wy', list: this.filterList(body) }
},
}
View on GitHub (pinned to 9c364b482e)
Solutions
- Guard against an empty ids array before making the request.
- Log body.code and statusCode to diagnose encryption vs. rate-limiting.
- Verify all IDs are valid Netease song IDs (numeric strings).
- Retry by calling getList(ids, retryNum + 1) since it supports bounded retries.
- Use a CN proxy if running from outside China.
Example fix
// before
async getList(ids = [], retryNum = 0) {
if (retryNum > 2) return Promise.reject(new Error('try max num'))
const requestObj = httpFetch('https://music.163.com/weapi/v3/song/detail', { ... })
const { body, statusCode } = await requestObj.promise
if (statusCode != 200 || body.code !== 200) throw new Error('获取歌曲详情失败')
return { source: 'wy', list: this.filterList(body) }
}
// after
async getList(ids = [], retryNum = 0) {
if (!ids.length) return { source: 'wy', list: [] }
if (retryNum > 2) return Promise.reject(new Error('try max num'))
const requestObj = httpFetch('https://music.163.com/weapi/v3/song/detail', { ... })
const { body, statusCode } = await requestObj.promise
if (statusCode != 200 || !body || body.code !== 200) {
console.warn('wy musicDetail failed', { statusCode, code: body?.code })
if (retryNum < 2) return this.getList(ids, retryNum + 1)
throw new Error('获取歌曲详情失败')
}
return { source: 'wy', list: this.filterList(body) }
} Defensive patterns
Strategy: validation
Validate before calling
function isValidDetailRequest(ids) {
return Array.isArray(ids) && ids.length > 0 && ids.every(id => typeof id === 'string' && /^\d+$/.test(id))
} Type guard
function isWyMusicDetailResponse(body) {
return body != null && typeof body === 'object' && body.code === 200 && body.songs != null
} Try / catch
try {
if (!ids.length) return { source: 'wy', list: [] }
const result = await wyMusicDetail.getList(ids)
} catch (err) {
if (err.message === '获取歌曲详情失败') {
console.warn('Netease song detail failed for ids', ids, '(check weapi keys / IP blocking)')
return { source: 'wy', list: [] }
}
throw err
} Prevention
- Guard against an empty ids array before calling getList.
- Verify all IDs are valid numeric Netease song IDs.
- Keep weapi encryption keys updated.
- Call getList with a retryNum parameter to leverage built-in retries.
- Use a CN proxy if running from outside China.
- Log body.code and statusCode to diagnose encryption vs. rate-limiting.
When it happens
Trigger: The weapi encryption is broken. One or more IDs in the batch are invalid or removed (Netease may return non-200 for partially-invalid batches). Empty ids array produces malformed weapi form. Rate-limiting or IP-banning. Netease changes the v3/song/detail endpoint contract.
Common situations: Passing an empty ids array (default is []) produces a request with empty c/ids arrays, which Netease may reject. The weapi key rotation breaks all encrypted requests. Non-CN IP blocking. Mixing IDs from different providers in the same batch.
Related errors
AI-assisted analysis of lyswhut/lx-music-desktop@9c364b482e (2026-08-12).
Data as JSON: /api/errors/22aca9bd1cfec7c7.
Report an issue: GitHub.