音源API更新 & 其他改动 (#1295)

## API

### kg源

- 增加歌单歌曲flac24bit显示
- 修复酷狗码只能导入500首的问题
- 更新排行榜

### mg源

- 修复搜索不显示时长的问题
- 修复评论加载失败的问题
- 更新排行榜

### tx源

- 增加热门评论图片显示
- 更新排行榜

### wy源

- 更新排行榜

## 其他

- 添加自定义源zlib模块的支持

---------

Co-authored-by: 彭狸花喵 <94218819+helloplhm-qwq@users.noreply.github.com>
Co-authored-by: lyswhut <lyswhut@qq.com>
This commit is contained in:
Folltoshe
2023-04-13 14:32:59 +08:00
committed by GitHub
co-authored by 彭狸花喵 lyswhut
parent d0425fc0d6
commit d970687ebe
32 changed files with 713 additions and 426 deletions
+1 -3
View File
@@ -18,9 +18,7 @@ const api_messoer = {
return requestObj
},
getPic(songInfo) {
return {
promise: Promise.resolve(`https://y.gtimg.cn/music/photo_new/T002R500x500M000${songInfo.albumId}.jpg`),
}
return Promise.resolve(`https://y.gtimg.cn/music/photo_new/T002R500x500M000${songInfo.albumId}.jpg`)
},
}
+107 -25
View File
@@ -124,40 +124,75 @@ export default {
maxPage: Math.ceil(comment.commenttotal / limit) || 1,
}
},
async getHotComment(mInfo, page = 1, limit = 100) {
async getHotComment(mInfo, page = 1, limit = 20) {
if (this._requestObj2) this._requestObj2.cancelHttp()
const songId = await this.getSongId(mInfo)
const _requestObj2 = httpFetch('http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg', {
method: 'POST',
headers: {
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
// const _requestObj2 = httpFetch('http://c.y.qq.com/base/fcgi-bin/fcg_global_comment_h5.fcg', {
// method: 'POST',
// headers: {
// 'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
// },
// form: {
// uin: '0',
// format: 'json',
// cid: '205360772',
// reqtype: '2',
// biztype: '1',
// topid: songId,
// cmd: '9',
// needmusiccrit: '1',
// pagenum: page - 1,
// pagesize: limit,
// },
// })
const _requestObj2 = httpFetch('https://u.y.qq.com/cgi-bin/musicu.fcg', {
method: 'post',
body: {
comm: {
cv: 4747474,
ct: 24,
format: 'json',
inCharset: 'utf-8',
outCharset: 'utf-8',
notice: 0,
platform: 'yqq.json',
needNewCode: 1,
uin: 0,
// g_tk_new_20200303: 2101046530,
// g_tk: 2101046530,
},
req: {
module: 'music.globalComment.CommentRead',
method: 'GetHotCommentList',
param: {
BizType: 1,
BizId: String(songId),
LastCommentSeqNo: '',
PageSize: limit,
PageNum: page - 1,
HotType: 1,
WithAirborne: 0,
PicEnable: 1,
},
},
},
form: {
uin: '0',
format: 'json',
cid: '205360772',
reqtype: '2',
biztype: '1',
topid: songId,
cmd: '9',
needmusiccrit: '1',
pagenum: page - 1,
pagesize: limit,
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.0.0',
referer: 'https://y.qq.com/',
},
})
const { body, statusCode } = await _requestObj2.promise
if (statusCode != 200 || body.code !== 0) throw new Error('获取热门评论失败')
// console.log(body, statusCode)
const comment = body.comment
// console.log('body', body)
if (statusCode != 200 || body.code !== 0 || body.req.code !== 0) throw new Error('获取热门评论失败')
const comment = body.req.data.CommentList
return {
source: 'tx',
comments: this.filterComment(comment.commentlist),
total: comment.commenttotal,
comments: this.filterHotComment(comment.Comments),
total: comment.Total,
page,
limit,
maxPage: Math.ceil(comment.commenttotal / limit) || 1,
maxPage: Math.ceil(comment.Total / limit) || 1,
}
},
replaceEmoji(msg) {
@@ -186,7 +221,7 @@ export default {
return {
id: `${item.rootcommentid}_${item.commentid}`,
rootId: item.rootcommentid,
text: item.rootcommentcontent ? this.replaceEmoji(item.rootcommentcontent).replace(/\\n/g, '\n').split('\n') : [],
text: item.rootcommentcontent ? this.replaceEmoji(item.rootcommentcontent).replace(/\\n/g, '\n') : '',
time: item.rootcommentid == item.commentid ? time : null,
timeStr: item.rootcommentid == item.commentid ? timeStr : null,
userName: item.rootcommentnick ? item.rootcommentnick.substring(1) : '',
@@ -198,7 +233,7 @@ export default {
// let index = c.subcommentid.lastIndexOf('_')
return {
id: `sub_${item.rootcommentid}_${c.subcommentid}`,
text: this.replaceEmoji(c.subcommentcontent).replace(/\\n/g, '\n').split('\n'),
text: this.replaceEmoji(c.subcommentcontent).replace(/\\n/g, '\n'),
time: c.subcommentid == item.commentid ? time : null,
timeStr: c.subcommentid == item.commentid ? timeStr : null,
userName: c.replynick.substring(1),
@@ -211,4 +246,51 @@ export default {
}
})
},
filterHotComment(rawList) {
// console.log(rawList)
return rawList.map(item => {
// let time = String(item.PubTime).length < 10 ? null : parseInt(item.PubTime + '000')
// let timeStr = time ? dateFormat2(time) : null
// if (item.SubComments) {
// let firstItem = item.SubComments[0]
// firstItem.avatarurl = item.avatarurl
// firstItem.praisenum = item.praisenum
// item.avatarurl = null
// item.praisenum = null
// item.SubComments.reverse()
// }
return {
id: `${item.SeqNo}_${item.EncryptUin}`,
rootId: item.SeqNo,
text: item.Content ? this.replaceEmoji(item.Content).replace(/\\n/g, '\n') : '',
time: this.formatTime(item.PubTime),
timeStr: item.PubTime ? dateFormat2(this.formatTime(item.PubTime)) : null,
userName: item.Nick ? item.Nick.substring(1) : '',
images: item.Pic ? [item.Pic] : [],
avatar: item.Avatar,
location: item.Location ? ('来自' + item.Location) : '',
userId: item.EncryptUin,
likedCount: item.PraiseNum,
reply: item.SubComments
? item.SubComments.map(c => {
// let index = c.subcommentid.lastIndexOf('_')
return {
id: `sub_${item.SeqNo}_${c.EncryptUin}`,
text: this.replaceEmoji(c.Content).replace(/\\n/g, '\n'),
time: this.formatTime(c.PubTime),
timeStr: item.PubTime ? dateFormat2(this.formatTime(c.PubTime)) : null,
userName: c.Nick.substring(1),
avatar: c.Avatar,
images: item.Pic ? [item.Pic] : [],
userId: c.EncryptUin,
likedCount: c.PraiseNum,
}
})
: [],
}
})
},
formatTime(time) {
return String(time).length < 10 ? null : parseInt(time + '000')
},
}
@@ -1,7 +1,7 @@
import { httpFetch } from '../../request'
import { formatPlayTime, sizeFormate } from '../../index'
let boardList = [{ id: 'tx__4', name: '流行指数榜', bangid: '4' }, { id: 'tx__26', name: '热歌榜', bangid: '26' }, { id: 'tx__27', name: '新歌榜', bangid: '27' }, { id: 'tx__62', name: '飙升榜', bangid: '62' }, { id: 'tx__58', name: '说唱榜', bangid: '58' }, { id: 'tx__57', name: '电音榜', bangid: '57' }, { id: 'tx__28', name: '网络歌曲榜', bangid: '28' }, { id: 'tx__5', name: '内地榜', bangid: '5' }, { id: 'tx__3', name: '欧美榜', bangid: '3' }, { id: 'tx__59', name: '香港地区榜', bangid: '59' }, { id: 'tx__16', name: '韩国榜', bangid: '16' }, { id: 'tx__60', name: '抖音排行榜', bangid: '60' }, { id: 'tx__29', name: '影视金曲榜', bangid: '29' }, { id: 'tx__17', name: '日本榜', bangid: '17' }, { id: 'tx__52', name: '腾讯音乐人原创榜', bangid: '52' }, { id: 'tx__36', name: 'K歌金曲榜', bangid: '36' }, { id: 'tx__61', name: '台湾地区榜', bangid: '61' }, { id: 'tx__63', name: 'DJ舞曲榜', bangid: '63' }, { id: 'tx__64', name: '综艺新歌榜', bangid: '64' }, { id: 'tx__65', name: '国风热歌榜', bangid: '65' }, { id: 'tx__66', name: 'ACG新歌榜', bangid: '66' }, { id: 'tx__67', name: '听歌识曲榜', bangid: '67' }, { id: 'tx__70', name: '达人音乐榜', bangid: '70' }]
let boardList = [{ id: 'tx__4', name: '流行指数榜', bangid: '4' }, { id: 'tx__26', name: '热歌榜', bangid: '26' }, { id: 'tx__27', name: '新歌榜', bangid: '27' }, { id: 'tx__62', name: '飙升榜', bangid: '62' }, { id: 'tx__58', name: '说唱榜', bangid: '58' }, { id: 'tx__57', name: '喜力电音榜', bangid: '57' }, { id: 'tx__28', name: '网络歌曲榜', bangid: '28' }, { id: 'tx__5', name: '内地榜', bangid: '5' }, { id: 'tx__3', name: '欧美榜', bangid: '3' }, { id: 'tx__59', name: '香港地区榜', bangid: '59' }, { id: 'tx__16', name: '韩国榜', bangid: '16' }, { id: 'tx__60', name: '抖快榜', bangid: '60' }, { id: 'tx__29', name: '影视金曲榜', bangid: '29' }, { id: 'tx__17', name: '日本榜', bangid: '17' }, { id: 'tx__52', name: '腾讯音乐人原创榜', bangid: '52' }, { id: 'tx__36', name: 'K歌金曲榜', bangid: '36' }, { id: 'tx__61', name: '台湾地区榜', bangid: '61' }, { id: 'tx__63', name: 'DJ舞曲榜', bangid: '63' }, { id: 'tx__64', name: '综艺新歌榜', bangid: '64' }, { id: 'tx__65', name: '国风热歌榜', bangid: '65' }, { id: 'tx__67', name: '听歌识曲榜', bangid: '67' }, { id: 'tx__72', name: '动漫音乐榜', bangid: '72' }, { id: 'tx__73', name: '游戏音乐榜', bangid: '73' }, { id: 'tx__75', name: '有声榜', bangid: '75' }, { id: 'tx__131', name: '校园音乐人排行榜', bangid: '131' }]
export default {
limit: 300,
@@ -214,7 +214,8 @@ export default {
// // console.log(response.body)
// if (response.statusCode !== 200 || response.body.code !== 0) return this.getBoards(retryNum)
// const list = this.filterBoardsData(response.body.data.topList)
// // console.log(list)
// console.log(list)
// console.log(JSON.stringify(list))
// this.list = list
// return {
// list,