{"record":{"id":"1c4044669fd193ed","repo":"lyswhut/lx-music-desktop","slug":"error-1c4044","errorCode":null,"errorMessage":"获取热搜词失败","messagePattern":"获取热搜词失败","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/utils/musicSdk/kg/hotSearch.js","lineNumber":22,"sourceCode":"export default {\n  _requestObj: null,\n  async getList(retryNum = 0) {\n    if (this._requestObj) this._requestObj.cancelHttp()\n    if (retryNum > 2) return Promise.reject(new Error('try max num'))\n\n    const _requestObj = httpFetch('http://gateway.kugou.com/api/v3/search/hot_tab?signature=ee44edb9d7155821412d220bcaf509dd&appid=1005&clientver=10026&plat=0', {\n      method: 'get',\n      headers: {\n        dfid: '1ssiv93oVqMp27cirf2CvoF1',\n        mid: '156798703528610303473757548878786007104',\n        clienttime: 1584257267,\n        'x-router': 'msearch.kugou.com',\n        'user-agent': 'Android9-AndroidPhone-10020-130-0-searchrecommendprotocol-wifi',\n        'kg-rc': 1,\n      },\n    })\n    const { body, statusCode } = await _requestObj.promise\n    if (statusCode != 200 || body.errcode !== 0) throw new Error('获取热搜词失败')\n    // console.log(body, statusCode)\n    return { source: 'kg', list: this.filterList(body.data.list) }\n  },\n  filterList(rawList) {\n    const list = []\n    rawList.forEach(item => {\n      item.keywords.map(k => list.push(decodeName(k.keyword)))\n    })\n    return list\n  },\n}\n","sourceCodeStart":4,"sourceCodeEnd":34,"githubUrl":"https://github.com/lyswhut/lx-music-desktop/blob/9c364b482e5621a1d38b50e8610d2fb974457e6e/src/renderer/utils/musicSdk/kg/hotSearch.js#L4-L34","documentation":"Kugou hot-search fetcher in kg/hotSearch.js:22. GETs gateway.kugou.com /api/v3/search/hot_tab with a STATIC signature (ee44edb9...) and STATIC headers including clienttime: 1584257267 (a March-2020 timestamp) and fixed dfid/mid. Requires HTTP 200 and body.errcode === 0; otherwise throws '获取热搜词失败'.","triggerScenarios":"Non-200 or errcode != 0 — most likely because the hardcoded static signature and the 2020-era clienttime no longer validate against Kugou's gateway, or the fixed dfid/mid has been banned. Also fires on plain network failure.","commonSituations":"Kugou rotated its signature requirement so the constant no longer works; the static clienttime is too old and rejected; the dfid/mid pair flagged for abuse; the hot_tab endpoint deprecated.","solutions":["Regenerate the signature dynamically per request instead of using the constant 'ee44edb9d7155821412d220bcaf509dd'.","Refresh the clienttime header to a current epoch value and rotate dfid/mid if they are flagged.","Confirm /api/v3/search/hot_tab is still the active endpoint; update if Kugou moved it.","Degrade to an empty hot-search list in the UI on rejection."],"exampleFix":"// before\n    const _requestObj = httpFetch('http://gateway.kugou.com/api/v3/search/hot_tab?signature=ee44edb9d7155821412d220bcaf509dd&appid=1005&clientver=10026&plat=0', {\n      method: 'get',\n      headers: { dfid: '1ssiv93oVqMp27cirf2CvoF1', mid: '15679...', clienttime: 1584257267, ... },\n    })\n\n// after - compute signature + clienttime dynamically\n    const clienttime = Math.floor(Date.now() / 1000)\n    const params = `appid=1005&clientver=10026&plat=0&clienttime=${clienttime}`\n    const signature = signatureParams(params)\n    const _requestObj = httpFetch(`http://gateway.kugou.com/api/v3/search/hot_tab?${params}&signature=${signature}`, { method: 'get', headers: { ... } })","handlingStrategy":"fallback","validationCode":"// best-effort liveness check of the gateway before the real call\nasync function kgGatewayAlive() {\n  try {\n    const { statusCode } = await httpFetch('http://gateway.kugou.com/', { method: 'head', timeout: 3000 }).promise\n    return statusCode >= 200 && statusCode < 500\n  } catch { return false }\n}","typeGuard":"const isKgHotSearchSuccess = (body) =>\n  body != null && typeof body === 'object' && body.errcode === 0 &&\n  body.data != null && Array.isArray(body.data.list)","tryCatchPattern":"async function loadKgHotSearch() {\n  try {\n    return await kgHotSearch.getList()\n  } catch (e) {\n    return { source: 'kg', list: [], error: e.message } // empty hot list in UI\n  }\n}","preventionTips":["Do NOT rely on the hardcoded signature (ee44...) and 2020 clienttime — regenerate them dynamically.","Rotate the dfid/mid headers if Kugou flags the static pair.","Degrade to an empty hot-search list in the UI when the gateway rejects."],"tags":["network","kugou","hot-search","third-party-api","hardcoded-signature","stale-constants"],"backgroundTag":null,"analyzedSha":"9c364b482e5621a1d38b50e8610d2fb974457e6e","analyzedAt":"2026-08-12T15:14:48.244Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}