修复MG源评论加载失败

This commit is contained in:
lyswhut
2025-11-26 13:41:22 +08:00
parent 0c71772953
commit 8142e5e79e
5 changed files with 157 additions and 71 deletions
+1
View File
@@ -17,6 +17,7 @@
- 尝试修复进度为0时仍然显示下载完成的问题 (#2471) - 尝试修复进度为0时仍然显示下载完成的问题 (#2471)
- 修复TX源搜索失败 (#2575 @Folltoshe) - 修复TX源搜索失败 (#2575 @Folltoshe)
- 修复MG源歌单加载失败 - 修复MG源歌单加载失败
- 修复MG源评论加载失败
### 变更 ### 变更
+2 -1
View File
@@ -74,7 +74,8 @@ const setList = (datas: SearchResult, page: number, text: string): LX.Music.Musi
} }
export const resetListInfo = (sourceId: LX.OnlineSource | 'all'): [] => { export const resetListInfo = (sourceId: LX.OnlineSource | 'all'): [] => {
let listInfo = listInfos[sourceId]! let listInfo = listInfos[sourceId]
if (!listInfo) return []
listInfo.list = [] listInfo.list = []
listInfo.page = 0 listInfo.page = 0
listInfo.maxPage = 0 listInfo.maxPage = 0
+2 -1
View File
@@ -72,7 +72,8 @@ const setList = (datas: SearchResult, page: number, text: string): ListInfoItem[
} }
export const resetListInfo = (sourceId: LX.OnlineSource | 'all'): [] => { export const resetListInfo = (sourceId: LX.OnlineSource | 'all'): [] => {
let listInfo = listInfos[sourceId]! let listInfo = listInfos[sourceId]
if (!listInfo) return []
listInfo.page = 1 listInfo.page = 1
listInfo.limit = 20 listInfo.limit = 20
listInfo.total = 0 listInfo.total = 0
+40 -34
View File
@@ -6,7 +6,7 @@ export default {
_requestObj: null, _requestObj: null,
_requestObj2: null, _requestObj2: null,
_requestObj3: null, _requestObj3: null,
async getComment(musicInfo, page = 1, limit = 10) { async getComment(musicInfo, page = 1, limit = 20) {
if (this._requestObj) this._requestObj.cancelHttp() if (this._requestObj) this._requestObj.cancelHttp()
if (!musicInfo.songId) { if (!musicInfo.songId) {
let id = await getSongId(musicInfo) let id = await getSongId(musicInfo)
@@ -14,18 +14,20 @@ export default {
musicInfo.songId = id musicInfo.songId = id
} }
const _requestObj = httpFetch(`https://music.migu.cn/v3/api/comment/listComments?targetId=${musicInfo.songId}&pageSize=${limit}&pageNo=${page}`, { // const _requestObj = httpFetch(`https://music.migu.cn/v3/api/comment/listComments?targetId=${musicInfo.songId}&pageSize=${limit}&pageNo=${page}`, {
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}`, {
headers: { headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4195.1 Safari/537.36', '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',
Referer: 'https://music.migu.cn', // Referer: 'https://music.migu.cn',
}, },
}) })
const { body, statusCode } = await _requestObj.promise const { body, statusCode } = await _requestObj.promise
// console.log(body) // console.log(body)
if (statusCode != 200 || body.returnCode !== '000000') throw new Error('获取评论失败') if (statusCode != 200 || body.code !== '000000') throw new Error('获取评论失败')
return { source: 'mg', comments: this.filterComment(body.data.items), total: body.data.itemTotal, page, limit, maxPage: Math.ceil(body.data.itemTotal / limit) || 1 } const total = parseInt(body.data.commentNums)
return { source: 'mg', comments: this.filterComment(body.data.comments), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }
}, },
async getHotComment(musicInfo, page = 1, limit = 5) { async getHotComment(musicInfo, page = 1, limit = 20) {
if (this._requestObj2) this._requestObj2.cancelHttp() if (this._requestObj2) this._requestObj2.cancelHttp()
if (!musicInfo.songId) { if (!musicInfo.songId) {
@@ -34,51 +36,55 @@ export default {
musicInfo.songId = id musicInfo.songId = id
} }
const _requestObj2 = httpFetch(`https://music.migu.cn/v3/api/comment/listTopComments?targetId=${musicInfo.songId}&pageSize=${limit}&pageNo=${page}`, { // const _requestObj2 = httpFetch(`https://music.migu.cn/v3/api/comment/listTopComments?targetId=${musicInfo.songId}&pageSize=${limit}&pageNo=${page}`, {
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}`, {
headers: { headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4195.1 Safari/537.36', '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',
Referer: 'https://music.migu.cn', // Referer: 'https://music.migu.cn',
}, },
}) })
const { body, statusCode } = await _requestObj2.promise const { body, statusCode } = await _requestObj2.promise
// console.log(body) // console.log(body)
if (statusCode != 200 || body.returnCode !== '000000') throw new Error('获取热门评论失败') if (statusCode != 200 || body.code !== '000000') throw new Error('获取热门评论失败')
return { source: 'mg', comments: this.filterComment(body.data.items), total: body.data.itemTotal, page, limit, maxPage: Math.ceil(body.data.itemTotal / limit) || 1 } const total = parseInt(body.data.cfgHotCount)
return { source: 'mg', comments: this.filterComment(body.data.hotComments), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }
}, },
async getReplyComment(musicInfo, replyId, page = 1, limit = 10) { async getReplyComment(musicInfo, replyId, page = 1, limit = 10) {
if (this._requestObj2) this._requestObj2.cancelHttp() if (this._requestObj2) this._requestObj2.cancelHttp()
const _requestObj2 = httpFetch(`https://music.migu.cn/v3/api/comment/listCommentsById?commentId=${replyId}&pageSize=${limit}&pageNo=${page}`, { // const _requestObj2 = httpFetch(`https://music.migu.cn/v3/api/comment/listCommentsById?commentId=${replyId}&pageSize=${limit}&pageNo=${page}`, {
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}`, {
headers: { headers: {
'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi', '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',
}, },
}) })
const { body, statusCode } = await _requestObj2.promise const { body, statusCode } = await _requestObj2.promise
// console.log(body) // console.log(body)
if (statusCode != 200 || body.returnCode !== '000000') throw new Error('获取回复评论失败') if (statusCode != 200 || body.code !== '000000') throw new Error('获取回复评论失败')
return { source: 'mg', comments: this.filterComment(body.data.items) } const total = parseInt(body.data.replyTotalCount)
return { source: 'mg', comments: this.filterComment(body.data.mainCommentItem.replyComments), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }
}, },
filterComment(rawList) { filterComment(rawList) {
return rawList.map(item => ({ return rawList.map(item => ({
id: item.commentId, id: item.commentId,
text: item.body, text: item.commentInfo,
time: item.createTime, time: item.commentTime,
timeStr: dateFormat2(new Date(item.createTime).getTime()), timeStr: dateFormat2(new Date(item.commentTime).getTime()),
userName: item.author.name, userName: item.user.nickName,
avatar: /^\/\//.test(item.author.avatar) ? `http:${item.author.avatar}` : item.author.avatar, avatar: item.user.middleIcon || item.user.bigIcon || item.user.smallIcon,
userId: item.author.id, userId: item.user.userId,
likedCount: item.praiseCount, likedCount: item.opNumItem.thumbNum,
replyNum: item.replyTotal, replyNum: item.replyTotalCount,
reply: item.replyCommentList.map(c => ({ reply: item.replyComments.map(c => ({
id: c.commentId, id: c.replyId,
text: c.body, text: c.replyInfo,
time: c.createTime, time: c.replyTime,
timeStr: dateFormat2(new Date(c.createTime).getTime()), timeStr: dateFormat2(new Date(c.replyTime).getTime()),
userName: c.author.name, userName: c.user.nickName,
avatar: /^\/\//.test(c.author.avatar) ? `http:${c.author.avatar}` : c.author.avatar, avatar: c.user.middleIcon || c.user.bigIcon || c.user.smallIcon,
userId: c.author.id, userId: c.user.userId,
likedCount: c.praiseCount, likedCount: null,
replyNum: c.replyTotal, replyNum: null,
})), })),
})) }))
}, },
+112 -35
View File
@@ -3,22 +3,84 @@ import { filterMusicInfoList } from './musicInfo'
// 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' }] // 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' }]
// const boardList = [
// { id: 'mg__27553319', name: '尖叫新歌榜', bangid: '27553319', webId: 'jianjiao_newsong' },
// { id: 'mg__27186466', name: '尖叫热歌榜', bangid: '27186466', webId: 'jianjiao_hotsong' },
// { id: 'mg__27553408', name: '尖叫原创榜', bangid: '27553408', webId: 'jianjiao_original' },
// { id: 'mg__23189800', name: '港台榜', bangid: '23189800', webId: 'hktw' },
// { id: 'mg__23189399', name: '内地榜', bangid: '23189399', webId: 'mainland' },
// { id: 'mg__19190036', name: '欧美榜', bangid: '19190036', webId: 'eur_usa' },
// { id: 'mg__23189813', name: '日韩榜', bangid: '23189813', webId: 'jpn_kor' },
// { id: 'mg__23190126', name: '彩铃榜', bangid: '23190126', webId: 'coloring' },
// { id: 'mg__15140045', name: 'KTV榜', bangid: '15140045', webId: 'ktv' },
// { id: 'mg__15140034', name: '网络榜', bangid: '15140034', webId: 'network' },
// // { id: 'mg__21958042', name: '美国iTunes榜', bangid: '21958042', webId: 'itunes' },
// // { id: 'mg__21975570', name: '美国billboard榜', bangid: '21975570', webId: 'billboard' },
// // { id: 'mg__22272815', name: '台湾Hito中文榜', bangid: '22272815', webId: 'hito' },
// // { id: 'mg__22272943', name: '韩国Melon榜', bangid: '22272943', webId: 'mnet' },
// // { id: 'mg__22273437', name: '英国UK榜', bangid: '22273437', webId: 'uk' },
// ]
const boardList = [ const boardList = [
{ id: 'mg__27553319', name: '尖叫新歌榜', bangid: '27553319', webId: 'jianjiao_newsong' }, {
{ id: 'mg__27186466', name: '尖叫热歌榜', bangid: '27186466', webId: 'jianjiao_hotsong' }, id: 'mg__27553319',
{ id: 'mg__27553408', name: '尖叫原创榜', bangid: '27553408', webId: 'jianjiao_original' }, name: '新歌榜',
{ id: 'mg__23189800', name: '港台榜', bangid: '23189800', webId: 'hktw' }, bangid: '27553319',
{ id: 'mg__23189399', name: '内地榜', bangid: '23189399', webId: 'mainland' }, source: 'mg',
{ id: 'mg__19190036', name: '欧美榜', bangid: '19190036', webId: 'eur_usa' }, },
{ id: 'mg__23189813', name: '日韩榜', bangid: '23189813', webId: 'jpn_kor' }, {
{ id: 'mg__23190126', name: '彩铃榜', bangid: '23190126', webId: 'coloring' }, id: 'mg__27186466',
{ id: 'mg__15140045', name: 'KTV榜', bangid: '15140045', webId: 'ktv' }, name: '热歌榜',
{ id: 'mg__15140034', name: '网络榜', bangid: '15140034', webId: 'network' }, bangid: '27186466',
// { id: 'mg__21958042', name: '美国iTunes榜', bangid: '21958042', webId: 'itunes' }, source: 'mg',
// { id: 'mg__21975570', name: '美国billboard榜', bangid: '21975570', webId: 'billboard' }, },
// { id: 'mg__22272815', name: '台湾Hito中文榜', bangid: '22272815', webId: 'hito' }, {
// { id: 'mg__22272943', name: '韩国Melon榜', bangid: '22272943', webId: 'mnet' }, id: 'mg__27553408',
// { id: 'mg__22273437', name: '英国UK榜', bangid: '22273437', webId: 'uk' }, name: '原创榜',
bangid: '27553408',
source: 'mg',
},
{
id: 'mg__75959118',
name: '音乐风向榜',
bangid: '75959118',
source: 'mg',
},
{
id: 'mg__76557036',
name: '彩铃分贝榜',
bangid: '76557036',
source: 'mg',
},
{
id: 'mg__76557745',
name: '会员臻爱榜',
bangid: '76557745',
source: 'mg',
},
{
id: 'mg__23189800',
name: '港台榜',
bangid: '23189800',
source: 'mg',
},
{
id: 'mg__23189399',
name: '内地榜',
bangid: '23189399',
source: 'mg',
},
{
id: 'mg__19190036',
name: '欧美榜',
bangid: '19190036',
source: 'mg',
},
{
id: 'mg__83176390',
name: '国风金曲榜',
bangid: '83176390',
source: 'mg',
},
] ]
export default { export default {
limit: 200, limit: 200,
@@ -82,7 +144,8 @@ export default {
requestBoardsObj: null, requestBoardsObj: null,
getBoardsData() { getBoardsData() {
if (this.requestBoardsObj) this._requestBoardsObj.cancelHttp() if (this.requestBoardsObj) this._requestBoardsObj.cancelHttp()
this.requestBoardsObj = httpFetch('https://app.c.nf.migu.cn/MIGUM3.0/v1.0/template/rank-list/release', { this.requestBoardsObj = httpFetch('https://app.c.nf.migu.cn/pc/bmw/rank/rank-index/v1.0', {
// this.requestBoardsObj = httpFetch('https://app.c.nf.migu.cn/MIGUM3.0/v1.0/template/rank-list/release', {
// this.requestBoardsObj = httpFetch('https://app.c.nf.migu.cn/MIGUM2.0/v2.0/content/indexrank.do?templateVersion=8', { // this.requestBoardsObj = httpFetch('https://app.c.nf.migu.cn/MIGUM2.0/v2.0/content/indexrank.do?templateVersion=8', {
headers: { headers: {
Referer: 'https://app.c.nf.migu.cn/', Referer: 'https://app.c.nf.migu.cn/',
@@ -96,24 +159,38 @@ export default {
const requestObj = httpFetch(url) const requestObj = httpFetch(url)
return requestObj.promise return requestObj.promise
}, },
filterBoardsData(rawList) { // filterBoardsData(listData, list = [], ids = new Set()) {
// console.log(rawList) // for (const item of listData) {
let list = [] // if (item.rankId && !ids.has(item.rankId)) {
for (const board of rawList) { // ids.add(item.rankId)
if (board.template != 'group1') continue // list.push({
for (const item of board.itemList) { // id: 'mg__' + item.rankId,
if ((item.template != 'row1' && item.template != 'grid1' && !item.actionUrl) || !item.actionUrl.includes('rank-info')) continue // name: item.rankName,
// bangid: String(item.rankId),
// source: 'mg',
// })
// } else if (item.contents) this.filterBoardsData(item.contents, list, ids)
// }
// return list
// },
// filterBoardsData(rawList) {
// // console.log(rawList)
// let list = []
// for (const board of rawList) {
// if (board.template != 'group1') continue
// for (const item of board.itemList) {
// if ((item.template != 'row1' && item.template != 'grid1' && !item.actionUrl) || !item.actionUrl.includes('rank-info')) continue
let data = item.displayLogId.param // let data = item.displayLogId.param
list.push({ // list.push({
id: 'mg__' + data.rankId, // id: 'mg__' + data.rankId,
name: data.rankName, // name: data.rankName,
bangid: String(data.rankId), // bangid: String(data.rankId),
}) // })
} // }
} // }
return list // return list
}, // },
async getBoards(retryNum = 0) { async getBoards(retryNum = 0) {
// if (++retryNum > 3) return Promise.reject(new Error('try max num')) // if (++retryNum > 3) return Promise.reject(new Error('try max num'))
// let response // let response
@@ -124,8 +201,8 @@ export default {
// } // }
// // console.log(response.body.data.contentItemList) // // console.log(response.body.data.contentItemList)
// if (response.statusCode !== 200 || response.body.code !== this.successCode) return this.getBoards(retryNum) // if (response.statusCode !== 200 || response.body.code !== this.successCode) return this.getBoards(retryNum)
// const list = this.filterBoardsData(response.body.data.contentItemList) // const list = this.filterBoardsData(response.body.data.contents)
// // console.log(list) // console.log(list)
// // console.log(JSON.stringify(list)) // // console.log(JSON.stringify(list))
// this.list = list // this.list = list
// return { // return {