lyswhut/lx-music-desktop · warning · Error

获取热搜词失败

Error message

获取热搜词失败

What it means

Thrown by Netease's hotSearch.getList when the eapi-encrypted endpoint /api/search/chart/detail returns non-200 or body.code !== 200. Uses eapiRequest (Netease's eapi encryption wrapper, different from weapi) with a fixed parameter id: 'HOT_SEARCH_SONG#@#'. Has a retry guard (retryNum > 2) that fires first. Reads body.data.itemList.

Source

Thrown at src/renderer/utils/musicSdk/wy/hotSearch.js:13

import { eapiRequest } from './utils/index'

export default {
  _requestObj: null,
  async getList(retryNum = 0) {
    if (this._requestObj) this._requestObj.cancelHttp()
    if (retryNum > 2) return Promise.reject(new Error('try max num'))

    const _requestObj = eapiRequest('/api/search/chart/detail', {
      id: 'HOT_SEARCH_SONG#@#',
    })
    const { body, statusCode } = await _requestObj.promise
    if (statusCode != 200 || body.code !== 200) throw new Error('获取热搜词失败')

    return { source: 'wy', list: this.filterList(body.data.itemList) }
  },
  filterList(rawList) {
    return rawList.map(item => item.searchWord)
  },
}

View on GitHub (pinned to 9c364b482e)

Solutions

  1. Log body and statusCode to diagnose encryption vs. rate-limiting.
  2. Verify the eapi encryption is current by testing other eapi endpoints.
  3. Retry by calling getList(retryNum + 1) since it supports bounded retries.
  4. Fall back to another provider's hot search if Netease is unavailable.
  5. Use a CN proxy if running from outside China.

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 hotSearch failed', { statusCode, code: body?.code })
  if (retryNum < 2) return this.getList(retryNum + 1)
  throw new Error('获取热搜词失败')
}
Defensive patterns

Strategy: retry

Type guard

function isWyHotSearchResponse(body) {
  return body != null && typeof body === 'object' && body.code === 200 && body.data != null && Array.isArray(body.data.itemList)
}

Try / catch

try {
  const result = await wyHotSearch.getList()
} catch (err) {
  if (err.message === '获取热搜词失败') {
    console.warn('Netease hot search unavailable (check eapi keys / IP blocking)')
    return { source: 'wy', list: [] }
  }
  throw err
}

Prevention

When it happens

Trigger: The eapi encryption is broken (Netease updates their eapi key/algorithm). The search chart endpoint is deprecated or the id 'HOT_SEARCH_SONG#@#' changes. Rate-limiting or IP-banning. Network interference with music.163.com.

Common situations: Netease rotates their eapi encryption secrets, breaking all eapi requests. Non-CN IP blocking. The hot search chart ID format changes. Unlike weapi, eapi failures are often silent (returns non-200 rather than an error code), making diagnosis harder.

Related errors


AI-assisted analysis of lyswhut/lx-music-desktop@9c364b482e (2026-08-12). Data as JSON: /api/errors/bbc1cd2c37393651. Report an issue: GitHub.