kg源评论接口更新,热门评论完整支持|这次才是对的,上次是搜索的HiRes
This commit is contained in:
parent
33f4951f5f
commit
16a0b849e4
@ -1,27 +1,35 @@
|
|||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { decodeName, dateFormat2 } from '../../index'
|
import { decodeName, dateFormat2 } from '../../index'
|
||||||
|
import { toMD5 } from '../utils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
_requestObj: null,
|
_requestObj: null,
|
||||||
_requestObj2: null,
|
_requestObj2: null,
|
||||||
async getComment({ hash }, page = 1, limit = 20) {
|
async getComment({ hash, songmid }, page = 1, limit = 20) {
|
||||||
if (this._requestObj) this._requestObj.cancelHttp()
|
if (this._requestObj) this._requestObj.cancelHttp()
|
||||||
|
|
||||||
const _requestObj = httpFetch(`http://comment.service.kugou.com/index.php?r=commentsv2/getCommentWithLike&code=fc4be23b4e972707f36b8a828a93ba8a&extdata=${hash}&p=${page}&pagesize=${limit}&ver=1.01&clientver=8373&appid=1001&kugouid=687373022&need_show_image=1`, {
|
let timestamp = Date.now()
|
||||||
|
let OIlwieks = '28dk2k092lksi2UIkp'
|
||||||
|
let sign_params = `OIlwieks${OIlwieks}appid=1005childrenid=${songmid}clienttime=${timestamp}clienttoken=0364933ef7daa8c0f150e91b49e6bc38ceaf106e6c49400c230936282b0a0dd8clientver=11409code=fc4be23b4e972707f36b8a828a93ba8adfid=347VvU1FGsNW0XwQu30ZZolsextdata=${hash}kugouid=0mid=162495122043363656740233957790194166813mixsongid=0p=${page}pagesize=${limit}uuid=0ver=10OIlwieks${OIlwieks}`
|
||||||
|
let signature = toMD5(sign_params)
|
||||||
|
const _requestObj = httpFetch(`http://m.comment.service.kugou.com/v1/cmtlist?dfid=347VvU1FGsNW0XwQu30ZZols&mid=162495122043363656740233957790194166813&signature=${signature}&clienttime=${timestamp}&uuid=0&extdata=${hash}&appid=1005&code=fc4be23b4e972707f36b8a828a93ba8a&childrenid=${songmid}&clientver=11409&p=${page}&mixsongid=0&clienttoken=0364933ef7daa8c0f150e91b49e6bc38ceaf106e6c49400c230936282b0a0dd8&pagesize=${limit}&ver=10&kugouid=0`, {
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi',
|
'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',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const { body, statusCode } = await _requestObj.promise
|
const { body, statusCode } = await _requestObj.promise
|
||||||
// console.log(body)
|
// console.log(body)
|
||||||
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取评论失败')
|
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取评论失败')
|
||||||
return { source: 'kg', comments: this.filterComment(body.list || []), total: body.count, page, limit, maxPage: Math.ceil(body.count / limit) || 1 }
|
return { source: 'kg', comments: this.filterComment(body.list || []), total: body.count, page, limit, maxPage: body.maxPage }
|
||||||
},
|
},
|
||||||
async getHotComment({ hash, songmid }, page = 1, limit = 100) {
|
async getHotComment({ hash, songmid }, page = 1, limit = 20) {
|
||||||
// console.log(songmid)
|
// console.log(songmid)
|
||||||
if (this._requestObj2) this._requestObj2.cancelHttp()
|
if (this._requestObj2) this._requestObj2.cancelHttp()
|
||||||
|
let timestamp = Date.now()
|
||||||
const _requestObj2 = httpFetch(`http://comment.service.kugou.com/index.php?r=commentsv2/getCommentWithLike&code=fc4be23b4e972707f36b8a828a93ba8a&extdata=${hash}&p=${page}&pagesize=${limit}&ver=1.01&clientver=8373&appid=1001&kugouid=687373022&need_show_image=1`, {
|
let OIlwieks = '28dk2k092lksi2UIkp'
|
||||||
|
let sign_params = `OIlwieks${OIlwieks}appid=1005childrenid=${songmid}clienttime=${timestamp}clienttoken=0364933ef7daa8c0f150e91b49e6bc38ceaf106e6c49400c230936282b0a0dd8clientver=11409code=fc4be23b4e972707f36b8a828a93ba8adfid=347VvU1FGsNW0XwQu30ZZolsextdata=${hash}kugouid=0mid=162495122043363656740233957790194166813mixsongid=0p=${page}pagesize=${limit}uuid=0ver=10OIlwieks${OIlwieks}`
|
||||||
|
let signature = toMD5(sign_params)
|
||||||
|
const _requestObj2 = httpFetch(`http://m.comment.service.kugou.com/v1/weightlist?dfid=347VvU1FGsNW0XwQu30ZZols&mid=162495122043363656740233957790194166813&signature=${signature}&clienttime=${timestamp}&uuid=0&extdata=${hash}&appid=1005&code=fc4be23b4e972707f36b8a828a93ba8a&childrenid=${songmid}&clientver=11409&p=${page}&mixsongid=0&clienttoken=0364933ef7daa8c0f150e91b49e6bc38ceaf106e6c49400c230936282b0a0dd8&pagesize=${limit}&ver=10&kugouid=0`, {
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi',
|
'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi',
|
||||||
},
|
},
|
||||||
@ -29,8 +37,8 @@ export default {
|
|||||||
const { body, statusCode } = await _requestObj2.promise
|
const { body, statusCode } = await _requestObj2.promise
|
||||||
// console.log(body)
|
// console.log(body)
|
||||||
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取热门评论失败')
|
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取热门评论失败')
|
||||||
const total = body.weightList?.length ?? 0
|
const total = body.count ?? 0
|
||||||
return { source: 'kg', comments: this.filterComment(body.weightList || []), total, page, limit, maxPage: 1 }
|
return { source: 'kg', comments: this.filterComment(body.list || []), total, page, limit, maxPage: Math.ceil(body.count / limit) || 1 }
|
||||||
},
|
},
|
||||||
async getReplyComment({ songmid, audioId }, replyId, page = 1, limit = 100) {
|
async getReplyComment({ songmid, audioId }, replyId, page = 1, limit = 100) {
|
||||||
if (this._requestObj2) this._requestObj2.cancelHttp()
|
if (this._requestObj2) this._requestObj2.cancelHttp()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user