更新kg最新评论接口(cmtlist->newest) & kg源歌手相关 (#1405)
* 修复wy源热搜词失效 * 更新kg最新评论接口(cmtlist->newest) & kg源歌手相关 --------- Co-authored-by: Folltoshe <folltoshe@foxmail.com>pull/1411/head
parent
76981a59d4
commit
b1a6c6b59c
|
@ -10,7 +10,7 @@ export default {
|
||||||
|
|
||||||
let timestamp = Date.now()
|
let timestamp = Date.now()
|
||||||
const params = `appid=1005&clienttime=${timestamp}&clienttoken=0&clientver=11409&code=fc4be23b4e972707f36b8a828a93ba8a&dfid=0&extdata=${hash}&kugouid=0&mid=16249512204336365674023395779019&mixsongid=0&p=${page}&pagesize=${limit}&uuid=0&ver=10`
|
const params = `appid=1005&clienttime=${timestamp}&clienttoken=0&clientver=11409&code=fc4be23b4e972707f36b8a828a93ba8a&dfid=0&extdata=${hash}&kugouid=0&mid=16249512204336365674023395779019&mixsongid=0&p=${page}&pagesize=${limit}&uuid=0&ver=10`
|
||||||
const _requestObj = httpFetch(`http://m.comment.service.kugou.com/v1/cmtlist?${params}&signature=${signatureParams(params)}`, {
|
const _requestObj = httpFetch(`http://m.comment.service.kugou.com/r/v1/rank/newest?${params}&signature=${signatureParams(params)}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.24',
|
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.24',
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
import { httpFetch } from '../../request'
|
||||||
|
// import { decodeName, formatPlayTime, sizeFormate } from '../../index'
|
||||||
|
// import { signatureParams } from './util'
|
||||||
|
import { getMusicInfosByList } from './musicInfo'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
filterAlbum(rawList) {
|
||||||
|
let returnList = []
|
||||||
|
rawList.forEach((albumInfo) => {
|
||||||
|
returnList.push({
|
||||||
|
name: albumInfo.albumname,
|
||||||
|
author: albumInfo.singername,
|
||||||
|
img: albumInfo.replaceAll('{size}', '480'),
|
||||||
|
album_id: albumInfo.albumid,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async getSingerInfo(singerid) {
|
||||||
|
if (singerid == 0) throw new Error('歌手不存在') // kg源某些歌曲在歌手没被kg收录时返回的歌手id为0
|
||||||
|
const requestObj = httpFetch(`http://mobiles.kugou.com/api/v5/singer/info?singerid=${singerid}`)
|
||||||
|
let { body, statusCode } = await requestObj.promise
|
||||||
|
if (statusCode !== 200) throw new Error('获取歌手信息失败')
|
||||||
|
return {
|
||||||
|
source: 'kg',
|
||||||
|
singerid,
|
||||||
|
info: {
|
||||||
|
name: body.data.singername,
|
||||||
|
desc: body.data.intro,
|
||||||
|
img: body.data.imgurl.replace('{size}', '480')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getSingerSongList(singerid, page, limit) {
|
||||||
|
if (singerid == 0) throw new Error('歌手不存在') // kg源某些歌曲在歌手没被kg收录时返回的歌手id为0
|
||||||
|
const requestObj = httpFetch(`http://mobiles.kugou.com/api/v5/singer/song?singerid=${singerid}&page=${page}&pagesize=${limit}`)
|
||||||
|
let { body, statusCode } = await requestObj.promise
|
||||||
|
if (statusCode !== 200) throw new Error('获取歌手歌曲列表失败')
|
||||||
|
let listData = await getMusicInfosByList(body.data.info)
|
||||||
|
return {
|
||||||
|
source: 'kg',
|
||||||
|
list: listData,
|
||||||
|
id: `kg__singer_${singerid}`,
|
||||||
|
singerid,
|
||||||
|
total: body.data.total,
|
||||||
|
allPage: Math.ceil(body.data.total / limit),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getSingerAlbumList(singerid, page, limit) {
|
||||||
|
if (singerid == 0) throw new Error('歌手不存在') // kg源某些歌曲在歌手没被kg收录时返回的歌手id为0
|
||||||
|
const requestObj = httpFetch(`http://mobiles.kugou.com/api/v5/singer/song?singerid=${singerid}&page=${page}&pagesize=${limit}`)
|
||||||
|
let { body, statusCode } = await requestObj.promise
|
||||||
|
if (statusCode !== 200) throw new Error('获取歌手专辑列表失败')
|
||||||
|
return {
|
||||||
|
source: 'kg',
|
||||||
|
albums: this.filterAlbum(body.data.info),
|
||||||
|
singerid,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue