优化参数生成

This commit is contained in:
lyswhut 2023-03-05 16:50:24 +08:00
parent 985b61cbf4
commit d880a7834e

View File

@ -2,17 +2,22 @@ import { httpFetch } from '../../request'
import { decodeName, dateFormat2 } from '../../index' import { decodeName, dateFormat2 } from '../../index'
import { toMD5 } from '../utils' import { toMD5 } from '../utils'
const signatureParams = (params) => {
let OIlwieks = '28dk2k092lksi2UIkp'
let sign_params = `OIlwieks${OIlwieks}${params.replace(/&/g, '')}OIlwieks${OIlwieks}`
return toMD5(sign_params)
}
export default { export default {
_requestObj: null, _requestObj: null,
_requestObj2: null, _requestObj2: null,
async getComment({ hash, songmid }, page = 1, limit = 20) { async getComment({ hash }, page = 1, limit = 20) {
if (this._requestObj) this._requestObj.cancelHttp() if (this._requestObj) this._requestObj.cancelHttp()
let timestamp = Date.now() let timestamp = Date.now()
let OIlwieks = '28dk2k092lksi2UIkp' 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`
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 = signatureParams(params)
let signature = toMD5(sign_params) const _requestObj = httpFetch(`http://m.comment.service.kugou.com/v1/cmtlist?${params}&signature=${signature}`, {
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': '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',
}, },
@ -22,14 +27,13 @@ export default {
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: body.maxPage } return { source: 'kg', comments: this.filterComment(body.list || []), total: body.count, page, limit, maxPage: body.maxPage }
}, },
async getHotComment({ hash, songmid }, page = 1, limit = 20) { async getHotComment({ hash }, 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() let timestamp = Date.now()
let OIlwieks = '28dk2k092lksi2UIkp' 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`
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 = signatureParams(params)
let signature = toMD5(sign_params) const _requestObj2 = httpFetch(`http://m.comment.service.kugou.com/v1/weightlist?${params}&signature=${signature}`, {
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',
}, },