forked from lyswhut/lx-music-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 修复wy源热搜词失效 * 添加更新日志 --------- Co-authored-by: lyswhut <[email protected]>
- Loading branch information
Showing
2 changed files
with
7 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
import { httpFetch } from '../../request' | ||
import { weapi } from './utils/crypto' | ||
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 = httpFetch('https://music.163.com/weapi/search/hot', { | ||
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({ type: 1111 }), | ||
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('获取热搜词失败') | ||
// console.log(body) | ||
return { source: 'wy', list: this.filterList(body.result.hots) } | ||
|
||
return { source: 'wy', list: this.filterList(body.data.itemList) } | ||
}, | ||
filterList(rawList) { | ||
return rawList.map(item => item.first) | ||
return rawList.map(item => item.searchWord) | ||
}, | ||
} |