Skip to content

Commit 593d832

Browse files
ikun0014lyswhut
andauthored
fix: 网易云部分歌曲无法被搜索 (#2666)
* fix: 网易云部分歌曲无法被搜索 将搜索请求由原有 eapiRequest 改为通过 httpFetch 调用 /eapi/search/song/list/page 并使用 eapi 加密表单;调整导入(使用 eapi)、移除部分注释和冗余代码。更新结果解析以兼容新响应结构(使用 item.baseInfo.simpleSongData、result.data.resources 和 result.data.totalCount 等字段),并保留原有的分页与重试逻辑。 * update * update --------- Co-authored-by: lyswhut <lyswhut@qq.com>
1 parent d5c54b7 commit 593d832

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

publish/changeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99

1010
- 修复音量条在调整音量时实际音量与显示的数值不一致的问题(#2606
1111
- 修复某些情况下搜索框的搜索按钮布局错位的问题(#2622
12+
- 修复 wyy 部分歌曲无法被搜索的问题(#2666, @ikun0014

src/renderer/utils/musicSdk/wy/musicSearch.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@ export default {
1010
page: 0,
1111
allPage: 1,
1212
musicSearch(str, page, limit) {
13-
const searchRequest = eapiRequest('/api/cloudsearch/pc', {
14-
s: str,
15-
type: 1, // 1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单, 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频
16-
limit,
17-
total: page == 1,
13+
// const searchRequest = eapiRequest('/api/cloudsearch/pc', {
14+
// s: str,
15+
// type: 1, // 1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单, 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频
16+
// limit,
17+
// total: page == 1,
18+
// offset: limit * (page - 1),
19+
// })
20+
const searchRequest = eapiRequest('/api/search/song/list/page', {
21+
keyword: str,
22+
needCorrect: '1',
23+
channel: 'typing',
1824
offset: limit * (page - 1),
25+
scene: 'normal',
26+
total: page == 1,
27+
limit,
1928
})
2029
return searchRequest.promise.then(({ body }) => body)
2130
},
@@ -30,6 +39,7 @@ export default {
3039
// console.log(rawList)
3140
if (!rawList) return []
3241
return rawList.map(item => {
42+
item = item.baseInfo.simpleSongData
3343
const types = []
3444
const _types = {}
3545
let size
@@ -87,12 +97,12 @@ export default {
8797
return this.musicSearch(str, page, limit).then(result => {
8898
// console.log(result)
8999
if (!result || result.code !== 200) return this.search(str, page, limit, retryNum)
90-
let list = this.handleResult(result.result.songs || [])
100+
let list = this.handleResult(result.data.resources || [])
91101
// console.log(list)
92102

93103
if (list == null) return this.search(str, page, limit, retryNum)
94104

95-
this.total = result.result.songCount || 0
105+
this.total = result.data.totalCount || 0
96106
this.page = page
97107
this.allPage = Math.ceil(this.total / this.limit)
98108

0 commit comments

Comments
 (0)