parent
15c9207542
commit
2039431735
|
@ -1,7 +1,12 @@
|
||||||
|
### 优化
|
||||||
|
- 不再丢弃kg源逐行歌词
|
||||||
|
- 支持kw源排行榜显示大小(revert @Folltoshe #1460)
|
||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
- 修复某些情况下歌曲加载时间过长时不会自动跳到下一首的问题
|
- 修复某些情况下歌曲加载时间过长时不会自动跳到下一首的问题
|
||||||
- 修复mg歌词在某些情况下获取失败的问题(#1783)
|
- 修复mg歌词在某些情况下获取失败的问题(#1783)
|
||||||
|
- 修复mg歌单搜索
|
||||||
|
|
||||||
### 其他
|
### 其他
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ export default {
|
||||||
// return requestObj
|
// return requestObj
|
||||||
// },
|
// },
|
||||||
searchLyric(name, hash, time, tryNum = 0) {
|
searchLyric(name, hash, time, tryNum = 0) {
|
||||||
let requestObj = httpFetch(`http://lyrics.kugou.com/search?ver=1&man=yes&client=pc&keyword=${encodeURIComponent(name)}&hash=${hash}&timelength=${time}`, {
|
let requestObj = httpFetch(`http://lyrics.kugou.com/search?ver=1&man=yes&client=pc&keyword=${encodeURIComponent(name)}&hash=${hash}&timelength=${time}&lrctxt=1`, {
|
||||||
headers: {
|
headers: {
|
||||||
'KG-RC': 1,
|
'KG-RC': 1,
|
||||||
'KG-THash': 'expand_search_manager.cpp:852736169:451',
|
'KG-THash': 'expand_search_manager.cpp:852736169:451',
|
||||||
|
@ -105,14 +105,14 @@ export default {
|
||||||
}
|
}
|
||||||
if (body.candidates.length) {
|
if (body.candidates.length) {
|
||||||
let info = body.candidates[0]
|
let info = body.candidates[0]
|
||||||
return { id: info.id, accessKey: info.accesskey }
|
return { id: info.id, accessKey: info.accesskey, fmt: (info.krctype == 1 && info.contenttype != 1) ? 'krc' : 'lrc' }
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
return requestObj
|
return requestObj
|
||||||
},
|
},
|
||||||
getLyricDownload(id, accessKey, tryNum = 0) {
|
getLyricDownload(id, accessKey, fmt, tryNum = 0) {
|
||||||
let requestObj = httpFetch(`http://lyrics.kugou.com/download?ver=1&client=pc&id=${id}&accesskey=${accessKey}&fmt=krc&charset=utf8`, {
|
let requestObj = httpFetch(`http://lyrics.kugou.com/download?ver=1&client=pc&id=${id}&accesskey=${accessKey}&fmt=${fmt}&charset=utf8`, {
|
||||||
headers: {
|
headers: {
|
||||||
'KG-RC': 1,
|
'KG-RC': 1,
|
||||||
'KG-THash': 'expand_search_manager.cpp:852736169:451',
|
'KG-THash': 'expand_search_manager.cpp:852736169:451',
|
||||||
|
@ -122,13 +122,26 @@ export default {
|
||||||
requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
||||||
if (statusCode !== 200) {
|
if (statusCode !== 200) {
|
||||||
if (tryNum > 5) return Promise.reject(new Error('歌词获取失败'))
|
if (tryNum > 5) return Promise.reject(new Error('歌词获取失败'))
|
||||||
let tryRequestObj = this.getLyric(id, accessKey, ++tryNum)
|
let tryRequestObj = this.getLyric(id, accessKey, fmt, ++tryNum)
|
||||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||||
return tryRequestObj.promise
|
return tryRequestObj.promise
|
||||||
}
|
}
|
||||||
|
|
||||||
return decodeLyric(body.content).then(result => parseLyric(result))
|
switch (body.fmt) {
|
||||||
|
case 'krc':
|
||||||
|
return decodeLyric(body.content).then(result => parseLyric(result))
|
||||||
|
case 'lrc':
|
||||||
|
return {
|
||||||
|
lyric: Buffer.from(body.content, 'base64').toString('utf-8'),
|
||||||
|
tlyric: '',
|
||||||
|
rlyric: '',
|
||||||
|
lxlyric: '',
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return Promise.reject(new Error(`未知歌词格式: ${body.fmt}`))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return requestObj
|
return requestObj
|
||||||
},
|
},
|
||||||
getLyric(songInfo, tryNum = 0) {
|
getLyric(songInfo, tryNum = 0) {
|
||||||
|
@ -137,7 +150,7 @@ export default {
|
||||||
requestObj.promise = requestObj.promise.then(result => {
|
requestObj.promise = requestObj.promise.then(result => {
|
||||||
if (!result) return Promise.reject(new Error('Get lyric failed'))
|
if (!result) return Promise.reject(new Error('Get lyric failed'))
|
||||||
|
|
||||||
let requestObj2 = this.getLyricDownload(result.id, result.accessKey)
|
let requestObj2 = this.getLyricDownload(result.id, result.accessKey, result.fmt)
|
||||||
|
|
||||||
requestObj.cancelHttp = requestObj2.cancelHttp.bind(requestObj2)
|
requestObj.cancelHttp = requestObj2.cancelHttp.bind(requestObj2)
|
||||||
|
|
||||||
|
|
|
@ -456,7 +456,7 @@ export default {
|
||||||
total -= limit
|
total -= limit
|
||||||
page += 1
|
page += 1
|
||||||
const params = 'appid=1058&global_specialid=' + id + '&specialid=0&plat=0&version=8000&page=' + page + '&pagesize=' + limit + '&srcappid=2919&clientver=20000&clienttime=1586163263991&mid=1586163263991&uuid=1586163263991&dfid=-'
|
const params = 'appid=1058&global_specialid=' + id + '&specialid=0&plat=0&version=8000&page=' + page + '&pagesize=' + limit + '&srcappid=2919&clientver=20000&clienttime=1586163263991&mid=1586163263991&uuid=1586163263991&dfid=-'
|
||||||
tasks.push(this.createHttp(`https://mobiles.kugou.com/api/v5/special/song_v2?${params}&signature=${signatureParams(params, 5)}`, {
|
tasks.push(this.createHttp(`https://mobiles.kugou.com/api/v5/special/song_v2?${params}&signature=${signatureParams(params, 'web')}`, {
|
||||||
headers: {
|
headers: {
|
||||||
mid: '1586163263991',
|
mid: '1586163263991',
|
||||||
Referer: 'https://m3ws.kugou.com/share/index.php',
|
Referer: 'https://m3ws.kugou.com/share/index.php',
|
||||||
|
@ -472,7 +472,7 @@ export default {
|
||||||
let id = global_collection_id
|
let id = global_collection_id
|
||||||
if (id.length > 1000) throw new Error('get list error')
|
if (id.length > 1000) throw new Error('get list error')
|
||||||
const params = 'appid=1058&specialid=0&global_specialid=' + id + '&format=jsonp&srcappid=2919&clientver=20000&clienttime=1586163242519&mid=1586163242519&uuid=1586163242519&dfid=-'
|
const params = 'appid=1058&specialid=0&global_specialid=' + id + '&format=jsonp&srcappid=2919&clientver=20000&clienttime=1586163242519&mid=1586163242519&uuid=1586163242519&dfid=-'
|
||||||
let info = await this.createHttp(`https://mobiles.kugou.com/api/v5/special/info_v2?${params}&signature=${signatureParams(params, 5)}`, {
|
let info = await this.createHttp(`https://mobiles.kugou.com/api/v5/special/info_v2?${params}&signature=${signatureParams(params, 'web')}`, {
|
||||||
headers: {
|
headers: {
|
||||||
mid: '1586163242519',
|
mid: '1586163242519',
|
||||||
Referer: 'https://m3ws.kugou.com/share/index.php',
|
Referer: 'https://m3ws.kugou.com/share/index.php',
|
||||||
|
|
|
@ -254,7 +254,7 @@ export default {
|
||||||
if (this.collectionIdListInfoCache.has(id)) return this.collectionIdListInfoCache.get(id)
|
if (this.collectionIdListInfoCache.has(id)) return this.collectionIdListInfoCache.get(id)
|
||||||
|
|
||||||
const params = `appid=1058&specialid=0&global_specialid=${id}&format=jsonp&srcappid=2919&clientver=20000&clienttime=1586163242519&mid=1586163242519&uuid=1586163242519&dfid=-`
|
const params = `appid=1058&specialid=0&global_specialid=${id}&format=jsonp&srcappid=2919&clientver=20000&clienttime=1586163242519&mid=1586163242519&uuid=1586163242519&dfid=-`
|
||||||
return createHttpFetch(`https://mobiles.kugou.com/api/v5/special/info_v2?${params}&signature=${signatureParams(params, 5)}`, {
|
return createHttpFetch(`https://mobiles.kugou.com/api/v5/special/info_v2?${params}&signature=${signatureParams(params, 'web')}`, {
|
||||||
headers: {
|
headers: {
|
||||||
mid: '1586163242519',
|
mid: '1586163242519',
|
||||||
Referer: 'https://m3ws.kugou.com/share/index.php',
|
Referer: 'https://m3ws.kugou.com/share/index.php',
|
||||||
|
@ -321,7 +321,7 @@ export default {
|
||||||
const listInfo = await this.getUserListInfoByCollectionId(id)
|
const listInfo = await this.getUserListInfoByCollectionId(id)
|
||||||
|
|
||||||
const params = `need_sort=1&module=CloudMusic&clientver=11589&pagesize=${limit}&global_collection_id=${id}&userid=0&page=${page}&type=0&area_code=1&appid=1005`
|
const params = `need_sort=1&module=CloudMusic&clientver=11589&pagesize=${limit}&global_collection_id=${id}&userid=0&page=${page}&type=0&area_code=1&appid=1005`
|
||||||
return createHttpFetch(`http://pubsongs.kugou.com/v2/get_other_list_file?${params}&signature=${signatureParams(params, 2)}`, {
|
return createHttpFetch(`http://pubsongs.kugou.com/v2/get_other_list_file?${params}&signature=${signatureParams(params, 'android')}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'Android10-AndroidPhone-11589-201-0-playlist-wifi',
|
'User-Agent': 'Android10-AndroidPhone-11589-201-0-playlist-wifi',
|
||||||
},
|
},
|
||||||
|
@ -539,7 +539,7 @@ export default {
|
||||||
total -= limit
|
total -= limit
|
||||||
page += 1
|
page += 1
|
||||||
const params = 'appid=1058&global_specialid=' + id + '&specialid=0&plat=0&version=8000&page=' + page + '&pagesize=' + limit + '&srcappid=2919&clientver=20000&clienttime=1586163263991&mid=1586163263991&uuid=1586163263991&dfid=-'
|
const params = 'appid=1058&global_specialid=' + id + '&specialid=0&plat=0&version=8000&page=' + page + '&pagesize=' + limit + '&srcappid=2919&clientver=20000&clienttime=1586163263991&mid=1586163263991&uuid=1586163263991&dfid=-'
|
||||||
tasks.push(createHttpFetch(`https://mobiles.kugou.com/api/v5/special/song_v2?${params}&signature=${signatureParams(params, 5)}`, {
|
tasks.push(createHttpFetch(`https://mobiles.kugou.com/api/v5/special/song_v2?${params}&signature=${signatureParams(params, 'web')}`, {
|
||||||
headers: {
|
headers: {
|
||||||
mid: '1586163263991',
|
mid: '1586163263991',
|
||||||
Referer: 'https://m3ws.kugou.com/share/index.php',
|
Referer: 'https://m3ws.kugou.com/share/index.php',
|
||||||
|
@ -555,7 +555,7 @@ export default {
|
||||||
let id = global_collection_id
|
let id = global_collection_id
|
||||||
if (id.length > 1000) throw new Error('get list error')
|
if (id.length > 1000) throw new Error('get list error')
|
||||||
const params = 'appid=1058&specialid=0&global_specialid=' + id + '&format=jsonp&srcappid=2919&clientver=20000&clienttime=1586163242519&mid=1586163242519&uuid=1586163242519&dfid=-'
|
const params = 'appid=1058&specialid=0&global_specialid=' + id + '&format=jsonp&srcappid=2919&clientver=20000&clienttime=1586163242519&mid=1586163242519&uuid=1586163242519&dfid=-'
|
||||||
let info = await createHttpFetch(`https://mobiles.kugou.com/api/v5/special/info_v2?${params}&signature=${signatureParams(params, 5)}`, {
|
let info = await createHttpFetch(`https://mobiles.kugou.com/api/v5/special/info_v2?${params}&signature=${signatureParams(params, 'web')}`, {
|
||||||
headers: {
|
headers: {
|
||||||
mid: '1586163242519',
|
mid: '1586163242519',
|
||||||
Referer: 'https://m3ws.kugou.com/share/index.php',
|
Referer: 'https://m3ws.kugou.com/share/index.php',
|
||||||
|
@ -760,7 +760,7 @@ export default {
|
||||||
|
|
||||||
search(text, page, limit = 20) {
|
search(text, page, limit = 20) {
|
||||||
const params = `userid=1384394652&req_custom=1&appid=1005&req_multi=1&version=11589&page=${page}&filter=0&pagesize=${limit}&order=0&clienttime=1681779443&iscorrection=1&searchsong=0&keyword=${text}&mid=288799920684148686226285199951543865551&dfid=3eSBsO1u97EY1zeIZd40hH4p&clientver=11589&platform=AndroidFilter`
|
const params = `userid=1384394652&req_custom=1&appid=1005&req_multi=1&version=11589&page=${page}&filter=0&pagesize=${limit}&order=0&clienttime=1681779443&iscorrection=1&searchsong=0&keyword=${text}&mid=288799920684148686226285199951543865551&dfid=3eSBsO1u97EY1zeIZd40hH4p&clientver=11589&platform=AndroidFilter`
|
||||||
const url = encodeURI(`http://complexsearchretry.kugou.com/v1/search/special?${params}&signature=${signatureParams(params, 1)}`)
|
const url = encodeURI(`http://complexsearchretry.kugou.com/v1/search/special?${params}&signature=${signatureParams(params, 'android')}`)
|
||||||
return createHttpFetch(url).then(body => {
|
return createHttpFetch(url).then(body => {
|
||||||
// console.log(body)
|
// console.log(body)
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -25,12 +25,12 @@ export const decodeLyric = str => new Promise((resolve, reject) => {
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @param {*} apiver
|
* @param {*} apiver
|
||||||
*/
|
*/
|
||||||
export const signatureParams = (params, apiver = 9) => {
|
export const signatureParams = (params, platform = 'android', body = '') => {
|
||||||
let keyparam = 'OIlwieks28dk2k092lksi2UIkp'
|
let keyparam = 'OIlwieks28dk2k092lksi2UIkp'
|
||||||
if (apiver === 5) keyparam = 'NVPh5oo715z5DIWAeQlhMDsWXXQV4hwt'
|
if (platform === 'web') keyparam = 'NVPh5oo715z5DIWAeQlhMDsWXXQV4hwt'
|
||||||
let param_list = params.split('&')
|
let param_list = params.split('&')
|
||||||
param_list.sort()
|
param_list.sort()
|
||||||
let sign_params = `${keyparam}${param_list.join('')}${keyparam}`
|
let sign_params = `${keyparam}${param_list.join('')}${body}${keyparam}`
|
||||||
return toMD5(sign_params)
|
return toMD5(sign_params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,35 @@
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { formatPlayTime, decodeName } from '../../index'
|
import { formatPlayTime, decodeName } from '../../index'
|
||||||
import { formatSinger } from './util'
|
import { formatSinger, wbdCrypto } from './util'
|
||||||
|
|
||||||
|
|
||||||
const boardList = [{ id: 'kw__93', name: '飙升榜', bangid: '93' }, { id: 'kw__17', name: '新歌榜', bangid: '17' }, { id: 'kw__16', name: '热歌榜', bangid: '16' }, { id: 'kw__158', name: '抖音热歌榜', bangid: '158' }, { id: 'kw__292', name: '铃声榜', bangid: '292' }, { id: 'kw__284', name: '热评榜', bangid: '284' }, { id: 'kw__290', name: 'ACG新歌榜', bangid: '290' }, { id: 'kw__286', name: '台湾KKBOX榜', bangid: '286' }, { id: 'kw__279', name: '冬日暖心榜', bangid: '279' }, { id: 'kw__281', name: '巴士随身听榜', bangid: '281' }, { id: 'kw__255', name: 'KTV点唱榜', bangid: '255' }, { id: 'kw__280', name: '家务进行曲榜', bangid: '280' }, { id: 'kw__282', name: '熬夜修仙榜', bangid: '282' }, { id: 'kw__283', name: '枕边轻音乐榜', bangid: '283' }, { id: 'kw__278', name: '古风音乐榜', bangid: '278' }, { id: 'kw__264', name: 'Vlog音乐榜', bangid: '264' }, { id: 'kw__242', name: '电音榜', bangid: '242' }, { id: 'kw__187', name: '流行趋势榜', bangid: '187' }, { id: 'kw__204', name: '现场音乐榜', bangid: '204' }, { id: 'kw__186', name: 'ACG神曲榜', bangid: '186' }, { id: 'kw__185', name: '最强翻唱榜', bangid: '185' }, { id: 'kw__26', name: '经典怀旧榜', bangid: '26' }, { id: 'kw__104', name: '华语榜', bangid: '104' }, { id: 'kw__182', name: '粤语榜', bangid: '182' }, { id: 'kw__22', name: '欧美榜', bangid: '22' }, { id: 'kw__184', name: '韩语榜', bangid: '184' }, { id: 'kw__183', name: '日语榜', bangid: '183' }, { id: 'kw__145', name: '会员畅听榜', bangid: '145' }, { id: 'kw__153', name: '网红新歌榜', bangid: '153' }, { id: 'kw__64', name: '影视金曲榜', bangid: '64' }, { id: 'kw__176', name: 'DJ嗨歌榜', bangid: '176' }, { id: 'kw__106', name: '真声音', bangid: '106' }, { id: 'kw__12', name: 'Billboard榜', bangid: '12' }, { id: 'kw__49', name: 'iTunes音乐榜', bangid: '49' }, { id: 'kw__180', name: 'beatport电音榜', bangid: '180' }, { id: 'kw__13', name: '英国UK榜', bangid: '13' }, { id: 'kw__164', name: '百大DJ榜', bangid: '164' }, { id: 'kw__246', name: 'YouTube音乐排行榜', bangid: '246' }, { id: 'kw__265', name: '韩国Genie榜', bangid: '265' }, { id: 'kw__14', name: '韩国M-net榜', bangid: '14' }, { id: 'kw__8', name: '香港电台榜', bangid: '8' }, { id: 'kw__15', name: '日本公信榜', bangid: '15' }, { id: 'kw__151', name: '腾讯音乐人原创榜', bangid: '151' }]
|
const boardList = [{ id: 'kw__93', name: '飙升榜', bangid: '93' }, { id: 'kw__17', name: '新歌榜', bangid: '17' }, { id: 'kw__16', name: '热歌榜', bangid: '16' }, { id: 'kw__158', name: '抖音热歌榜', bangid: '158' }, { id: 'kw__292', name: '铃声榜', bangid: '292' }, { id: 'kw__284', name: '热评榜', bangid: '284' }, { id: 'kw__290', name: 'ACG新歌榜', bangid: '290' }, { id: 'kw__286', name: '台湾KKBOX榜', bangid: '286' }, { id: 'kw__279', name: '冬日暖心榜', bangid: '279' }, { id: 'kw__281', name: '巴士随身听榜', bangid: '281' }, { id: 'kw__255', name: 'KTV点唱榜', bangid: '255' }, { id: 'kw__280', name: '家务进行曲榜', bangid: '280' }, { id: 'kw__282', name: '熬夜修仙榜', bangid: '282' }, { id: 'kw__283', name: '枕边轻音乐榜', bangid: '283' }, { id: 'kw__278', name: '古风音乐榜', bangid: '278' }, { id: 'kw__264', name: 'Vlog音乐榜', bangid: '264' }, { id: 'kw__242', name: '电音榜', bangid: '242' }, { id: 'kw__187', name: '流行趋势榜', bangid: '187' }, { id: 'kw__204', name: '现场音乐榜', bangid: '204' }, { id: 'kw__186', name: 'ACG神曲榜', bangid: '186' }, { id: 'kw__185', name: '最强翻唱榜', bangid: '185' }, { id: 'kw__26', name: '经典怀旧榜', bangid: '26' }, { id: 'kw__104', name: '华语榜', bangid: '104' }, { id: 'kw__182', name: '粤语榜', bangid: '182' }, { id: 'kw__22', name: '欧美榜', bangid: '22' }, { id: 'kw__184', name: '韩语榜', bangid: '184' }, { id: 'kw__183', name: '日语榜', bangid: '183' }, { id: 'kw__145', name: '会员畅听榜', bangid: '145' }, { id: 'kw__153', name: '网红新歌榜', bangid: '153' }, { id: 'kw__64', name: '影视金曲榜', bangid: '64' }, { id: 'kw__176', name: 'DJ嗨歌榜', bangid: '176' }, { id: 'kw__106', name: '真声音', bangid: '106' }, { id: 'kw__12', name: 'Billboard榜', bangid: '12' }, { id: 'kw__49', name: 'iTunes音乐榜', bangid: '49' }, { id: 'kw__180', name: 'beatport电音榜', bangid: '180' }, { id: 'kw__13', name: '英国UK榜', bangid: '13' }, { id: 'kw__164', name: '百大DJ榜', bangid: '164' }, { id: 'kw__246', name: 'YouTube音乐排行榜', bangid: '246' }, { id: 'kw__265', name: '韩国Genie榜', bangid: '265' }, { id: 'kw__14', name: '韩国M-net榜', bangid: '14' }, { id: 'kw__8', name: '香港电台榜', bangid: '8' }, { id: 'kw__15', name: '日本公信榜', bangid: '15' }, { id: 'kw__151', name: '腾讯音乐人原创榜', bangid: '151' }]
|
||||||
|
|
||||||
|
const sortQualityArray = array => {
|
||||||
|
const qualityMap = {
|
||||||
|
flac24bit: 4,
|
||||||
|
flac: 3,
|
||||||
|
'320k': 2,
|
||||||
|
'128k': 1,
|
||||||
|
}
|
||||||
|
const rawQualityArray = []
|
||||||
|
const newQualityArray = []
|
||||||
|
|
||||||
|
array.forEach((item, index) => {
|
||||||
|
const type = qualityMap[item.type]
|
||||||
|
if (!type) return
|
||||||
|
rawQualityArray.push({ type, index })
|
||||||
|
})
|
||||||
|
|
||||||
|
rawQualityArray.sort((a, b) => a.type - b.type)
|
||||||
|
|
||||||
|
rawQualityArray.forEach(item => {
|
||||||
|
newQualityArray.push(array[item.index])
|
||||||
|
})
|
||||||
|
|
||||||
|
return newQualityArray
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
list: [
|
list: [
|
||||||
{
|
{
|
||||||
|
@ -62,9 +88,9 @@ export default {
|
||||||
bangid: 183,
|
bangid: 183,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
getUrl: (p, l, id) => `http://kbangserver.kuwo.cn/ksong.s?from=pc&fmt=json&pn=${p - 1}&rn=${l}&type=bang&data=content&id=${id}&show_copyright_off=0&pcmp4=1&isbang=1`,
|
// getUrl: (p, l, id) => `http://kbangserver.kuwo.cn/ksong.s?from=pc&fmt=json&pn=${p - 1}&rn=${l}&type=bang&data=content&id=${id}&show_copyright_off=0&pcmp4=1&isbang=1`,
|
||||||
regExps: {
|
regExps: {
|
||||||
|
mInfo: /level:(\w+),bitrate:(\d+),format:(\w+),size:([\w.]+)/,
|
||||||
},
|
},
|
||||||
limit: 100,
|
limit: 100,
|
||||||
_requestBoardsObj: null,
|
_requestBoardsObj: null,
|
||||||
|
@ -79,57 +105,50 @@ export default {
|
||||||
return requestDataObj.promise
|
return requestDataObj.promise
|
||||||
},
|
},
|
||||||
filterData(rawList) {
|
filterData(rawList) {
|
||||||
// console.log(rawList)
|
return rawList.map(item => {
|
||||||
// console.log(rawList.length, rawList2.length)
|
|
||||||
return rawList.map((item, inedx) => {
|
|
||||||
let formats = item.formats.split('|')
|
|
||||||
let types = []
|
let types = []
|
||||||
let _types = {}
|
const _types = {}
|
||||||
if (formats.includes('MP3128')) {
|
const qualitys = new Set()
|
||||||
types.push({ type: '128k', size: null })
|
|
||||||
_types['128k'] = {
|
item.n_minfo.split(';').forEach(i => {
|
||||||
size: null,
|
const info = i.match(this.regExps.mInfo)
|
||||||
|
if (!info) return
|
||||||
|
|
||||||
|
const quality = info[2]
|
||||||
|
const size = info[4].toLocaleUpperCase()
|
||||||
|
|
||||||
|
if (qualitys.has(quality)) return
|
||||||
|
qualitys.add(quality)
|
||||||
|
|
||||||
|
switch (quality) {
|
||||||
|
case '4000':
|
||||||
|
types.push({ type: 'flac24bit', size })
|
||||||
|
_types.flac24bit = { size }
|
||||||
|
break
|
||||||
|
case '2000':
|
||||||
|
types.push({ type: 'flac', size })
|
||||||
|
_types.flac = { size }
|
||||||
|
break
|
||||||
|
case '320':
|
||||||
|
types.push({ type: '320k', size })
|
||||||
|
_types['320k'] = { size }
|
||||||
|
break
|
||||||
|
case '128':
|
||||||
|
types.push({ type: '128k', size })
|
||||||
|
_types['128k'] = { size }
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
// if (formats.includes('MP3192')) {
|
types = sortQualityArray(types)
|
||||||
// types.push({ type: '192k', size: null })
|
|
||||||
// _types['192k'] = {
|
|
||||||
// size: null,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
if (formats.includes('MP3H')) {
|
|
||||||
types.push({ type: '320k', size: null })
|
|
||||||
_types['320k'] = {
|
|
||||||
size: null,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if (formats.includes('AL')) {
|
|
||||||
// types.push({ type: 'ape', size: null })
|
|
||||||
// _types.ape = {
|
|
||||||
// size: null,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
if (formats.includes('ALFLAC')) {
|
|
||||||
types.push({ type: 'flac', size: null })
|
|
||||||
_types.flac = {
|
|
||||||
size: null,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (formats.includes('HIRFLAC')) {
|
|
||||||
types.push({ type: 'flac24bit', size: null })
|
|
||||||
_types.flac24bit = {
|
|
||||||
size: null,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// types.reverse()
|
|
||||||
return {
|
return {
|
||||||
singer: formatSinger(decodeName(item.artist)),
|
singer: formatSinger(decodeName(item.artist)),
|
||||||
name: decodeName(item.name),
|
name: decodeName(item.name),
|
||||||
albumName: decodeName(item.album),
|
albumName: decodeName(item.album),
|
||||||
albumId: item.albumid,
|
albumId: item.albumId,
|
||||||
songmid: item.id,
|
songmid: item.id,
|
||||||
source: 'kw',
|
source: 'kw',
|
||||||
interval: formatPlayTime(parseInt(item.song_duration)),
|
interval: formatPlayTime(parseInt(item.duration)),
|
||||||
img: item.pic,
|
img: item.pic,
|
||||||
lrc: null,
|
lrc: null,
|
||||||
otherSource: null,
|
otherSource: null,
|
||||||
|
@ -180,12 +199,20 @@ export default {
|
||||||
|
|
||||||
getList(id, page, retryNum = 0) {
|
getList(id, page, retryNum = 0) {
|
||||||
if (++retryNum > 3) return Promise.reject(new Error('try max num'))
|
if (++retryNum > 3) return Promise.reject(new Error('try max num'))
|
||||||
return this.getData(this.getUrl(page, this.limit, id)).then(({ statusCode, body }) => {
|
|
||||||
// console.log(body)
|
const requestBody = { uid: '', devId: '', sFrom: 'kuwo_sdk', user_type: 'AP', carSource: 'kwplayercar_ar_6.0.1.0_apk_keluze.apk', id, pn: page - 1, rn: this.limit }
|
||||||
if (statusCode !== 200 || !body.musiclist) return this.getList(id, page, retryNum)
|
const requestUrl = `https://wbd.kuwo.cn/api/bd/bang/bang_info?${wbdCrypto.buildParam(requestBody)}`
|
||||||
// console.log(data1.musiclist, data2.data)
|
const request = httpFetch(requestUrl).promise
|
||||||
let total = parseInt(body.num)
|
|
||||||
let list = this.filterData(body.musiclist)
|
return request.then(({ statusCode, body }) => {
|
||||||
|
const rawData = wbdCrypto.decodeData(body)
|
||||||
|
// console.log(rawData)
|
||||||
|
const data = rawData.data
|
||||||
|
if (statusCode !== 200 || rawData.code != 200 || !data.musiclist) return this.getList(id, page, retryNum)
|
||||||
|
|
||||||
|
const total = parseInt(data.total)
|
||||||
|
const list = this.filterData(data.musiclist)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
total,
|
total,
|
||||||
list,
|
list,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// import { httpGet, httpFetch } from '../../request'
|
// import { httpGet, httpFetch } from '../../request'
|
||||||
import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames'
|
import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames'
|
||||||
import { rendererInvoke } from '@common/rendererIpc'
|
import { rendererInvoke } from '@common/rendererIpc'
|
||||||
|
import { createCipheriv, createDecipheriv } from 'crypto'
|
||||||
|
import { toMD5 } from '../utils'
|
||||||
|
|
||||||
// const kw_token = {
|
// const kw_token = {
|
||||||
// token: null,
|
// token: null,
|
||||||
|
@ -179,3 +181,38 @@ export const lrcTools = {
|
||||||
return lrcs
|
return lrcs
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const createAesEncrypt = (buffer, mode, key, iv) => {
|
||||||
|
const cipher = createCipheriv(mode, key, iv)
|
||||||
|
return Buffer.concat([cipher.update(buffer), cipher.final()])
|
||||||
|
}
|
||||||
|
|
||||||
|
const createAesDecrypt = (buffer, mode, key, iv) => {
|
||||||
|
const cipher = createDecipheriv(mode, key, iv)
|
||||||
|
return Buffer.concat([cipher.update(buffer), cipher.final()])
|
||||||
|
}
|
||||||
|
|
||||||
|
export const wbdCrypto = {
|
||||||
|
aesMode: 'aes-128-ecb',
|
||||||
|
aesKey: Buffer.from([112, 87, 39, 61, 199, 250, 41, 191, 57, 68, 45, 114, 221, 94, 140, 228], 'binary'),
|
||||||
|
aesIv: '',
|
||||||
|
appId: 'y67sprxhhpws',
|
||||||
|
decodeData(base64Result) {
|
||||||
|
const data = Buffer.from(decodeURIComponent(base64Result), 'base64')
|
||||||
|
return JSON.parse(createAesDecrypt(data, this.aesMode, this.aesKey, this.aesIv).toString())
|
||||||
|
},
|
||||||
|
createSign(data, time) {
|
||||||
|
const str = `${this.appId}${data}${time}`
|
||||||
|
return toMD5(str).toUpperCase()
|
||||||
|
},
|
||||||
|
buildParam(jsonData) {
|
||||||
|
const data = Buffer.from(JSON.stringify(jsonData))
|
||||||
|
const time = Date.now()
|
||||||
|
|
||||||
|
const encodeData = createAesEncrypt(data, this.aesMode, this.aesKey, this.aesIv).toString('base64')
|
||||||
|
const sign = this.createSign(encodeData, time)
|
||||||
|
|
||||||
|
return `data=${encodeURIComponent(encodeData)}&time=${time}&appId=${this.appId}&sign=${sign}`
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
|
@ -308,7 +308,7 @@ export default {
|
||||||
search(text, page, limit = 20) {
|
search(text, page, limit = 20) {
|
||||||
const timeStr = Date.now().toString()
|
const timeStr = Date.now().toString()
|
||||||
const signResult = createSignature(timeStr, text)
|
const signResult = createSignature(timeStr, text)
|
||||||
return createHttpFetch(`https://jadeite.migu.cn/music_search/v3/search/searchAll?isCorrect=1&isCopyright=1&searchSwitch=%7B%22song%22%3A0%2C%22album%22%3A0%2C%22singer%22%3A0%2C%22tagSong%22%3A0%2C%22mvSong%22%3A0%2C%22bestShow%22%3A0%2C%22songlist%22%3A1%2C%22lyricSong%22%3A0%7D&pageSize=${limit}&text=${encodeURIComponent(text)}&pageNo=${page}&sort=0`, {
|
return createHttpFetch(`https://jadeite.migu.cn/music_search/v3/search/searchAll?isCorrect=1&isCopyright=1&searchSwitch=%7B%22song%22%3A0%2C%22album%22%3A0%2C%22singer%22%3A0%2C%22tagSong%22%3A0%2C%22mvSong%22%3A0%2C%22bestShow%22%3A0%2C%22songlist%22%3A1%2C%22lyricSong%22%3A0%7D&pageSize=${limit}&text=${encodeURIComponent(text)}&pageNo=${page}&sort=0&sid=USS`, {
|
||||||
headers: {
|
headers: {
|
||||||
uiVersion: 'A_music_3.6.1',
|
uiVersion: 'A_music_3.6.1',
|
||||||
deviceId: signResult.deviceId,
|
deviceId: signResult.deviceId,
|
||||||
|
|
Loading…
Reference in New Issue