Skip to content

Commit 8142e5e

Browse files
committed
修复MG源评论加载失败
1 parent 0c71772 commit 8142e5e

5 files changed

Lines changed: 157 additions & 71 deletions

File tree

publish/changeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- 尝试修复进度为0时仍然显示下载完成的问题 (#2471)
1818
- 修复TX源搜索失败 (#2575 @Folltoshe)
1919
- 修复MG源歌单加载失败
20+
- 修复MG源评论加载失败
2021

2122
### 变更
2223

src/renderer/store/search/music/action.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ const setList = (datas: SearchResult, page: number, text: string): LX.Music.Musi
7474
}
7575

7676
export const resetListInfo = (sourceId: LX.OnlineSource | 'all'): [] => {
77-
let listInfo = listInfos[sourceId]!
77+
let listInfo = listInfos[sourceId]
78+
if (!listInfo) return []
7879
listInfo.list = []
7980
listInfo.page = 0
8081
listInfo.maxPage = 0

src/renderer/store/search/songlist/action.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ const setList = (datas: SearchResult, page: number, text: string): ListInfoItem[
7272
}
7373

7474
export const resetListInfo = (sourceId: LX.OnlineSource | 'all'): [] => {
75-
let listInfo = listInfos[sourceId]!
75+
let listInfo = listInfos[sourceId]
76+
if (!listInfo) return []
7677
listInfo.page = 1
7778
listInfo.limit = 20
7879
listInfo.total = 0

src/renderer/utils/musicSdk/mg/comment.js

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,28 @@ export default {
66
_requestObj: null,
77
_requestObj2: null,
88
_requestObj3: null,
9-
async getComment(musicInfo, page = 1, limit = 10) {
9+
async getComment(musicInfo, page = 1, limit = 20) {
1010
if (this._requestObj) this._requestObj.cancelHttp()
1111
if (!musicInfo.songId) {
1212
let id = await getSongId(musicInfo)
1313
if (!id) throw new Error('获取评论失败')
1414
musicInfo.songId = id
1515
}
1616

17-
const _requestObj = httpFetch(`https://music.migu.cn/v3/api/comment/listComments?targetId=${musicInfo.songId}&pageSize=${limit}&pageNo=${page}`, {
17+
// const _requestObj = httpFetch(`https://music.migu.cn/v3/api/comment/listComments?targetId=${musicInfo.songId}&pageSize=${limit}&pageNo=${page}`, {
18+
const _requestObj = httpFetch(`https://app.c.nf.migu.cn/MIGUM3.0/user/comment/stack/v1.0?pageSize=${limit}&queryType=1&resourceId=${musicInfo.songId}&resourceType=2&start=${(page - 1) * limit}`, {
1819
headers: {
19-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4195.1 Safari/537.36',
20-
Referer: 'https://music.migu.cn',
20+
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
21+
// Referer: 'https://music.migu.cn',
2122
},
2223
})
2324
const { body, statusCode } = await _requestObj.promise
2425
// console.log(body)
25-
if (statusCode != 200 || body.returnCode !== '000000') throw new Error('获取评论失败')
26-
return { source: 'mg', comments: this.filterComment(body.data.items), total: body.data.itemTotal, page, limit, maxPage: Math.ceil(body.data.itemTotal / limit) || 1 }
26+
if (statusCode != 200 || body.code !== '000000') throw new Error('获取评论失败')
27+
const total = parseInt(body.data.commentNums)
28+
return { source: 'mg', comments: this.filterComment(body.data.comments), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }
2729
},
28-
async getHotComment(musicInfo, page = 1, limit = 5) {
30+
async getHotComment(musicInfo, page = 1, limit = 20) {
2931
if (this._requestObj2) this._requestObj2.cancelHttp()
3032

3133
if (!musicInfo.songId) {
@@ -34,51 +36,55 @@ export default {
3436
musicInfo.songId = id
3537
}
3638

37-
const _requestObj2 = httpFetch(`https://music.migu.cn/v3/api/comment/listTopComments?targetId=${musicInfo.songId}&pageSize=${limit}&pageNo=${page}`, {
39+
// const _requestObj2 = httpFetch(`https://music.migu.cn/v3/api/comment/listTopComments?targetId=${musicInfo.songId}&pageSize=${limit}&pageNo=${page}`, {
40+
const _requestObj2 = httpFetch(`https://app.c.nf.migu.cn/MIGUM3.0/user/comment/stack/v1.0?pageSize=${limit}&queryType=2&resourceId=${musicInfo.songId}&resourceType=2&hotCommentStart=${(page - 1) * limit}`, {
3841
headers: {
39-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4195.1 Safari/537.36',
40-
Referer: 'https://music.migu.cn',
42+
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
43+
// Referer: 'https://music.migu.cn',
4144
},
4245
})
4346
const { body, statusCode } = await _requestObj2.promise
4447
// console.log(body)
45-
if (statusCode != 200 || body.returnCode !== '000000') throw new Error('获取热门评论失败')
46-
return { source: 'mg', comments: this.filterComment(body.data.items), total: body.data.itemTotal, page, limit, maxPage: Math.ceil(body.data.itemTotal / limit) || 1 }
48+
if (statusCode != 200 || body.code !== '000000') throw new Error('获取热门评论失败')
49+
const total = parseInt(body.data.cfgHotCount)
50+
return { source: 'mg', comments: this.filterComment(body.data.hotComments), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }
4751
},
4852
async getReplyComment(musicInfo, replyId, page = 1, limit = 10) {
4953
if (this._requestObj2) this._requestObj2.cancelHttp()
5054

51-
const _requestObj2 = httpFetch(`https://music.migu.cn/v3/api/comment/listCommentsById?commentId=${replyId}&pageSize=${limit}&pageNo=${page}`, {
55+
// const _requestObj2 = httpFetch(`https://music.migu.cn/v3/api/comment/listCommentsById?commentId=${replyId}&pageSize=${limit}&pageNo=${page}`, {
56+
const _requestObj2 = httpFetch(`https://app.c.nf.migu.cn/MIGUM3.0/user/comment/stack/${replyId}/v1.0?pageSize=${limit}&queryType=2&resourceId=${musicInfo.songId}&resourceType=2&start=${(page - 1) * limit}`, {
5257
headers: {
53-
'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi',
58+
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
5459
},
5560
})
5661
const { body, statusCode } = await _requestObj2.promise
5762
// console.log(body)
58-
if (statusCode != 200 || body.returnCode !== '000000') throw new Error('获取回复评论失败')
59-
return { source: 'mg', comments: this.filterComment(body.data.items) }
63+
if (statusCode != 200 || body.code !== '000000') throw new Error('获取回复评论失败')
64+
const total = parseInt(body.data.replyTotalCount)
65+
return { source: 'mg', comments: this.filterComment(body.data.mainCommentItem.replyComments), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }
6066
},
6167
filterComment(rawList) {
6268
return rawList.map(item => ({
6369
id: item.commentId,
64-
text: item.body,
65-
time: item.createTime,
66-
timeStr: dateFormat2(new Date(item.createTime).getTime()),
67-
userName: item.author.name,
68-
avatar: /^\/\//.test(item.author.avatar) ? `http:${item.author.avatar}` : item.author.avatar,
69-
userId: item.author.id,
70-
likedCount: item.praiseCount,
71-
replyNum: item.replyTotal,
72-
reply: item.replyCommentList.map(c => ({
73-
id: c.commentId,
74-
text: c.body,
75-
time: c.createTime,
76-
timeStr: dateFormat2(new Date(c.createTime).getTime()),
77-
userName: c.author.name,
78-
avatar: /^\/\//.test(c.author.avatar) ? `http:${c.author.avatar}` : c.author.avatar,
79-
userId: c.author.id,
80-
likedCount: c.praiseCount,
81-
replyNum: c.replyTotal,
70+
text: item.commentInfo,
71+
time: item.commentTime,
72+
timeStr: dateFormat2(new Date(item.commentTime).getTime()),
73+
userName: item.user.nickName,
74+
avatar: item.user.middleIcon || item.user.bigIcon || item.user.smallIcon,
75+
userId: item.user.userId,
76+
likedCount: item.opNumItem.thumbNum,
77+
replyNum: item.replyTotalCount,
78+
reply: item.replyComments.map(c => ({
79+
id: c.replyId,
80+
text: c.replyInfo,
81+
time: c.replyTime,
82+
timeStr: dateFormat2(new Date(c.replyTime).getTime()),
83+
userName: c.user.nickName,
84+
avatar: c.user.middleIcon || c.user.bigIcon || c.user.smallIcon,
85+
userId: c.user.userId,
86+
likedCount: null,
87+
replyNum: null,
8288
})),
8389
}))
8490
},

src/renderer/utils/musicSdk/mg/leaderboard.js

Lines changed: 112 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,84 @@ import { filterMusicInfoList } from './musicInfo'
33

44
// const boardList = [{ id: 'mg__27553319', name: '咪咕尖叫新歌榜', bangid: '27553319' }, { id: 'mg__27186466', name: '咪咕尖叫热歌榜', bangid: '27186466' }, { id: 'mg__27553408', name: '咪咕尖叫原创榜', bangid: '27553408' }, { id: 'mg__23189800', name: '咪咕港台榜', bangid: '23189800' }, { id: 'mg__23189399', name: '咪咕内地榜', bangid: '23189399' }, { id: 'mg__19190036', name: '咪咕欧美榜', bangid: '19190036' }, { id: 'mg__23189813', name: '咪咕日韩榜', bangid: '23189813' }, { id: 'mg__23190126', name: '咪咕彩铃榜', bangid: '23190126' }, { id: 'mg__15140045', name: '咪咕KTV榜', bangid: '15140045' }, { id: 'mg__15140034', name: '咪咕网络榜', bangid: '15140034' }, { id: 'mg__23217754', name: 'MV榜', bangid: '23217754' }, { id: 'mg__23218151', name: '新专辑榜', bangid: '23218151' }, { id: 'mg__21958042', name: 'iTunes榜', bangid: '21958042' }, { id: 'mg__21975570', name: 'billboard榜', bangid: '21975570' }, { id: 'mg__22272815', name: '台湾Hito中文榜', bangid: '22272815' }, { id: 'mg__22272904', name: '中国TOP排行榜', bangid: '22272904' }, { id: 'mg__22272943', name: '韩国Melon榜', bangid: '22272943' }, { id: 'mg__22273437', name: '英国UK榜', bangid: '22273437' }]
55

6+
// const boardList = [
7+
// { id: 'mg__27553319', name: '尖叫新歌榜', bangid: '27553319', webId: 'jianjiao_newsong' },
8+
// { id: 'mg__27186466', name: '尖叫热歌榜', bangid: '27186466', webId: 'jianjiao_hotsong' },
9+
// { id: 'mg__27553408', name: '尖叫原创榜', bangid: '27553408', webId: 'jianjiao_original' },
10+
// { id: 'mg__23189800', name: '港台榜', bangid: '23189800', webId: 'hktw' },
11+
// { id: 'mg__23189399', name: '内地榜', bangid: '23189399', webId: 'mainland' },
12+
// { id: 'mg__19190036', name: '欧美榜', bangid: '19190036', webId: 'eur_usa' },
13+
// { id: 'mg__23189813', name: '日韩榜', bangid: '23189813', webId: 'jpn_kor' },
14+
// { id: 'mg__23190126', name: '彩铃榜', bangid: '23190126', webId: 'coloring' },
15+
// { id: 'mg__15140045', name: 'KTV榜', bangid: '15140045', webId: 'ktv' },
16+
// { id: 'mg__15140034', name: '网络榜', bangid: '15140034', webId: 'network' },
17+
// // { id: 'mg__21958042', name: '美国iTunes榜', bangid: '21958042', webId: 'itunes' },
18+
// // { id: 'mg__21975570', name: '美国billboard榜', bangid: '21975570', webId: 'billboard' },
19+
// // { id: 'mg__22272815', name: '台湾Hito中文榜', bangid: '22272815', webId: 'hito' },
20+
// // { id: 'mg__22272943', name: '韩国Melon榜', bangid: '22272943', webId: 'mnet' },
21+
// // { id: 'mg__22273437', name: '英国UK榜', bangid: '22273437', webId: 'uk' },
22+
// ]
623
const boardList = [
7-
{ id: 'mg__27553319', name: '尖叫新歌榜', bangid: '27553319', webId: 'jianjiao_newsong' },
8-
{ id: 'mg__27186466', name: '尖叫热歌榜', bangid: '27186466', webId: 'jianjiao_hotsong' },
9-
{ id: 'mg__27553408', name: '尖叫原创榜', bangid: '27553408', webId: 'jianjiao_original' },
10-
{ id: 'mg__23189800', name: '港台榜', bangid: '23189800', webId: 'hktw' },
11-
{ id: 'mg__23189399', name: '内地榜', bangid: '23189399', webId: 'mainland' },
12-
{ id: 'mg__19190036', name: '欧美榜', bangid: '19190036', webId: 'eur_usa' },
13-
{ id: 'mg__23189813', name: '日韩榜', bangid: '23189813', webId: 'jpn_kor' },
14-
{ id: 'mg__23190126', name: '彩铃榜', bangid: '23190126', webId: 'coloring' },
15-
{ id: 'mg__15140045', name: 'KTV榜', bangid: '15140045', webId: 'ktv' },
16-
{ id: 'mg__15140034', name: '网络榜', bangid: '15140034', webId: 'network' },
17-
// { id: 'mg__21958042', name: '美国iTunes榜', bangid: '21958042', webId: 'itunes' },
18-
// { id: 'mg__21975570', name: '美国billboard榜', bangid: '21975570', webId: 'billboard' },
19-
// { id: 'mg__22272815', name: '台湾Hito中文榜', bangid: '22272815', webId: 'hito' },
20-
// { id: 'mg__22272943', name: '韩国Melon榜', bangid: '22272943', webId: 'mnet' },
21-
// { id: 'mg__22273437', name: '英国UK榜', bangid: '22273437', webId: 'uk' },
24+
{
25+
id: 'mg__27553319',
26+
name: '新歌榜',
27+
bangid: '27553319',
28+
source: 'mg',
29+
},
30+
{
31+
id: 'mg__27186466',
32+
name: '热歌榜',
33+
bangid: '27186466',
34+
source: 'mg',
35+
},
36+
{
37+
id: 'mg__27553408',
38+
name: '原创榜',
39+
bangid: '27553408',
40+
source: 'mg',
41+
},
42+
{
43+
id: 'mg__75959118',
44+
name: '音乐风向榜',
45+
bangid: '75959118',
46+
source: 'mg',
47+
},
48+
{
49+
id: 'mg__76557036',
50+
name: '彩铃分贝榜',
51+
bangid: '76557036',
52+
source: 'mg',
53+
},
54+
{
55+
id: 'mg__76557745',
56+
name: '会员臻爱榜',
57+
bangid: '76557745',
58+
source: 'mg',
59+
},
60+
{
61+
id: 'mg__23189800',
62+
name: '港台榜',
63+
bangid: '23189800',
64+
source: 'mg',
65+
},
66+
{
67+
id: 'mg__23189399',
68+
name: '内地榜',
69+
bangid: '23189399',
70+
source: 'mg',
71+
},
72+
{
73+
id: 'mg__19190036',
74+
name: '欧美榜',
75+
bangid: '19190036',
76+
source: 'mg',
77+
},
78+
{
79+
id: 'mg__83176390',
80+
name: '国风金曲榜',
81+
bangid: '83176390',
82+
source: 'mg',
83+
},
2284
]
2385
export default {
2486
limit: 200,
@@ -82,7 +144,8 @@ export default {
82144
requestBoardsObj: null,
83145
getBoardsData() {
84146
if (this.requestBoardsObj) this._requestBoardsObj.cancelHttp()
85-
this.requestBoardsObj = httpFetch('https://app.c.nf.migu.cn/MIGUM3.0/v1.0/template/rank-list/release', {
147+
this.requestBoardsObj = httpFetch('https://app.c.nf.migu.cn/pc/bmw/rank/rank-index/v1.0', {
148+
// this.requestBoardsObj = httpFetch('https://app.c.nf.migu.cn/MIGUM3.0/v1.0/template/rank-list/release', {
86149
// this.requestBoardsObj = httpFetch('https://app.c.nf.migu.cn/MIGUM2.0/v2.0/content/indexrank.do?templateVersion=8', {
87150
headers: {
88151
Referer: 'https://app.c.nf.migu.cn/',
@@ -96,24 +159,38 @@ export default {
96159
const requestObj = httpFetch(url)
97160
return requestObj.promise
98161
},
99-
filterBoardsData(rawList) {
100-
// console.log(rawList)
101-
let list = []
102-
for (const board of rawList) {
103-
if (board.template != 'group1') continue
104-
for (const item of board.itemList) {
105-
if ((item.template != 'row1' && item.template != 'grid1' && !item.actionUrl) || !item.actionUrl.includes('rank-info')) continue
162+
// filterBoardsData(listData, list = [], ids = new Set()) {
163+
// for (const item of listData) {
164+
// if (item.rankId && !ids.has(item.rankId)) {
165+
// ids.add(item.rankId)
166+
// list.push({
167+
// id: 'mg__' + item.rankId,
168+
// name: item.rankName,
169+
// bangid: String(item.rankId),
170+
// source: 'mg',
171+
// })
172+
// } else if (item.contents) this.filterBoardsData(item.contents, list, ids)
173+
// }
174+
// return list
175+
// },
176+
// filterBoardsData(rawList) {
177+
// // console.log(rawList)
178+
// let list = []
179+
// for (const board of rawList) {
180+
// if (board.template != 'group1') continue
181+
// for (const item of board.itemList) {
182+
// if ((item.template != 'row1' && item.template != 'grid1' && !item.actionUrl) || !item.actionUrl.includes('rank-info')) continue
106183

107-
let data = item.displayLogId.param
108-
list.push({
109-
id: 'mg__' + data.rankId,
110-
name: data.rankName,
111-
bangid: String(data.rankId),
112-
})
113-
}
114-
}
115-
return list
116-
},
184+
// let data = item.displayLogId.param
185+
// list.push({
186+
// id: 'mg__' + data.rankId,
187+
// name: data.rankName,
188+
// bangid: String(data.rankId),
189+
// })
190+
// }
191+
// }
192+
// return list
193+
// },
117194
async getBoards(retryNum = 0) {
118195
// if (++retryNum > 3) return Promise.reject(new Error('try max num'))
119196
// let response
@@ -124,8 +201,8 @@ export default {
124201
// }
125202
// // console.log(response.body.data.contentItemList)
126203
// if (response.statusCode !== 200 || response.body.code !== this.successCode) return this.getBoards(retryNum)
127-
// const list = this.filterBoardsData(response.body.data.contentItemList)
128-
// // console.log(list)
204+
// const list = this.filterBoardsData(response.body.data.contents)
205+
// console.log(list)
129206
// // console.log(JSON.stringify(list))
130207
// this.list = list
131208
// return {

0 commit comments

Comments
 (0)