kg源数据更新 (#1232)
* kg源评论接口更新,热门评论完整支持 * kg搜索HiRes支持 --------- Co-authored-by: 彭狸花喵 <94218819+helloplhm-qwq@users.noreply.github.com>pull/1235/head
parent
fe259747dc
commit
371b8fad05
|
@ -12,6 +12,7 @@
|
||||||
- 支持wy源flac hires歌曲类型的显示
|
- 支持wy源flac hires歌曲类型的显示
|
||||||
- 快捷键调整音量时每次加减2%音量改为4%(#1220)
|
- 快捷键调整音量时每次加减2%音量改为4%(#1220)
|
||||||
- 音量、播放模式等设置弹出式按钮在鼠标移到按钮上时将自动弹出设置内容,保留点击切换显示/隐藏
|
- 音量、播放模式等设置弹出式按钮在鼠标移到按钮上时将自动弹出设置内容,保留点击切换显示/隐藏
|
||||||
|
- 支持kg源搜索列表flac hires歌曲类型的显示(@helloplhm-qwq)
|
||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { decodeName, dateFormat2 } from '../../index'
|
import { decodeName, dateFormat2 } from '../../index'
|
||||||
|
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,
|
||||||
|
@ -7,21 +14,26 @@ export default {
|
||||||
async getComment({ hash }, page = 1, limit = 20) {
|
async getComment({ hash }, 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()
|
||||||
|
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 signature = signatureParams(params)
|
||||||
|
const _requestObj = httpFetch(`http://m.comment.service.kugou.com/v1/cmtlist?${params}&signature=${signature}`, {
|
||||||
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 }, 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`, {
|
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 signature = signatureParams(params)
|
||||||
|
const _requestObj2 = httpFetch(`http://m.comment.service.kugou.com/v1/weightlist?${params}&signature=${signature}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi',
|
'User-Agent': 'Android712-AndroidPhone-8983-18-0-COMMENT-wifi',
|
||||||
},
|
},
|
||||||
|
@ -29,8 +41,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()
|
||||||
|
|
|
@ -11,65 +11,72 @@ export default {
|
||||||
page: 0,
|
page: 0,
|
||||||
allPage: 1,
|
allPage: 1,
|
||||||
musicSearch(str, page, limit) {
|
musicSearch(str, page, limit) {
|
||||||
const searchRequest = httpFetch(`http://ioscdn.kugou.com/api/v3/search/song?keyword=${encodeURIComponent(str)}&page=${page}&pagesize=${limit}&showtype=10&plat=2&version=7910&tag=1&correct=1&privilege=1&sver=5`)
|
const searchRequest = httpFetch(`https://songsearch.kugou.com/song_search_v2?keyword=${encodeURIComponent(str)}&page=${page}&pagesize=${limit}&userid=0&clientver=&platform=WebFilter&filter=2&iscorrection=1&privilege_filter=0`)
|
||||||
return searchRequest.promise.then(({ body }) => body)
|
return searchRequest.promise.then(({ body }) => body)
|
||||||
},
|
},
|
||||||
filterData(rawData) {
|
filterData(rawData) {
|
||||||
const types = []
|
const types = []
|
||||||
const _types = {}
|
const _types = {}
|
||||||
if (rawData.filesize !== 0) {
|
if (rawData.FileSize !== 0) {
|
||||||
let size = sizeFormate(rawData.filesize)
|
let size = sizeFormate(rawData.FileSize)
|
||||||
types.push({ type: '128k', size, hash: rawData.hash })
|
types.push({ type: '128k', size, hash: rawData.FileHash })
|
||||||
_types['128k'] = {
|
_types['128k'] = {
|
||||||
size,
|
size,
|
||||||
hash: rawData.hash,
|
hash: rawData.FileHash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rawData['320filesize'] !== 0) {
|
if (rawData.HQFileSize !== 0) {
|
||||||
let size = sizeFormate(rawData['320filesize'])
|
let size = sizeFormate(rawData.HQFileSize)
|
||||||
types.push({ type: '320k', size, hash: rawData['320hash'] })
|
types.push({ type: '320k', size, hash: rawData.HQFileHash })
|
||||||
_types['320k'] = {
|
_types['320k'] = {
|
||||||
size,
|
size,
|
||||||
hash: rawData['320hash'],
|
hash: rawData.HQFileHash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rawData.sqfilesize !== 0) {
|
if (rawData.SQFileSize !== 0) {
|
||||||
let size = sizeFormate(rawData.sqfilesize)
|
let size = sizeFormate(rawData.SQFileSize)
|
||||||
types.push({ type: 'flac', size, hash: rawData.sqhash })
|
types.push({ type: 'flac', size, hash: rawData.SQFileHash })
|
||||||
_types.flac = {
|
_types.flac = {
|
||||||
size,
|
size,
|
||||||
hash: rawData.sqhash,
|
hash: rawData.SQFileHash,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rawData.ResFileSize !== 0) {
|
||||||
|
let size = sizeFormate(rawData.ResFileSize)
|
||||||
|
types.push({ type: 'flac24bit', size, hash: rawData.ResFileHash })
|
||||||
|
_types.flac24bit = {
|
||||||
|
size,
|
||||||
|
hash: rawData.ResFileHash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
singer: decodeName(rawData.singername),
|
singer: decodeName(rawData.SingerName),
|
||||||
name: decodeName(rawData.songname),
|
name: decodeName(rawData.SongName),
|
||||||
albumName: decodeName(rawData.album_name),
|
albumName: decodeName(rawData.AlbumName),
|
||||||
albumId: rawData.album_id,
|
albumId: rawData.Albumid,
|
||||||
songmid: rawData.audio_id,
|
songmid: rawData.Audioid,
|
||||||
source: 'kg',
|
source: 'kg',
|
||||||
interval: formatPlayTime(rawData.duration),
|
interval: formatPlayTime(rawData.Duration),
|
||||||
_interval: rawData.duration,
|
_interval: rawData.Duration,
|
||||||
img: null,
|
img: null,
|
||||||
lrc: null,
|
lrc: null,
|
||||||
otherSource: null,
|
otherSource: null,
|
||||||
hash: rawData.hash,
|
hash: rawData.FileHash,
|
||||||
types,
|
types,
|
||||||
_types,
|
_types,
|
||||||
typeUrl: {},
|
typeUrl: {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleResult(rawData) {
|
handleResult(rawData) {
|
||||||
// console.log(rawData)
|
|
||||||
let ids = new Set()
|
let ids = new Set()
|
||||||
const list = []
|
const list = []
|
||||||
rawData.forEach(item => {
|
rawData.forEach(item => {
|
||||||
const key = item.audio_id + item.hash
|
const key = item.Audioid + item.FileHash
|
||||||
if (ids.has(key)) return
|
if (ids.has(key)) return
|
||||||
ids.add(key)
|
ids.add(key)
|
||||||
list.push(this.filterData(item))
|
list.push(this.filterData(item))
|
||||||
for (const childItem of item.group) {
|
for (const childItem of item.Grp) {
|
||||||
const key = item.audio_id + item.hash
|
const key = item.Audioid + item.FileHash
|
||||||
if (ids.has(key)) continue
|
if (ids.has(key)) continue
|
||||||
ids.add(key)
|
ids.add(key)
|
||||||
list.push(this.filterData(childItem))
|
list.push(this.filterData(childItem))
|
||||||
|
@ -82,8 +89,8 @@ export default {
|
||||||
if (limit == null) limit = this.limit
|
if (limit == null) limit = this.limit
|
||||||
// http://newlyric.kuwo.cn/newlyric.lrc?62355680
|
// http://newlyric.kuwo.cn/newlyric.lrc?62355680
|
||||||
return this.musicSearch(str, page, limit).then(result => {
|
return this.musicSearch(str, page, limit).then(result => {
|
||||||
if (!result || result.errcode !== 0) return this.search(str, page, limit, retryNum)
|
if (!result || result.error_code !== 0) return this.search(str, page, limit, retryNum)
|
||||||
let list = this.handleResult(result.data.info)
|
let list = this.handleResult(result.data.lists)
|
||||||
|
|
||||||
if (list == null) return this.search(str, page, limit, retryNum)
|
if (list == null) return this.search(str, page, limit, retryNum)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue