kg源评论接口更新,热门评论完整支持
This commit is contained in:
parent
fe259747dc
commit
4b9a0d9504
@ -11,65 +11,74 @@ 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) {
|
||||||
|
console.log(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)
|
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 +91,9 @@ 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)
|
console.log(result)
|
||||||
let list = this.handleResult(result.data.info)
|
if (!result || result.error_code !== 0) return this.search(str, page, limit, retryNum)
|
||||||
|
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
Block a user