parent
200ca1eeda
commit
908815def3
|
@ -48,12 +48,12 @@ export default {
|
||||||
const tipSearch = debounce(async() => {
|
const tipSearch = debounce(async() => {
|
||||||
if (searchText.value === '' && prevTempSearchSource) {
|
if (searchText.value === '' && prevTempSearchSource) {
|
||||||
tipList.value = []
|
tipList.value = []
|
||||||
music[prevTempSearchSource].tempSearch.cancelTempSearch()
|
music[prevTempSearchSource].tipSearch.cancelTipSearch()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const { temp_source } = await getSearchSetting()
|
const { temp_source } = await getSearchSetting()
|
||||||
prevTempSearchSource = temp_source
|
prevTempSearchSource = temp_source
|
||||||
music[prevTempSearchSource].tempSearch.search(searchText.value).then(list => {
|
music[prevTempSearchSource].tipSearch.search(searchText.value).then(list => {
|
||||||
tipList.value = list
|
tipList.value = list
|
||||||
}).catch(() => {})
|
}).catch(() => {})
|
||||||
}, 50)
|
}, 50)
|
||||||
|
|
|
@ -5,6 +5,17 @@ export * from '@common/utils/nodejs'
|
||||||
export * from '@common/utils/common'
|
export * from '@common/utils/common'
|
||||||
export * from '@common/utils/tools'
|
export * from '@common/utils/tools'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化播放数量
|
||||||
|
* @param {*} num 数字
|
||||||
|
*/
|
||||||
|
export const formatPlayCount = (num: number): string => {
|
||||||
|
if (num > 100000000) return `${Math.trunc(num / 10000000) / 10}亿`
|
||||||
|
if (num > 10000) return `${Math.trunc(num / 1000) / 10}万`
|
||||||
|
return String(num)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 时间格式化
|
* 时间格式化
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
import { getMusicInfosByList } from './musicInfo'
|
||||||
|
import { createHttpFetch } from './util'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
/**
|
||||||
|
* 通过AlbumId获取专辑信息
|
||||||
|
* @param {*} id
|
||||||
|
*/
|
||||||
|
async getAlbumInfo(id) {
|
||||||
|
const albumInfoRequest = await createHttpFetch('http://kmrserviceretry.kugou.com/container/v1/album?dfid=1tT5He3kxrNC4D29ad1MMb6F&mid=22945702112173152889429073101964063697&userid=0&appid=1005&clientver=11589', {
|
||||||
|
method: 'POST',
|
||||||
|
body: {
|
||||||
|
appid: 1005,
|
||||||
|
clienttime: 1681833686,
|
||||||
|
clientver: 11589,
|
||||||
|
data: [{ album_id: id }],
|
||||||
|
fields: 'language,grade_count,intro,mix_intro,heat,category,sizable_cover,cover,album_name,type,quality,publish_company,grade,special_tag,author_name,publish_date,language_id,album_id,exclusive,is_publish,trans_param,authors,album_tag',
|
||||||
|
isBuy: 0,
|
||||||
|
key: 'e6f3306ff7e2afb494e89fbbda0becbf',
|
||||||
|
mid: '22945702112173152889429073101964063697',
|
||||||
|
show_album_tag: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if (!albumInfoRequest) return Promise.reject(new Error('get album info failed.'))
|
||||||
|
const albumInfo = albumInfoRequest[0]
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: albumInfo.album_name,
|
||||||
|
image: albumInfo.sizable_cover.replace('{size}', 240),
|
||||||
|
desc: albumInfo.intro,
|
||||||
|
authorName: albumInfo.author_name,
|
||||||
|
// play_count: this.formatPlayCount(info.count),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 通过AlbumId获取专辑
|
||||||
|
* @param {*} id
|
||||||
|
* @param {*} page
|
||||||
|
*/
|
||||||
|
async getAlbumDetail(id, page = 1, limit = 200) {
|
||||||
|
const albumList = await createHttpFetch(`http://mobiles.kugou.com/api/v3/album/song?version=9108&albumid=${id}&plat=0&pagesize=${limit}&area_code=0&page=${page}&with_res_tag=0`)
|
||||||
|
if (!albumList.info) return Promise.reject(new Error('Get album list failed.'))
|
||||||
|
|
||||||
|
let result = await getMusicInfosByList(albumList.info)
|
||||||
|
|
||||||
|
const info = await this.getAlbumInfo(id)
|
||||||
|
|
||||||
|
return {
|
||||||
|
list: result || [],
|
||||||
|
page,
|
||||||
|
limit,
|
||||||
|
total: albumList.total,
|
||||||
|
source: 'kg',
|
||||||
|
info: {
|
||||||
|
name: info.name,
|
||||||
|
img: info.image,
|
||||||
|
desc: info.desc,
|
||||||
|
author: info.authorName,
|
||||||
|
// play_count: this.formatPlayCount(info.count),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
|
@ -6,8 +6,10 @@ import pic from './pic'
|
||||||
import lyric from './lyric'
|
import lyric from './lyric'
|
||||||
import hotSearch from './hotSearch'
|
import hotSearch from './hotSearch'
|
||||||
import comment from './comment'
|
import comment from './comment'
|
||||||
|
// import tipSearch from './tipSearch'
|
||||||
|
|
||||||
const kg = {
|
const kg = {
|
||||||
|
// tipSearch,
|
||||||
leaderboard,
|
leaderboard,
|
||||||
songList,
|
songList,
|
||||||
musicSearch,
|
musicSearch,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { decodeName, formatPlayTime, sizeFormate } from '../../index'
|
import { decodeName, formatPlayTime, sizeFormate } from '../../index'
|
||||||
|
import { formatSingerName } from '../utils'
|
||||||
|
|
||||||
let boardList = [{ id: 'kg__8888', name: 'TOP500', bangid: '8888' }, { id: 'kg__6666', name: '飙升榜', bangid: '6666' }, { id: 'kg__59703', name: '蜂鸟流行音乐榜', bangid: '59703' }, { id: 'kg__52144', name: '抖音热歌榜', bangid: '52144' }, { id: 'kg__52767', name: '快手热歌榜', bangid: '52767' }, { id: 'kg__24971', name: 'DJ热歌榜', bangid: '24971' }, { id: 'kg__23784', name: '网络红歌榜', bangid: '23784' }, { id: 'kg__44412', name: '说唱先锋榜', bangid: '44412' }, { id: 'kg__31308', name: '内地榜', bangid: '31308' }, { id: 'kg__33160', name: '电音榜', bangid: '33160' }, { id: 'kg__31313', name: '香港地区榜', bangid: '31313' }, { id: 'kg__51341', name: '民谣榜', bangid: '51341' }, { id: 'kg__54848', name: '台湾地区榜', bangid: '54848' }, { id: 'kg__31310', name: '欧美榜', bangid: '31310' }, { id: 'kg__33162', name: 'ACG新歌榜', bangid: '33162' }, { id: 'kg__31311', name: '韩国榜', bangid: '31311' }, { id: 'kg__31312', name: '日本榜', bangid: '31312' }, { id: 'kg__49225', name: '80后热歌榜', bangid: '49225' }, { id: 'kg__49223', name: '90后热歌榜', bangid: '49223' }, { id: 'kg__49224', name: '00后热歌榜', bangid: '49224' }, { id: 'kg__33165', name: '粤语金曲榜', bangid: '33165' }, { id: 'kg__33166', name: '欧美金曲榜', bangid: '33166' }, { id: 'kg__33163', name: '影视金曲榜', bangid: '33163' }, { id: 'kg__51340', name: '伤感榜', bangid: '51340' }, { id: 'kg__35811', name: '会员专享榜', bangid: '35811' }, { id: 'kg__37361', name: '雷达榜', bangid: '37361' }, { id: 'kg__21101', name: '分享榜', bangid: '21101' }, { id: 'kg__46910', name: '综艺新歌榜', bangid: '46910' }, { id: 'kg__30972', name: '酷狗音乐人原创榜', bangid: '30972' }, { id: 'kg__60170', name: '闽南语榜', bangid: '60170' }, { id: 'kg__65234', name: '儿歌榜', bangid: '65234' }, { id: 'kg__4681', name: '美国BillBoard榜', bangid: '4681' }, { id: 'kg__25028', name: 'Beatport电子舞曲榜', bangid: '25028' }, { id: 'kg__4680', name: '英国单曲榜', bangid: '4680' }, { id: 'kg__38623', name: '韩国Melon音乐榜', bangid: '38623' }, { id: 'kg__42807', name: 'joox本地热歌榜', bangid: '42807' }, { id: 'kg__36107', name: '小语种热歌榜', bangid: '36107' }, { id: 'kg__4673', name: '日本公信榜', bangid: '4673' }, { id: 'kg__46868', name: '日本SPACE SHOWER榜', bangid: '46868' }, { id: 'kg__42808', name: 'KKBOX风云榜', bangid: '42808' }, { id: 'kg__60171', name: '越南语榜', bangid: '60171' }, { id: 'kg__60172', name: '泰语榜', bangid: '60172' }, { id: 'kg__59895', name: 'R&B榜', bangid: '59895' }, { id: 'kg__59896', name: '摇滚榜', bangid: '59896' }, { id: 'kg__59897', name: '爵士榜', bangid: '59897' }, { id: 'kg__59898', name: '乡村音乐榜', bangid: '59898' }, { id: 'kg__59900', name: '纯音乐榜', bangid: '59900' }, { id: 'kg__59899', name: '古典榜', bangid: '59899' }, { id: 'kg__22603', name: '5sing音乐榜', bangid: '22603' }, { id: 'kg__21335', name: '繁星音乐榜', bangid: '21335' }, { id: 'kg__33161', name: '古风新歌榜', bangid: '33161' }]
|
let boardList = [{ id: 'kg__8888', name: 'TOP500', bangid: '8888' }, { id: 'kg__6666', name: '飙升榜', bangid: '6666' }, { id: 'kg__59703', name: '蜂鸟流行音乐榜', bangid: '59703' }, { id: 'kg__52144', name: '抖音热歌榜', bangid: '52144' }, { id: 'kg__52767', name: '快手热歌榜', bangid: '52767' }, { id: 'kg__24971', name: 'DJ热歌榜', bangid: '24971' }, { id: 'kg__23784', name: '网络红歌榜', bangid: '23784' }, { id: 'kg__44412', name: '说唱先锋榜', bangid: '44412' }, { id: 'kg__31308', name: '内地榜', bangid: '31308' }, { id: 'kg__33160', name: '电音榜', bangid: '33160' }, { id: 'kg__31313', name: '香港地区榜', bangid: '31313' }, { id: 'kg__51341', name: '民谣榜', bangid: '51341' }, { id: 'kg__54848', name: '台湾地区榜', bangid: '54848' }, { id: 'kg__31310', name: '欧美榜', bangid: '31310' }, { id: 'kg__33162', name: 'ACG新歌榜', bangid: '33162' }, { id: 'kg__31311', name: '韩国榜', bangid: '31311' }, { id: 'kg__31312', name: '日本榜', bangid: '31312' }, { id: 'kg__49225', name: '80后热歌榜', bangid: '49225' }, { id: 'kg__49223', name: '90后热歌榜', bangid: '49223' }, { id: 'kg__49224', name: '00后热歌榜', bangid: '49224' }, { id: 'kg__33165', name: '粤语金曲榜', bangid: '33165' }, { id: 'kg__33166', name: '欧美金曲榜', bangid: '33166' }, { id: 'kg__33163', name: '影视金曲榜', bangid: '33163' }, { id: 'kg__51340', name: '伤感榜', bangid: '51340' }, { id: 'kg__35811', name: '会员专享榜', bangid: '35811' }, { id: 'kg__37361', name: '雷达榜', bangid: '37361' }, { id: 'kg__21101', name: '分享榜', bangid: '21101' }, { id: 'kg__46910', name: '综艺新歌榜', bangid: '46910' }, { id: 'kg__30972', name: '酷狗音乐人原创榜', bangid: '30972' }, { id: 'kg__60170', name: '闽南语榜', bangid: '60170' }, { id: 'kg__65234', name: '儿歌榜', bangid: '65234' }, { id: 'kg__4681', name: '美国BillBoard榜', bangid: '4681' }, { id: 'kg__25028', name: 'Beatport电子舞曲榜', bangid: '25028' }, { id: 'kg__4680', name: '英国单曲榜', bangid: '4680' }, { id: 'kg__38623', name: '韩国Melon音乐榜', bangid: '38623' }, { id: 'kg__42807', name: 'joox本地热歌榜', bangid: '42807' }, { id: 'kg__36107', name: '小语种热歌榜', bangid: '36107' }, { id: 'kg__4673', name: '日本公信榜', bangid: '4673' }, { id: 'kg__46868', name: '日本SPACE SHOWER榜', bangid: '46868' }, { id: 'kg__42808', name: 'KKBOX风云榜', bangid: '42808' }, { id: 'kg__60171', name: '越南语榜', bangid: '60171' }, { id: 'kg__60172', name: '泰语榜', bangid: '60172' }, { id: 'kg__59895', name: 'R&B榜', bangid: '59895' }, { id: 'kg__59896', name: '摇滚榜', bangid: '59896' }, { id: 'kg__59897', name: '爵士榜', bangid: '59897' }, { id: 'kg__59898', name: '乡村音乐榜', bangid: '59898' }, { id: 'kg__59900', name: '纯音乐榜', bangid: '59900' }, { id: 'kg__59899', name: '古典榜', bangid: '59899' }, { id: 'kg__22603', name: '5sing音乐榜', bangid: '22603' }, { id: 'kg__21335', name: '繁星音乐榜', bangid: '21335' }, { id: 'kg__33161', name: '古风新歌榜', bangid: '33161' }]
|
||||||
|
|
||||||
|
@ -8,7 +9,7 @@ export default {
|
||||||
list: [
|
list: [
|
||||||
{
|
{
|
||||||
id: 'kgtop500',
|
id: 'kgtop500',
|
||||||
name: '酷狗TOP500',
|
name: 'TOP500',
|
||||||
bangid: '8888',
|
bangid: '8888',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -126,7 +127,7 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
singer: decodeName(this.getSinger(item.authors)),
|
singer: formatSingerName(item.authors, 'author_name'),
|
||||||
name: decodeName(item.songname),
|
name: decodeName(item.songname),
|
||||||
albumName: decodeName(item.remark),
|
albumName: decodeName(item.remark),
|
||||||
albumId: item.album_id,
|
albumId: item.album_id,
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
import { decodeName, formatPlayTime, sizeFormate } from '../../index'
|
||||||
|
import { createHttpFetch } from './util'
|
||||||
|
|
||||||
|
const createGetMusicInfosTask = (hashs) => {
|
||||||
|
let data = {
|
||||||
|
appid: 1001,
|
||||||
|
clienttime: 639437935,
|
||||||
|
clientver: 9020,
|
||||||
|
fields: 'album_info,author_name,audio_info,ori_audio_name',
|
||||||
|
is_publish: '1',
|
||||||
|
key: '0475af1457cd3363c7b45b871e94428a',
|
||||||
|
mid: '21511157a05844bd085308bc76ef3342',
|
||||||
|
show_privilege: 1,
|
||||||
|
}
|
||||||
|
let list = hashs
|
||||||
|
let tasks = []
|
||||||
|
while (list.length) {
|
||||||
|
tasks.push(Object.assign({ data: list.slice(0, 100) }, data))
|
||||||
|
if (list.length < 100) break
|
||||||
|
list = list.slice(100)
|
||||||
|
}
|
||||||
|
let url = 'http://kmr.service.kugou.com/v2/album_audio/audio'
|
||||||
|
return tasks.map(task => createHttpFetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
body: task,
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
|
||||||
|
},
|
||||||
|
}).then(data => data.map(s => s[0])))
|
||||||
|
}
|
||||||
|
|
||||||
|
export const filterMusicInfoList = (rawList) => {
|
||||||
|
// console.log(rawList)
|
||||||
|
let ids = new Set()
|
||||||
|
let list = []
|
||||||
|
rawList.forEach(item => {
|
||||||
|
if (!item) return
|
||||||
|
if (ids.has(item.audio_info.audio_id)) return
|
||||||
|
ids.add(item.audio_info.audio_id)
|
||||||
|
const types = []
|
||||||
|
const _types = {}
|
||||||
|
if (item.audio_info.filesize !== '0') {
|
||||||
|
let size = sizeFormate(parseInt(item.audio_info.filesize))
|
||||||
|
types.push({ type: '128k', size, hash: item.audio_info.hash })
|
||||||
|
_types['128k'] = {
|
||||||
|
size,
|
||||||
|
hash: item.audio_info.hash,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.audio_info.filesize_320 !== '0') {
|
||||||
|
let size = sizeFormate(parseInt(item.audio_info.filesize_320))
|
||||||
|
types.push({ type: '320k', size, hash: item.audio_info.hash_320 })
|
||||||
|
_types['320k'] = {
|
||||||
|
size,
|
||||||
|
hash: item.audio_info.hash_320,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.audio_info.filesize_flac !== '0') {
|
||||||
|
let size = sizeFormate(parseInt(item.audio_info.filesize_flac))
|
||||||
|
types.push({ type: 'flac', size, hash: item.audio_info.hash_flac })
|
||||||
|
_types.flac = {
|
||||||
|
size,
|
||||||
|
hash: item.audio_info.hash_flac,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.audio_info.filesize_high !== '0') {
|
||||||
|
let size = sizeFormate(parseInt(item.audio_info.filesize_high))
|
||||||
|
types.push({ type: 'flac24bit', size, hash: item.audio_info.hash_high })
|
||||||
|
_types.flac24bit = {
|
||||||
|
size,
|
||||||
|
hash: item.audio_info.hash_high,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list.push({
|
||||||
|
singer: decodeName(item.author_name),
|
||||||
|
name: decodeName(item.ori_audio_name),
|
||||||
|
albumName: decodeName(item.album_info.album_name),
|
||||||
|
albumId: item.album_info.album_id,
|
||||||
|
songmid: item.audio_info.audio_id,
|
||||||
|
source: 'kg',
|
||||||
|
interval: formatPlayTime(parseInt(item.audio_info.timelength) / 1000),
|
||||||
|
img: null,
|
||||||
|
lrc: null,
|
||||||
|
hash: item.audio_info.hash,
|
||||||
|
otherSource: null,
|
||||||
|
types,
|
||||||
|
_types,
|
||||||
|
typeUrl: {},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getMusicInfos = async(hashs) => {
|
||||||
|
return filterMusicInfoList(await Promise.all(createGetMusicInfosTask(hashs)).then(data => data.flat()))
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getMusicInfo = async(hash) => {
|
||||||
|
return getMusicInfos([hash]).then(data => data[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getMusicInfosByList = (list) => {
|
||||||
|
return getMusicInfos(list.map(item => ({ hash: item.hash })))
|
||||||
|
}
|
|
@ -1,9 +1,6 @@
|
||||||
// import '../../polyfill/array.find'
|
|
||||||
|
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { decodeName, formatPlayTime, sizeFormate } from '../../index'
|
import { decodeName, formatPlayTime, sizeFormate } from '../../index'
|
||||||
// import { debug } from '../../utils/env'
|
import { formatSingerName } from '@renderer/utils/musicSdk/utils'
|
||||||
// import { formatSinger } from './util'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
limit: 30,
|
limit: 30,
|
||||||
|
@ -50,7 +47,7 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
singer: decodeName(rawData.SingerName),
|
singer: decodeName(formatSingerName(rawData.Singers, 'name')),
|
||||||
name: decodeName(rawData.SongName),
|
name: decodeName(rawData.SongName),
|
||||||
albumName: decodeName(rawData.AlbumName),
|
albumName: decodeName(rawData.AlbumName),
|
||||||
albumId: rawData.AlbumID,
|
albumId: rawData.AlbumID,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { decodeName, formatPlayTime, sizeFormate, dateFormat } from '../../index'
|
import { decodeName, formatPlayTime, sizeFormate, dateFormat, formatPlayCount } from '../../index'
|
||||||
import infSign from './vendors/infSign.min'
|
import infSign from './vendors/infSign.min'
|
||||||
import { signatureParams } from './util'
|
import { signatureParams } from './util'
|
||||||
|
|
||||||
|
@ -52,17 +52,17 @@ export default {
|
||||||
// https://www.kugou.com/yy/special/single/1067062.html
|
// https://www.kugou.com/yy/special/single/1067062.html
|
||||||
listDetailLink: /^.+\/(\d+)\.html(?:\?.*|&.*$|#.*$|$)/,
|
listDetailLink: /^.+\/(\d+)\.html(?:\?.*|&.*$|#.*$|$)/,
|
||||||
},
|
},
|
||||||
async getGlobalSpecialId(specialId) {
|
// async getGlobalSpecialId(specialId) {
|
||||||
return httpFetch(`http://mobilecdnbj.kugou.com/api/v5/special/info?specialid=${specialId}`, {
|
// return httpFetch(`http://mobilecdnbj.kugou.com/api/v5/special/info?specialid=${specialId}`, {
|
||||||
headers: {
|
// headers: {
|
||||||
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; HLK-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Mobile Safari/537.36 EdgA/104.0.1293.70',
|
// 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; HLK-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Mobile Safari/537.36 EdgA/104.0.1293.70',
|
||||||
},
|
// },
|
||||||
}).promise.then(({ body }) => {
|
// }).promise.then(({ body }) => {
|
||||||
// console.log(body)
|
// // console.log(body)
|
||||||
if (!body.data.global_specialid) Promise.reject(new Error('Failed to get global collection id.'))
|
// if (!body.data.global_specialid) Promise.reject(new Error('Failed to get global collection id.'))
|
||||||
return body.data.global_specialid
|
// return body.data.global_specialid
|
||||||
})
|
// })
|
||||||
},
|
// },
|
||||||
// async getListInfoBySpecialId(special_id, retry = 0) {
|
// async getListInfoBySpecialId(special_id, retry = 0) {
|
||||||
// if (++retry > 2) throw new Error('failed')
|
// if (++retry > 2) throw new Error('failed')
|
||||||
// return httpFetch(`https://m.kugou.com/plist/list/${special_id}/?json=true`, {
|
// return httpFetch(`https://m.kugou.com/plist/list/${special_id}/?json=true`, {
|
||||||
|
@ -135,7 +135,7 @@ export default {
|
||||||
img: pic,
|
img: pic,
|
||||||
desc,
|
desc,
|
||||||
// author: body.result.info.userinfo.username,
|
// author: body.result.info.userinfo.username,
|
||||||
// play_count: this.formatPlayCount(body.result.listen_num),
|
// play_count: formatPlayCount(body.result.listen_num),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ export default {
|
||||||
// img: listInfo.image,
|
// img: listInfo.image,
|
||||||
// desc: listInfo.intro,
|
// desc: listInfo.intro,
|
||||||
// author: listInfo.author,
|
// author: listInfo.author,
|
||||||
// play_count: this.formatPlayCount(listInfo.playcount),
|
// play_count: formatPlayCount(listInfo.playcount),
|
||||||
// },
|
// },
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
|
@ -172,15 +172,6 @@ export default {
|
||||||
return `http://www2.kugou.kugou.com/yueku/v9/special/single/${id}-5-9999.html`
|
return `http://www2.kugou.kugou.com/yueku/v9/special/single/${id}-5-9999.html`
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* 格式化播放数量
|
|
||||||
* @param {*} num
|
|
||||||
*/
|
|
||||||
formatPlayCount(num) {
|
|
||||||
if (num > 100000000) return parseInt(num / 10000000) / 10 + '亿'
|
|
||||||
if (num > 10000) return parseInt(num / 1000) / 10 + '万'
|
|
||||||
return num
|
|
||||||
},
|
|
||||||
filterInfoHotTag(rawData) {
|
filterInfoHotTag(rawData) {
|
||||||
const result = []
|
const result = []
|
||||||
if (rawData.status !== 1) return result
|
if (rawData.status !== 1) return result
|
||||||
|
@ -252,7 +243,7 @@ export default {
|
||||||
},
|
},
|
||||||
filterList(rawData) {
|
filterList(rawData) {
|
||||||
return rawData.map(item => ({
|
return rawData.map(item => ({
|
||||||
play_count: item.total_play_count || this.formatPlayCount(item.play_count),
|
play_count: item.total_play_count || formatPlayCount(item.play_count),
|
||||||
id: 'id_' + item.specialid,
|
id: 'id_' + item.specialid,
|
||||||
author: item.nickname,
|
author: item.nickname,
|
||||||
name: item.specialname,
|
name: item.specialname,
|
||||||
|
@ -374,7 +365,7 @@ export default {
|
||||||
img: (info.img_size && info.img_size.replace('{size}', 240)) || info.img,
|
img: (info.img_size && info.img_size.replace('{size}', 240)) || info.img,
|
||||||
// desc: body.result.info.list_desc,
|
// desc: body.result.info.list_desc,
|
||||||
author: info.username,
|
author: info.username,
|
||||||
// play_count: this.formatPlayCount(info.count),
|
// play_count: formatPlayCount(info.count),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -402,7 +393,7 @@ export default {
|
||||||
img: songInfo.info.img,
|
img: songInfo.info.img,
|
||||||
// desc: body.result.info.list_desc,
|
// desc: body.result.info.list_desc,
|
||||||
author: songInfo.info.username,
|
author: songInfo.info.username,
|
||||||
// play_count: this.formatPlayCount(info.count),
|
// play_count: formatPlayCount(info.count),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -446,7 +437,7 @@ export default {
|
||||||
img: listInfo.pic && listInfo.pic.replace('{size}', 240),
|
img: listInfo.pic && listInfo.pic.replace('{size}', 240),
|
||||||
// desc: body.result.info.list_desc,
|
// desc: body.result.info.list_desc,
|
||||||
author: listInfo.list_create_username,
|
author: listInfo.list_create_username,
|
||||||
// play_count: this.formatPlayCount(listInfo.count),
|
// play_count: formatPlayCount(listInfo.count),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -497,7 +488,7 @@ export default {
|
||||||
img: info.imgurl && info.imgurl.replace('{size}', 240),
|
img: info.imgurl && info.imgurl.replace('{size}', 240),
|
||||||
desc: info.intro,
|
desc: info.intro,
|
||||||
author: info.nickname,
|
author: info.nickname,
|
||||||
play_count: this.formatPlayCount(info.playcount),
|
play_count: formatPlayCount(info.playcount),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -548,7 +539,7 @@ export default {
|
||||||
img: listInfo.imgurl && listInfo.imgurl.replace('{size}', 240),
|
img: listInfo.imgurl && listInfo.imgurl.replace('{size}', 240),
|
||||||
// desc: body.result.info.list_desc,
|
// desc: body.result.info.list_desc,
|
||||||
author: listInfo.nickname,
|
author: listInfo.nickname,
|
||||||
// play_count: this.formatPlayCount(info.count),
|
// play_count: formatPlayCount(info.count),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -569,7 +560,7 @@ export default {
|
||||||
img: listInfo.imgurl && listInfo.imgurl.replace('{size}', 240),
|
img: listInfo.imgurl && listInfo.imgurl.replace('{size}', 240),
|
||||||
// desc: body.result.info.list_desc,
|
// desc: body.result.info.list_desc,
|
||||||
author: listInfo.nickname,
|
author: listInfo.nickname,
|
||||||
// play_count: this.formatPlayCount(info.count),
|
// play_count: formatPlayCount(info.count),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -905,7 +896,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
list: body.data.info.map(item => {
|
list: body.data.info.map(item => {
|
||||||
return {
|
return {
|
||||||
play_count: this.formatPlayCount(item.playcount),
|
play_count: formatPlayCount(item.playcount),
|
||||||
id: 'id_' + item.specialid,
|
id: 'id_' + item.specialid,
|
||||||
author: item.nickname,
|
author: item.nickname,
|
||||||
name: item.specialname,
|
name: item.specialname,
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
import { formatSingerName } from '@renderer/utils/musicSdk/utils'
|
||||||
|
import { decodeName, formatPlayTime, sizeFormate } from '../../index'
|
||||||
|
import { signatureParams, createHttpFetch } from './util'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
limit: 30,
|
||||||
|
total: 0,
|
||||||
|
page: 0,
|
||||||
|
allPage: 1,
|
||||||
|
musicSearch(str, page, limit) {
|
||||||
|
const sign = signatureParams(`userid=0&area_code=1&appid=1005&dopicfull=1&page=${page}&token=0&privilegefilter=0&requestid=0&pagesize=${limit}&user_labels=&clienttime=0&sec_aggre=1&iscorrection=1&uuid=0&mid=0&keyword=${str}&dfid=-&clientver=11409&platform=AndroidFilter&tag=`, 3)
|
||||||
|
return createHttpFetch(`https://gateway.kugou.com/complexsearch/v3/search/song?userid=0&area_code=1&appid=1005&dopicfull=1&page=${page}&token=0&privilegefilter=0&requestid=0&pagesize=${limit}&user_labels=&clienttime=0&sec_aggre=1&iscorrection=1&uuid=0&mid=0&dfid=-&clientver=11409&platform=AndroidFilter&tag=&keyword=${encodeURIComponent(str)}&signature=${sign}`, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
|
||||||
|
referer: 'https://kugou.com',
|
||||||
|
},
|
||||||
|
}).then(body => body)
|
||||||
|
},
|
||||||
|
filterList(raw) {
|
||||||
|
let ids = new Set()
|
||||||
|
const list = []
|
||||||
|
|
||||||
|
raw.forEach(item => {
|
||||||
|
if (ids.has(item.Audioid)) return
|
||||||
|
ids.add(item.Audioid)
|
||||||
|
|
||||||
|
const types = []
|
||||||
|
const _types = {}
|
||||||
|
if (item.FileSize !== 0) {
|
||||||
|
let size = sizeFormate(item.FileSize)
|
||||||
|
types.push({ type: '128k', size, hash: item.FileHash })
|
||||||
|
_types['128k'] = {
|
||||||
|
size,
|
||||||
|
hash: item.FileHash,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.HQ != undefined) {
|
||||||
|
let size = sizeFormate(item.HQ.FileSize)
|
||||||
|
types.push({ type: '320k', size, hash: item.HQ.Hash })
|
||||||
|
_types['320k'] = {
|
||||||
|
size,
|
||||||
|
hash: item.HQ.Hash,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.SQ != undefined) {
|
||||||
|
let size = sizeFormate(item.SQ.FileSize)
|
||||||
|
types.push({ type: 'flac', size, hash: item.SQ.Hash })
|
||||||
|
_types.flac = {
|
||||||
|
size,
|
||||||
|
hash: item.SQ.Hash,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.Res != undefined) {
|
||||||
|
let size = sizeFormate(item.Res.FileSize)
|
||||||
|
types.push({ type: 'flac24bit', size, hash: item.Res.Hash })
|
||||||
|
_types.flac24bit = {
|
||||||
|
size,
|
||||||
|
hash: item.Res.Hash,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list.push({
|
||||||
|
singer: decodeName(formatSingerName(item.Singers)),
|
||||||
|
name: decodeName(item.SongName),
|
||||||
|
albumName: decodeName(item.AlbumName),
|
||||||
|
albumId: item.AlbumID,
|
||||||
|
songmid: item.Audioid,
|
||||||
|
source: 'kg',
|
||||||
|
interval: formatPlayTime(item.Duration),
|
||||||
|
_interval: item.Duration,
|
||||||
|
img: null,
|
||||||
|
lrc: null,
|
||||||
|
otherSource: null,
|
||||||
|
hash: item.FileHash,
|
||||||
|
types,
|
||||||
|
_types,
|
||||||
|
typeUrl: {},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return list
|
||||||
|
},
|
||||||
|
handleResult(rawData) {
|
||||||
|
const rawList = []
|
||||||
|
rawData.forEach(item => {
|
||||||
|
rawList.push(item)
|
||||||
|
item.Grp.forEach(e => rawList.push(e))
|
||||||
|
})
|
||||||
|
|
||||||
|
return this.filterList(rawList)
|
||||||
|
},
|
||||||
|
search(str, page = 1, limit, retryNum = 0) {
|
||||||
|
if (++retryNum > 3) return Promise.reject(new Error('try max num'))
|
||||||
|
if (limit == null) limit = this.limit
|
||||||
|
|
||||||
|
return this.musicSearch(str, page, limit).then(data => {
|
||||||
|
let list = this.handleResult(data.lists)
|
||||||
|
if (!list) return this.search(str, page, limit, retryNum)
|
||||||
|
|
||||||
|
this.total = data.total
|
||||||
|
this.page = page
|
||||||
|
this.allPage = Math.ceil(this.total / limit)
|
||||||
|
|
||||||
|
return Promise.resolve({
|
||||||
|
list,
|
||||||
|
allPage: this.allPage,
|
||||||
|
limit,
|
||||||
|
total: this.total,
|
||||||
|
source: 'kg',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
|
@ -0,0 +1,794 @@
|
||||||
|
import { httpFetch } from '../../../request'
|
||||||
|
import { formatSingerName } from '../../utils'
|
||||||
|
import { decodeName, formatPlayTime, sizeFormate, dateFormat, formatPlayCount } from '../../../index'
|
||||||
|
import { signatureParams, createHttpFetch } from './../util'
|
||||||
|
import { getMusicInfosByList } from '../musicInfo'
|
||||||
|
import album from '../album'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
_requestObj_tags: null,
|
||||||
|
_requestObj_listInfo: null,
|
||||||
|
_requestObj_list: null,
|
||||||
|
_requestObj_listRecommend: null,
|
||||||
|
listDetailLimit: 10000,
|
||||||
|
currentTagInfo: {
|
||||||
|
id: undefined,
|
||||||
|
info: undefined,
|
||||||
|
},
|
||||||
|
sortList: [
|
||||||
|
{
|
||||||
|
name: '推荐',
|
||||||
|
id: '5',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '最热',
|
||||||
|
id: '6',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '最新',
|
||||||
|
id: '7',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '热藏',
|
||||||
|
id: '3',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '飙升',
|
||||||
|
id: '8',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cache: new Map(),
|
||||||
|
collectionIdListInfoCache: new Map(),
|
||||||
|
regExps: {
|
||||||
|
listData: /global\.data = (\[.+\]);/,
|
||||||
|
listInfo: /global = {[\s\S]+?name: "(.+)"[\s\S]+?pic: "(.+)"[\s\S]+?};/,
|
||||||
|
// https://www.kugou.com/yy/special/single/1067062.html
|
||||||
|
listDetailLink: /^.+\/(\d+)\.html(?:\?.*|&.*$|#.*$|$)/,
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取歌曲列表内的音乐
|
||||||
|
* @param {*} id
|
||||||
|
* @param {*} page
|
||||||
|
*/
|
||||||
|
async getListDetail(id, page) {
|
||||||
|
id = id.toString()
|
||||||
|
|
||||||
|
if (id.includes('special/single/')) id = id.replace(this.regExps.listDetailLink, '$1')
|
||||||
|
// fix https://www.kugou.com/songlist/xxx/?uid=xxx&chl=qq_client&cover=http%3A%2F%2Fimge.kugou.com%xxx.jpg&iszlist=1
|
||||||
|
if (/https?:/.test(id)) {
|
||||||
|
if (id.includes('#')) id = id.replace(/#.*$/, '')
|
||||||
|
if (id.includes('global_collection_id')) return this.getUserListDetailByCollectionId(id.replace(/^.*?global_collection_id=(\w+)(?:&.*$|#.*$|$)/, '$1'), page)
|
||||||
|
if (id.includes('chain=')) return this.getUserListDetail3(id.replace(/^.*?chain=(\w+)(?:&.*$|#.*$|$)/, '$1'), page)
|
||||||
|
if (id.includes('.html')) {
|
||||||
|
if (id.includes('zlist.html')) {
|
||||||
|
id = id.replace(/^(.*)zlist\.html/, 'https://m3ws.kugou.com/zlist/list')
|
||||||
|
if (id.includes('pagesize')) {
|
||||||
|
id = id.replace('pagesize=30', 'pagesize=' + this.listDetailLimit).replace('page=1', 'page=' + page)
|
||||||
|
} else {
|
||||||
|
id += `&pagesize=${this.listDetailLimit}&page=${page}`
|
||||||
|
}
|
||||||
|
} else if (!id.includes('song.html')) return this.getUserListDetail3(id.replace(/.+\/(\w+).html(?:\?.*|&.*$|#.*$|$)/, '$1'), page)
|
||||||
|
}
|
||||||
|
return this.getUserListDetail(id.replace(/^.*?http/, 'http'), page)
|
||||||
|
}
|
||||||
|
if (/^\d+$/.test(id)) return this.getUserListDetailByCode(id, page)
|
||||||
|
if (id.startsWith('gid_')) return this.getUserListDetailByCollectionId(id.replace('gid_', ''), page)
|
||||||
|
if (id.startsWith('id_')) return this.getUserListDetailBySpecialId(id.replace('id_', ''), page)
|
||||||
|
|
||||||
|
return new Error('Failed.')
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取SpecialId歌单
|
||||||
|
* @param {*} id
|
||||||
|
*/
|
||||||
|
async getUserListDetailBySpecialId(id, page, tryNum = 0) {
|
||||||
|
if (tryNum > 2) throw new Error('try max num')
|
||||||
|
|
||||||
|
const { body } = await httpFetch(this.getSongListDetailUrl(id)).promise
|
||||||
|
let listData = body.match(this.regExps.listData)
|
||||||
|
let listInfo = body.match(this.regExps.listInfo)
|
||||||
|
if (!listData) return this.getListDetailBySpecialId(id, page, ++tryNum)
|
||||||
|
let list = await getMusicInfosByList(JSON.parse(listData[1]))
|
||||||
|
let name
|
||||||
|
let pic
|
||||||
|
if (listInfo) {
|
||||||
|
name = listInfo[1]
|
||||||
|
pic = listInfo[2]
|
||||||
|
}
|
||||||
|
let desc = this.parseHtmlDesc(body)
|
||||||
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
list,
|
||||||
|
page: 1,
|
||||||
|
limit: 10000,
|
||||||
|
total: list.length,
|
||||||
|
source: 'kg',
|
||||||
|
info: {
|
||||||
|
name,
|
||||||
|
img: pic,
|
||||||
|
desc,
|
||||||
|
// author: body.result.info.userinfo.username,
|
||||||
|
// play_count: formatPlayCount(body.result.listen_num),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
parseHtmlDesc(html) {
|
||||||
|
const prefix = '<div class="pc_specail_text pc_singer_tab_content" id="specailIntroduceWrap">'
|
||||||
|
let index = html.indexOf(prefix)
|
||||||
|
if (index < 0) return null
|
||||||
|
const afterStr = html.substring(index + prefix.length)
|
||||||
|
index = afterStr.indexOf('</div>')
|
||||||
|
if (index < 0) return null
|
||||||
|
return decodeName(afterStr.substring(0, index))
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用SpecialId获取CollectionId
|
||||||
|
* @param {*} specialId
|
||||||
|
*/
|
||||||
|
async getCollectionIdBySpecialId(specialId) {
|
||||||
|
return httpFetch(`http://mobilecdnbj.kugou.com/api/v5/special/info?specialid=${specialId}`, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; HLK-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Mobile Safari/537.36 EdgA/104.0.1293.70',
|
||||||
|
},
|
||||||
|
}).promise.then(({ body }) => {
|
||||||
|
// console.log('getCollectionIdBySpecialId', body)
|
||||||
|
if (!body.data.global_specialid) return Promise.reject(new Error('Failed to get global collection id.'))
|
||||||
|
return body.data.global_specialid
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取歌单URL
|
||||||
|
* @param {*} sortId
|
||||||
|
* @param {*} tagId
|
||||||
|
* @param {*} page
|
||||||
|
*/
|
||||||
|
getSongListUrl(sortId, tagId, page) {
|
||||||
|
if (tagId == null) tagId = ''
|
||||||
|
return `http://www2.kugou.kugou.com/yueku/v9/special/getSpecial?is_ajax=1&cdn=cdn&t=${sortId}&c=${tagId}&p=${page}`
|
||||||
|
},
|
||||||
|
getInfoUrl(tagId) {
|
||||||
|
return tagId
|
||||||
|
? `http://www2.kugou.kugou.com/yueku/v9/special/getSpecial?is_smarty=1&cdn=cdn&t=5&c=${tagId}`
|
||||||
|
: 'http://www2.kugou.kugou.com/yueku/v9/special/getSpecial?is_smarty=1&'
|
||||||
|
},
|
||||||
|
getSongListDetailUrl(id) {
|
||||||
|
return `http://www2.kugou.kugou.com/yueku/v9/special/single/${id}-5-9999.html`
|
||||||
|
},
|
||||||
|
|
||||||
|
filterInfoHotTag(rawData) {
|
||||||
|
const result = []
|
||||||
|
if (rawData.status !== 1) return result
|
||||||
|
for (const key of Object.keys(rawData.data)) {
|
||||||
|
let tag = rawData.data[key]
|
||||||
|
result.push({
|
||||||
|
id: tag.special_id,
|
||||||
|
name: tag.special_name,
|
||||||
|
source: 'kg',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
|
filterTagInfo(rawData) {
|
||||||
|
const result = []
|
||||||
|
for (const name of Object.keys(rawData)) {
|
||||||
|
result.push({
|
||||||
|
name,
|
||||||
|
list: rawData[name].data.map(tag => ({
|
||||||
|
parent_id: tag.parent_id,
|
||||||
|
parent_name: tag.pname,
|
||||||
|
id: tag.id,
|
||||||
|
name: tag.name,
|
||||||
|
source: 'kg',
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
filterSongList(rawData) {
|
||||||
|
return rawData.map(item => ({
|
||||||
|
play_count: item.total_play_count || formatPlayCount(item.play_count),
|
||||||
|
id: 'id_' + item.specialid,
|
||||||
|
author: item.nickname,
|
||||||
|
name: item.specialname,
|
||||||
|
time: dateFormat(item.publish_time || item.publishtime, 'Y-M-D'),
|
||||||
|
img: item.img || item.imgurl,
|
||||||
|
total: item.songcount,
|
||||||
|
grade: item.grade,
|
||||||
|
desc: item.intro,
|
||||||
|
source: 'kg',
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
|
||||||
|
getSongList(sortId, tagId, page, tryNum = 0) {
|
||||||
|
if (this._requestObj_list) this._requestObj_list.cancelHttp()
|
||||||
|
if (tryNum > 2) return Promise.reject(new Error('try max num'))
|
||||||
|
this._requestObj_list = httpFetch(
|
||||||
|
this.getSongListUrl(sortId, tagId, page),
|
||||||
|
)
|
||||||
|
return this._requestObj_list.promise.then(({ body }) => {
|
||||||
|
if (!body || body.status !== 1) return this.getSongList(sortId, tagId, page, ++tryNum)
|
||||||
|
return this.filterSongList(body.special_db)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getSongListRecommend(tryNum = 0) {
|
||||||
|
if (this._requestObj_listRecommend) this._requestObj_listRecommend.cancelHttp()
|
||||||
|
if (tryNum > 2) return Promise.reject(new Error('try max num'))
|
||||||
|
this._requestObj_listRecommend = httpFetch(
|
||||||
|
'http://everydayrec.service.kugou.com/guess_special_recommend',
|
||||||
|
{
|
||||||
|
method: 'post',
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'KuGou2012-8275-web_browser_event_handler',
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
appid: 1001,
|
||||||
|
clienttime: 1566798337219,
|
||||||
|
clientver: 8275,
|
||||||
|
key: 'f1f93580115bb106680d2375f8032d96',
|
||||||
|
mid: '21511157a05844bd085308bc76ef3343',
|
||||||
|
platform: 'pc',
|
||||||
|
userid: '262643156',
|
||||||
|
return_min: 6,
|
||||||
|
return_max: 15,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return this._requestObj_listRecommend.promise.then(({ body }) => {
|
||||||
|
if (body.status !== 1) return this.getSongListRecommend(++tryNum)
|
||||||
|
return this.filterSongList(body.data.special_list)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过CollectionId获取歌单详情
|
||||||
|
* @param {*} id
|
||||||
|
*/
|
||||||
|
async getUserListInfoByCollectionId(id) {
|
||||||
|
if (!id || id.length > 1000) return Promise.reject(new Error('get list error'))
|
||||||
|
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=-`
|
||||||
|
return createHttpFetch(`https://mobiles.kugou.com/api/v5/special/info_v2?${params}&signature=${signatureParams(params, 5)}`, {
|
||||||
|
headers: {
|
||||||
|
mid: '1586163242519',
|
||||||
|
Referer: 'https://m3ws.kugou.com/share/index.php',
|
||||||
|
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
|
||||||
|
dfid: '-',
|
||||||
|
clienttime: '1586163242519',
|
||||||
|
},
|
||||||
|
}).then(body => {
|
||||||
|
let info = {
|
||||||
|
type: body.type,
|
||||||
|
userName: body.nickname,
|
||||||
|
userAvatar: body.user_avatar,
|
||||||
|
imageUrl: body.imgurl,
|
||||||
|
desc: body.intro,
|
||||||
|
name: body.specialname,
|
||||||
|
globalSpecialid: body.global_specialid,
|
||||||
|
total: body.songcount,
|
||||||
|
playCount: body.playcount,
|
||||||
|
}
|
||||||
|
|
||||||
|
this.collectionIdListInfoCache.set(id, info)
|
||||||
|
return info
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 通过SpecialId获取歌单
|
||||||
|
* @param {*} id
|
||||||
|
*/
|
||||||
|
// async getUserListDetailBySpecialId(id, page = 1, limit = 300) {
|
||||||
|
// if (!id || id.length > 1000) return Promise.reject(new Error('get list error.'))
|
||||||
|
// const listInfo = await this.getListInfoBySpecialId(id)
|
||||||
|
|
||||||
|
// const params = `specialid=${id}&need_sort=1&module=CloudMusic&clientver=11589&pagesize=${limit}&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)}`, {
|
||||||
|
// headers: {
|
||||||
|
// 'User-Agent': 'Android10-AndroidPhone-11589-201-0-playlist-wifi',
|
||||||
|
// },
|
||||||
|
// }).then(body => {
|
||||||
|
// if (!body.info) return Promise.reject(new Error('Get list failed.'))
|
||||||
|
// const songList = this.filterListByCollectionId(body.info)
|
||||||
|
|
||||||
|
// return {
|
||||||
|
// list: songList || [],
|
||||||
|
// page,
|
||||||
|
// limit,
|
||||||
|
// total: body.count,
|
||||||
|
// source: 'kg',
|
||||||
|
// info: {
|
||||||
|
// name: listInfo.name,
|
||||||
|
// img: listInfo.image,
|
||||||
|
// desc: listInfo.desc,
|
||||||
|
// // author: listInfo.userName,
|
||||||
|
// // play_count: formatPlayCount(listInfo.playCount),
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// },
|
||||||
|
/**
|
||||||
|
* 通过CollectionId获取歌单
|
||||||
|
* @param {*} id
|
||||||
|
*/
|
||||||
|
async getUserListDetailByCollectionId(id, page = 1, limit = 300) {
|
||||||
|
if (!id || id.length > 1000) return Promise.reject(new Error('ID error.'))
|
||||||
|
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`
|
||||||
|
return createHttpFetch(`http://pubsongs.kugou.com/v2/get_other_list_file?${params}&signature=${signatureParams(params, 2)}`, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'Android10-AndroidPhone-11589-201-0-playlist-wifi',
|
||||||
|
},
|
||||||
|
}).then(body => {
|
||||||
|
if (!body.info) return Promise.reject(new Error('Get list failed.'))
|
||||||
|
const songList = this.filterListByCollectionId(body.info)
|
||||||
|
|
||||||
|
return {
|
||||||
|
list: songList || [],
|
||||||
|
page,
|
||||||
|
limit,
|
||||||
|
total: listInfo.total,
|
||||||
|
source: 'kg',
|
||||||
|
info: {
|
||||||
|
name: listInfo.name,
|
||||||
|
img: listInfo.imageUrl && listInfo.imageUrl.replace('{size}', 240),
|
||||||
|
desc: listInfo.desc,
|
||||||
|
author: listInfo.userName,
|
||||||
|
play_count: formatPlayCount(listInfo.playCount),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 过滤GlobalSpecialId歌单数据
|
||||||
|
* @param {*} rawData
|
||||||
|
*/
|
||||||
|
filterListByCollectionId(rawData) {
|
||||||
|
let ids = new Set()
|
||||||
|
let list = []
|
||||||
|
rawData.forEach(item => {
|
||||||
|
if (!item) return
|
||||||
|
if (ids.has(item.hash)) return
|
||||||
|
ids.add(item.hash)
|
||||||
|
const types = []
|
||||||
|
const _types = {}
|
||||||
|
|
||||||
|
item.relate_goods.forEach(data => {
|
||||||
|
let size = sizeFormate(data.size)
|
||||||
|
switch (data.level) {
|
||||||
|
case 2:
|
||||||
|
types.push({ type: '128k', size, hash: data.hash })
|
||||||
|
_types['128k'] = {
|
||||||
|
size,
|
||||||
|
hash: data.hash,
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 4:
|
||||||
|
types.push({ type: '320k', size, hash: data.hash })
|
||||||
|
_types['320k'] = {
|
||||||
|
size,
|
||||||
|
hash: data.hash,
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 5:
|
||||||
|
types.push({ type: 'flac', size, hash: data.hash })
|
||||||
|
_types.flac = {
|
||||||
|
size,
|
||||||
|
hash: data.hash,
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 6:
|
||||||
|
types.push({ type: 'flac24bit', size, hash: data.hash })
|
||||||
|
_types.flac24bit = {
|
||||||
|
size,
|
||||||
|
hash: data.hash,
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
list.push({
|
||||||
|
singer: formatSingerName(item.singerinfo, 'name') || decodeName(item.name).split(' - ')[0].replace(/&/g, '、'),
|
||||||
|
name: decodeName(item.name).split(' - ')[1],
|
||||||
|
albumName: decodeName(item.albuminfo.name),
|
||||||
|
albumId: item.albuminfo.id,
|
||||||
|
songmid: item.audio_id,
|
||||||
|
source: 'kg',
|
||||||
|
interval: formatPlayTime(parseInt(item.timelen) / 1000),
|
||||||
|
img: null,
|
||||||
|
lrc: null,
|
||||||
|
hash: item.hash,
|
||||||
|
otherSource: null,
|
||||||
|
types,
|
||||||
|
_types,
|
||||||
|
typeUrl: {},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return list
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 通过酷狗码获取歌单
|
||||||
|
* @param {*} id
|
||||||
|
* @param {*} page
|
||||||
|
*/
|
||||||
|
async getUserListDetailByCode(id, page = 1) {
|
||||||
|
// type 1单曲,2歌单,3电台,4酷狗码,5别人的播放队列
|
||||||
|
const codeData = await createHttpFetch('http://t.kugou.com/command/', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'KG-RC': 1,
|
||||||
|
'KG-THash': 'network_super_call.cpp:3676261689:379',
|
||||||
|
'User-Agent': '',
|
||||||
|
},
|
||||||
|
body: { appid: 1001, clientver: 9020, mid: '21511157a05844bd085308bc76ef3343', clienttime: 640612895, key: '36164c4015e704673c588ee202b9ecb8', data: id },
|
||||||
|
})
|
||||||
|
if (!codeData) return Promise.reject(new Error('Get list failed.'))
|
||||||
|
const codeInfo = codeData.info
|
||||||
|
|
||||||
|
switch (codeInfo.type) {
|
||||||
|
case 2:
|
||||||
|
if (!codeInfo.global_collection_id) return this.getUserListDetailBySpecialId(codeInfo.id, page)
|
||||||
|
break
|
||||||
|
case 3:
|
||||||
|
return album.getAlbumDetail(codeInfo.id, page)
|
||||||
|
}
|
||||||
|
if (codeInfo.global_collection_id) return this.getUserListDetailByCollectionId(codeInfo.global_collection_id, page)
|
||||||
|
|
||||||
|
if (codeInfo.userid != null) {
|
||||||
|
const songList = await createHttpFetch('http://www2.kugou.kugou.com/apps/kucodeAndShare/app/', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'KG-RC': 1,
|
||||||
|
'KG-THash': 'network_super_call.cpp:3676261689:379',
|
||||||
|
'User-Agent': '',
|
||||||
|
},
|
||||||
|
body: { appid: 1001, clientver: 9020, mid: '21511157a05844bd085308bc76ef3343', clienttime: 640612895, key: '36164c4015e704673c588ee202b9ecb8', data: { id: codeInfo.id, type: 3, userid: codeInfo.userid, collect_type: 0, page: 1, pagesize: codeInfo.count } },
|
||||||
|
})
|
||||||
|
// console.log(songList)
|
||||||
|
let list = await getMusicInfosByList(songList || codeInfo.list)
|
||||||
|
return {
|
||||||
|
list,
|
||||||
|
page: 1,
|
||||||
|
limit: codeInfo.count,
|
||||||
|
total: list.length,
|
||||||
|
source: 'kg',
|
||||||
|
info: {
|
||||||
|
name: codeInfo.name,
|
||||||
|
img: (codeInfo.img_size && codeInfo.img_size.replace('{size}', 240)) || codeInfo.img,
|
||||||
|
// desc: body.result.info.list_desc,
|
||||||
|
author: codeInfo.username,
|
||||||
|
// play_count: formatPlayCount(info.count),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async getUserListDetail3(chain, page) {
|
||||||
|
const songInfo = await createHttpFetch(`http://m.kugou.com/schain/transfer?pagesize=${this.listDetailLimit}&chain=${chain}&su=1&page=${page}&n=0.7928855356604456`, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if (!songInfo.list) {
|
||||||
|
if (songInfo.global_collection_id) return this.getUserListDetailByCollectionId(songInfo.global_collection_id, page)
|
||||||
|
else return this.getUserListDetail4(songInfo, chain, page).catch(() => this.getUserListDetail5(chain))
|
||||||
|
}
|
||||||
|
let list = await getMusicInfosByList(songInfo.list)
|
||||||
|
// console.log(info, songInfo)
|
||||||
|
return {
|
||||||
|
list,
|
||||||
|
page: 1,
|
||||||
|
limit: this.listDetailLimit,
|
||||||
|
total: list.length,
|
||||||
|
source: 'kg',
|
||||||
|
info: {
|
||||||
|
name: songInfo.info.name,
|
||||||
|
img: songInfo.info.img,
|
||||||
|
// desc: body.result.info.list_desc,
|
||||||
|
author: songInfo.info.username,
|
||||||
|
// play_count: formatPlayCount(info.count),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async getUserListDetailByLink({ info }, link) {
|
||||||
|
let listInfo = info['0']
|
||||||
|
let total = listInfo.count
|
||||||
|
let tasks = []
|
||||||
|
let page = 0
|
||||||
|
while (total) {
|
||||||
|
const limit = total > 90 ? 90 : total
|
||||||
|
total -= limit
|
||||||
|
page += 1
|
||||||
|
tasks.push(createHttpFetch(link.replace(/pagesize=\d+/, 'pagesize=' + limit).replace(/page=\d+/, 'page=' + page), {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
|
||||||
|
Referer: link,
|
||||||
|
},
|
||||||
|
}).then(data => data.list.info))
|
||||||
|
}
|
||||||
|
let result = await Promise.all(tasks).then(([...datas]) => datas.flat())
|
||||||
|
result = await getMusicInfosByList(result)
|
||||||
|
// console.log(result)
|
||||||
|
return {
|
||||||
|
list: result,
|
||||||
|
page,
|
||||||
|
limit: this.listDetailLimit,
|
||||||
|
total: result.length,
|
||||||
|
source: 'kg',
|
||||||
|
info: {
|
||||||
|
name: listInfo.name,
|
||||||
|
img: listInfo.pic && listInfo.pic.replace('{size}', 240),
|
||||||
|
// desc: body.result.info.list_desc,
|
||||||
|
author: listInfo.list_create_username,
|
||||||
|
// play_count: formatPlayCount(listInfo.count),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
createGetListDetail2Task(id, total) {
|
||||||
|
let tasks = []
|
||||||
|
let page = 0
|
||||||
|
while (total) {
|
||||||
|
const limit = total > 300 ? 300 : total
|
||||||
|
total -= limit
|
||||||
|
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=-'
|
||||||
|
tasks.push(createHttpFetch(`https://mobiles.kugou.com/api/v5/special/song_v2?${params}&signature=${signatureParams(params, 5)}`, {
|
||||||
|
headers: {
|
||||||
|
mid: '1586163263991',
|
||||||
|
Referer: 'https://m3ws.kugou.com/share/index.php',
|
||||||
|
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
|
||||||
|
dfid: '-',
|
||||||
|
clienttime: '1586163263991',
|
||||||
|
},
|
||||||
|
}).then(data => data.info))
|
||||||
|
}
|
||||||
|
return Promise.all(tasks).then(([...datas]) => datas.flat())
|
||||||
|
},
|
||||||
|
async getUserListDetail2(global_collection_id) {
|
||||||
|
let id = global_collection_id
|
||||||
|
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=-'
|
||||||
|
let info = await createHttpFetch(`https://mobiles.kugou.com/api/v5/special/info_v2?${params}&signature=${signatureParams(params, 5)}`, {
|
||||||
|
headers: {
|
||||||
|
mid: '1586163242519',
|
||||||
|
Referer: 'https://m3ws.kugou.com/share/index.php',
|
||||||
|
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
|
||||||
|
dfid: '-',
|
||||||
|
clienttime: '1586163242519',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const songInfo = await this.createGetListDetail2Task(id, info.songcount)
|
||||||
|
let list = await getMusicInfosByList(songInfo)
|
||||||
|
// console.log(info, songInfo, list)
|
||||||
|
return {
|
||||||
|
list,
|
||||||
|
page: 1,
|
||||||
|
limit: this.listDetailLimit,
|
||||||
|
total: list.length,
|
||||||
|
source: 'kg',
|
||||||
|
info: {
|
||||||
|
name: info.specialname,
|
||||||
|
img: info.imgurl && info.imgurl.replace('{size}', 240),
|
||||||
|
desc: info.intro,
|
||||||
|
author: info.nickname,
|
||||||
|
play_count: formatPlayCount(info.playcount),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async getListInfoByChain(chain) {
|
||||||
|
if (this.cache.has(chain)) return this.cache.get(chain)
|
||||||
|
const { body } = await httpFetch(`https://m.kugou.com/share/?chain=${chain}&id=${chain}`, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
|
||||||
|
},
|
||||||
|
}).promise
|
||||||
|
// console.log(body)
|
||||||
|
let result = body.match(/var\sphpParam\s=\s({.+?});/)
|
||||||
|
if (result) result = JSON.parse(result[1])
|
||||||
|
this.cache.set(chain, result)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
|
async getUserListDetailByPcChain(chain) {
|
||||||
|
let key = `${chain}_pc_list`
|
||||||
|
if (this.cache.has(key)) return this.cache.get(key)
|
||||||
|
const { body } = await httpFetch(`http://www.kugou.com/share/${chain}.html`, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
|
||||||
|
},
|
||||||
|
}).promise
|
||||||
|
let result = body.match(/var\sdataFromSmarty\s=\s(\[.+?\])/)
|
||||||
|
if (result) result = JSON.parse(result[1])
|
||||||
|
this.cache.set(chain, result)
|
||||||
|
result = await getMusicInfosByList(result)
|
||||||
|
// console.log(info, songInfo)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
|
||||||
|
async getUserListDetail4(songInfo, chain, page) {
|
||||||
|
const limit = 100
|
||||||
|
const [listInfo, list] = await Promise.all([
|
||||||
|
this.getListInfoByChain(chain),
|
||||||
|
this.getUserListDetailBySpecialId(songInfo.id, page, limit),
|
||||||
|
])
|
||||||
|
return {
|
||||||
|
list: list || [],
|
||||||
|
page,
|
||||||
|
limit,
|
||||||
|
total: list.length ?? 0,
|
||||||
|
source: 'kg',
|
||||||
|
info: {
|
||||||
|
name: listInfo.specialname,
|
||||||
|
img: listInfo.imgurl && listInfo.imgurl.replace('{size}', 240),
|
||||||
|
// desc: body.result.info.list_desc,
|
||||||
|
author: listInfo.nickname,
|
||||||
|
// play_count: formatPlayCount(info.count),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async getUserListDetail5(chain) {
|
||||||
|
const [listInfo, list] = await Promise.all([
|
||||||
|
this.getListInfoByChain(chain),
|
||||||
|
this.getUserListDetailByPcChain(chain),
|
||||||
|
])
|
||||||
|
return {
|
||||||
|
list: list || [],
|
||||||
|
page: 1,
|
||||||
|
limit: this.listDetailLimit,
|
||||||
|
total: list.length ?? 0,
|
||||||
|
source: 'kg',
|
||||||
|
info: {
|
||||||
|
name: listInfo.specialname,
|
||||||
|
img: listInfo.imgurl && listInfo.imgurl.replace('{size}', 240),
|
||||||
|
// desc: body.result.info.list_desc,
|
||||||
|
author: listInfo.nickname,
|
||||||
|
// play_count: formatPlayCount(info.count),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async getUserListDetail(link, page, retryNum = 0) {
|
||||||
|
if (retryNum > 3) return Promise.reject(new Error('link try max num'))
|
||||||
|
|
||||||
|
const requestLink = httpFetch(link, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
|
||||||
|
Referer: link,
|
||||||
|
},
|
||||||
|
follow_max: 2,
|
||||||
|
})
|
||||||
|
const { headers: { location }, statusCode, body } = await requestLink.promise
|
||||||
|
// console.log(body, location, statusCode)
|
||||||
|
if (statusCode > 400) return this.getUserListDetail(link, page, ++retryNum)
|
||||||
|
if (typeof body == 'string') {
|
||||||
|
if (body.includes('"global_collection_id":')) return this.getUserListDetailByCollectionId(body.replace(/^[\s\S]+?"global_collection_id":"(\w+)"[\s\S]+?$/, '$1'), page)
|
||||||
|
if (body.includes('"albumid":')) return album.getAlbumDetail(body.replace(/^[\s\S]+?"albumid":(\w+)[\s\S]+?$/, '$1'), page)
|
||||||
|
if (body.includes('"album_id":') && link.includes('album/info')) return album.getAlbumDetail(body.replace(/^[\s\S]+?"album_id":(\w+)[\s\S]+?$/, '$1'), page)
|
||||||
|
if (body.includes('list_id = "') && link.includes('album/info')) return album.getAlbumDetail(body.replace(/^[\s\S]+?list_id = "(\w+)"[\s\S]+?$/, '$1'), page)
|
||||||
|
}
|
||||||
|
if (location) {
|
||||||
|
// 概念版分享链接 https://t1.kugou.com/xxx
|
||||||
|
if (location.includes('global_specialid')) return this.getUserListDetailByCollectionId(location.replace(/^.*?global_specialid=(\w+)(?:&.*$|#.*$|$)/, '$1'), page)
|
||||||
|
if (location.includes('global_collection_id')) return this.getUserListDetailByCollectionId(location.replace(/^.*?global_collection_id=(\w+)(?:&.*$|#.*$|$)/, '$1'), page)
|
||||||
|
if (location.includes('chain=')) return this.getUserListDetail3(location.replace(/^.*?chain=(\w+)(?:&.*$|#.*$|$)/, '$1'), page)
|
||||||
|
if (location.includes('.html')) {
|
||||||
|
if (location.includes('zlist.html')) {
|
||||||
|
let link = location.replace(/^(.*)zlist\.html/, 'https://m3ws.kugou.com/zlist/list')
|
||||||
|
if (link.includes('pagesize')) {
|
||||||
|
link = link.replace('pagesize=30', 'pagesize=' + this.listDetailLimit).replace('page=1', 'page=' + page)
|
||||||
|
} else {
|
||||||
|
link += `&pagesize=${this.listDetailLimit}&page=${page}`
|
||||||
|
}
|
||||||
|
return this.getUserListDetail(link, page, ++retryNum)
|
||||||
|
} else return this.getUserListDetail3(location.replace(/.+\/(\w+).html(?:\?.*|&.*$|#.*$|$)/, '$1'), page)
|
||||||
|
}
|
||||||
|
return this.getUserListDetail(location, page, ++retryNum)
|
||||||
|
}
|
||||||
|
if (body.errcode !== 0) return this.getUserListDetail(link, page, ++retryNum)
|
||||||
|
return this.getUserListDetailByLink(body, link)
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取列表信息
|
||||||
|
getListInfo(tagId, tryNum = 0) {
|
||||||
|
if (this._requestObj_listInfo) this._requestObj_listInfo.cancelHttp()
|
||||||
|
if (tryNum > 2) return Promise.reject(new Error('try max num'))
|
||||||
|
this._requestObj_listInfo = httpFetch(this.getInfoUrl(tagId))
|
||||||
|
return this._requestObj_listInfo.promise.then(({ body }) => {
|
||||||
|
if (body.status !== 1) return this.getListInfo(tagId, ++tryNum)
|
||||||
|
return {
|
||||||
|
limit: body.data.params.pagesize,
|
||||||
|
page: body.data.params.p,
|
||||||
|
total: body.data.params.total,
|
||||||
|
source: 'kg',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取列表数据
|
||||||
|
getList(sortId, tagId, page) {
|
||||||
|
let tasks = [this.getSongList(sortId, tagId, page)]
|
||||||
|
tasks.push(
|
||||||
|
this.currentTagInfo.id === tagId
|
||||||
|
? Promise.resolve(this.currentTagInfo.info)
|
||||||
|
: this.getListInfo(tagId).then(info => {
|
||||||
|
this.currentTagInfo.id = tagId
|
||||||
|
this.currentTagInfo.info = Object.assign({}, info)
|
||||||
|
return info
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
if (!tagId && page === 1 && sortId === this.sortList[0].id) tasks.push(this.getSongListRecommend()) // 如果是所有类别,则顺便获取推荐列表
|
||||||
|
return Promise.all(tasks).then(([list, info, recommendList]) => {
|
||||||
|
if (recommendList) list.unshift(...recommendList)
|
||||||
|
return {
|
||||||
|
list,
|
||||||
|
...info,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
// 获取标签
|
||||||
|
getTags(tryNum = 0) {
|
||||||
|
if (this._requestObj_tags) this._requestObj_tags.cancelHttp()
|
||||||
|
if (tryNum > 2) return Promise.reject(new Error('try max num'))
|
||||||
|
this._requestObj_tags = httpFetch(this.getInfoUrl())
|
||||||
|
return this._requestObj_tags.promise.then(({ body }) => {
|
||||||
|
if (body.status !== 1) return this.getTags(++tryNum)
|
||||||
|
return {
|
||||||
|
hotTag: this.filterInfoHotTag(body.data.hotTag),
|
||||||
|
tags: this.filterTagInfo(body.data.tagids),
|
||||||
|
source: 'kg',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
getDetailPageUrl(id) {
|
||||||
|
if (typeof id == 'string') {
|
||||||
|
if (/^https?:\/\//.test(id)) return id
|
||||||
|
id = id.replace('id_', '')
|
||||||
|
}
|
||||||
|
return `https://www.kugou.com/yy/special/single/${id}.html`
|
||||||
|
},
|
||||||
|
|
||||||
|
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 url = encodeURI(`http://complexsearchretry.kugou.com/v1/search/special?${params}&signature=${signatureParams(params, 1)}`)
|
||||||
|
return createHttpFetch(url).then(body => {
|
||||||
|
// console.log(body)
|
||||||
|
return {
|
||||||
|
list: body.lists.map(item => {
|
||||||
|
return {
|
||||||
|
play_count: formatPlayCount(item.total_play_count),
|
||||||
|
id: item.gid ? `gid_${item.gid}` : `id_${item.specialid}`,
|
||||||
|
author: item.nickname,
|
||||||
|
name: item.specialname,
|
||||||
|
time: dateFormat(item.publish_time, 'Y-M-D'),
|
||||||
|
img: item.img,
|
||||||
|
grade: item.grade,
|
||||||
|
desc: item.intro,
|
||||||
|
total: item.song_count,
|
||||||
|
source: 'kg',
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
limit,
|
||||||
|
total: body.total,
|
||||||
|
source: 'kg',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// http://msearchretry.kugou.com/api/v3/search/special?version=9209&keyword=%E5%91%A8%E6%9D%B0%E4%BC%A6&pagesize=20&filter=0&page=1&sver=2&with_res_tag=0
|
||||||
|
// http://ioscdn.kugou.com/api/v3/search/special?keyword=${encodeURIComponent(text)}&page=${page}&pagesize=${limit}&showtype=10&plat=2&version=7910&correct=1&sver=5
|
||||||
|
// http://msearchretry.kugou.com/api/v3/search/special?keyword=${encodeURIComponent(text)}&page=${page}&pagesize=${limit}&showtype=10&filter=0&version=7910&sver=2
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// getList
|
||||||
|
// getTags
|
||||||
|
// getListDetail
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { createHttpFetch } from './util'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
requestObj: null,
|
||||||
|
cancelTipSearch() {
|
||||||
|
if (this.requestObj && this.requestObj.cancelHttp) this.requestObj.cancelHttp()
|
||||||
|
},
|
||||||
|
tipSearchBySong(str) {
|
||||||
|
this.cancelTipSearch()
|
||||||
|
this.requestObj = createHttpFetch(`https://searchtip.kugou.com/getSearchTip?MusicTipCount=10&keyword=${encodeURIComponent(str)}`, {
|
||||||
|
headers: {
|
||||||
|
referer: 'https://www.kugou.com/',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return this.requestObj.then(body => {
|
||||||
|
return body[0].RecordDatas
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleResult(rawData) {
|
||||||
|
return rawData.map(info => info.HintInfo)
|
||||||
|
},
|
||||||
|
async search(str) {
|
||||||
|
return this.tipSearchBySong(str).then(result => this.handleResult(result))
|
||||||
|
},
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
import { inflate } from 'zlib'
|
import { inflate } from 'zlib'
|
||||||
import { toMD5 } from '../utils'
|
import { toMD5 } from '../utils'
|
||||||
|
import { httpFetch } from '../../request'
|
||||||
|
|
||||||
// https://github.com/lyswhut/lx-music-desktop/issues/296#issuecomment-683285784
|
// https://github.com/lyswhut/lx-music-desktop/issues/296#issuecomment-683285784
|
||||||
const enc_key = Buffer.from([0x40, 0x47, 0x61, 0x77, 0x5e, 0x32, 0x74, 0x47, 0x51, 0x36, 0x31, 0x2d, 0xce, 0xd2, 0x6e, 0x69], 'binary')
|
const enc_key = Buffer.from([0x40, 0x47, 0x61, 0x77, 0x5e, 0x32, 0x74, 0x47, 0x51, 0x36, 0x31, 0x2d, 0xce, 0xd2, 0x6e, 0x69], 'binary')
|
||||||
|
@ -19,6 +20,11 @@ export const decodeLyric = str => new Promise((resolve, reject) => {
|
||||||
// console.log(str)
|
// console.log(str)
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签名
|
||||||
|
* @param {*} params
|
||||||
|
* @param {*} apiver
|
||||||
|
*/
|
||||||
export const signatureParams = (params, apiver = 9) => {
|
export const signatureParams = (params, apiver = 9) => {
|
||||||
let keyparam = 'OIlwieks28dk2k092lksi2UIkp'
|
let keyparam = 'OIlwieks28dk2k092lksi2UIkp'
|
||||||
if (apiver === 5) keyparam = 'NVPh5oo715z5DIWAeQlhMDsWXXQV4hwt'
|
if (apiver === 5) keyparam = 'NVPh5oo715z5DIWAeQlhMDsWXXQV4hwt'
|
||||||
|
@ -27,3 +33,30 @@ export const signatureParams = (params, apiver = 9) => {
|
||||||
let sign_params = `${keyparam}${param_list.join('')}${keyparam}`
|
let sign_params = `${keyparam}${param_list.join('')}${keyparam}`
|
||||||
return toMD5(sign_params)
|
return toMD5(sign_params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个适用于KG的Http请求
|
||||||
|
* @param {*} url
|
||||||
|
* @param {*} options
|
||||||
|
* @param {*} retryNum
|
||||||
|
*/
|
||||||
|
export const createHttpFetch = async(url, options, retryNum = 0) => {
|
||||||
|
if (retryNum > 2) throw new Error('try max num')
|
||||||
|
let result
|
||||||
|
try {
|
||||||
|
result = await httpFetch(url, options).promise
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
return createHttpFetch(url, options, ++retryNum)
|
||||||
|
}
|
||||||
|
// console.log(result.statusCode, result.body)
|
||||||
|
if (result.statusCode !== 200 ||
|
||||||
|
(
|
||||||
|
result.body.error_code ??
|
||||||
|
result.body.errcode ??
|
||||||
|
result.body.err_code) != 0
|
||||||
|
) return createHttpFetch(url, options, ++retryNum)
|
||||||
|
if (result.body.data) return result.body.data
|
||||||
|
if (Array.isArray(result.body.info)) return result.body
|
||||||
|
return result.body.info
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import tempSearch from './tempSearch'
|
import tipSearch from './tipSearch'
|
||||||
import musicSearch from './musicSearch'
|
import musicSearch from './musicSearch'
|
||||||
import { formatSinger, getToken } from './util'
|
import { formatSinger, getToken } from './util'
|
||||||
import leaderboard from './leaderboard'
|
import leaderboard from './leaderboard'
|
||||||
|
@ -32,7 +32,7 @@ const kw = {
|
||||||
// // })
|
// // })
|
||||||
// },
|
// },
|
||||||
|
|
||||||
tempSearch,
|
tipSearch,
|
||||||
musicSearch,
|
musicSearch,
|
||||||
leaderboard,
|
leaderboard,
|
||||||
songList,
|
songList,
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { httpFetch } from '../../request'
|
||||||
import { formatPlayTime, decodeName } from '../../index'
|
import { formatPlayTime, decodeName } from '../../index'
|
||||||
import { formatSinger } from './util'
|
import { formatSinger } 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' }]
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
list: [
|
list: [
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
// import { httpFetch } from '../../request'
|
|
||||||
import { decodeName } from '../../index'
|
import { decodeName } from '../../index'
|
||||||
import { tokenRequest } from './util'
|
import { tokenRequest } from './util'
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
regExps: {
|
regExps: {
|
||||||
relWord: /RELWORD=(.+)/,
|
relWord: /RELWORD=(.+)/,
|
||||||
},
|
},
|
||||||
requestObj: null,
|
requestObj: null,
|
||||||
async tempSearch(str) {
|
async tipSearchBySong(str) {
|
||||||
this.cancelTempSearch()
|
this.cancelTipSearch()
|
||||||
this.requestObj = await tokenRequest(`http://www.kuwo.cn/api/www/search/searchKey?key=${encodeURIComponent(str)}`)
|
this.requestObj = await tokenRequest(`http://www.kuwo.cn/api/www/search/searchKey?key=${encodeURIComponent(str)}`)
|
||||||
return this.requestObj.promise.then(({ body }) => {
|
return this.requestObj.promise.then(({ body }) => {
|
||||||
// console.log(body)
|
// console.log(body)
|
||||||
|
@ -23,10 +21,10 @@ export default {
|
||||||
return matchResult ? decodeName(matchResult[1]) : ''
|
return matchResult ? decodeName(matchResult[1]) : ''
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
cancelTempSearch() {
|
cancelTipSearch() {
|
||||||
if (this.requestObj && this.requestObj.cancelHttp) this.requestObj.cancelHttp()
|
if (this.requestObj && this.requestObj.cancelHttp) this.requestObj.cancelHttp()
|
||||||
},
|
},
|
||||||
async search(str) {
|
async search(str) {
|
||||||
return this.tempSearch(str).then(result => this.handleResult(result.data))
|
return this.tipSearchBySong(str).then(result => this.handleResult(result.data))
|
||||||
},
|
},
|
||||||
}
|
}
|
|
@ -1,18 +1,51 @@
|
||||||
import { httpFetch } from '../../request'
|
import { createHttpFetch } from './utils'
|
||||||
|
import { filterMusicInfoList } from './musicInfo'
|
||||||
|
import { formatPlayCount } from '../../index'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getAlbum(songInfo, tryNum = 0) {
|
/**
|
||||||
let requestObj = httpFetch(`http://app.c.nf.migu.cn/MIGUM2.0/v1.0/content/queryAlbumSong?albumId=${songInfo.albumId}&pageNo=1`)
|
* 通过AlbumId获取专辑
|
||||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
* @param {*} id
|
||||||
if (body.code !== '000000') {
|
* @param {*} page
|
||||||
if (tryNum > 5) return Promise.reject('获取专辑失败')
|
*/
|
||||||
let tryRequestObj = this.getAlbum(songInfo, ++tryNum)
|
async getAlbumDetail(id, page = 1) {
|
||||||
requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
const list = await createHttpFetch(`http://app.c.nf.migu.cn/MIGUM2.0/v1.0/content/queryAlbumSong?albumId=${id}&pageNo=${page}`)
|
||||||
return tryRequestObj.promise
|
if (!list.songList) return Promise.reject(new Error('Get album list error.'))
|
||||||
}
|
|
||||||
// console.log(body)
|
const songList = filterMusicInfoList(list.songList)
|
||||||
return body.songList
|
const listInfo = await this.getAlbumInfo(id)
|
||||||
})
|
|
||||||
return requestObj
|
return {
|
||||||
|
list: songList || [],
|
||||||
|
page,
|
||||||
|
limit: listInfo.total,
|
||||||
|
total: listInfo.total,
|
||||||
|
source: 'mg',
|
||||||
|
info: {
|
||||||
|
name: listInfo.name,
|
||||||
|
img: listInfo.image,
|
||||||
|
desc: listInfo.desc,
|
||||||
|
author: listInfo.author,
|
||||||
|
play_count: listInfo.play_count,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 通过AlbumId获取专辑信息
|
||||||
|
* @param {*} id
|
||||||
|
* @param {*} page
|
||||||
|
*/
|
||||||
|
async getAlbumInfo(id) {
|
||||||
|
const info = await createHttpFetch(`https://app.c.nf.migu.cn/MIGUM3.0/resource/album/v2.0?albumId=${id}`)
|
||||||
|
if (!info) return Promise.reject(new Error('Get album info error.'))
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: info.title,
|
||||||
|
image: info.imgItems.length ? info.imgItems[0].img : null,
|
||||||
|
desc: info.summary,
|
||||||
|
author: info.singer,
|
||||||
|
play_count: formatPlayCount(info.opNumItem.playNum),
|
||||||
|
total: info.totalCount,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,10 @@ import pic from './pic'
|
||||||
import lyric from './lyric'
|
import lyric from './lyric'
|
||||||
import hotSearch from './hotSearch'
|
import hotSearch from './hotSearch'
|
||||||
import comment from './comment'
|
import comment from './comment'
|
||||||
|
// import tipSearch from './tipSearch'
|
||||||
|
|
||||||
const mg = {
|
const mg = {
|
||||||
|
// tipSearch,
|
||||||
songList,
|
songList,
|
||||||
musicSearch,
|
musicSearch,
|
||||||
leaderboard,
|
leaderboard,
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { filterMusicInfoData } from './musicInfo'
|
import { filterMusicInfoList } from './musicInfo'
|
||||||
|
|
||||||
|
|
||||||
// const boardList = [{ id: 'mg__27553319', name: '咪咕尖叫新歌榜', bangid: '27553319' }, { id: 'mg__27186466', name: '咪咕尖叫热歌榜', bangid: '27186466' }, { id: 'mg__27553408', name: '咪咕尖叫原创榜', bangid: '27553408' }, { id: 'mg__23189800', name: '咪咕港台榜', bangid: '23189800' }, { id: 'mg__23189399', name: '咪咕内地榜', bangid: '23189399' }, { id: 'mg__19190036', name: '咪咕欧美榜', bangid: '19190036' }, { id: 'mg__23189813', name: '咪咕日韩榜', bangid: '23189813' }, { id: 'mg__23190126', name: '咪咕彩铃榜', bangid: '23190126' }, { id: 'mg__15140045', name: '咪咕KTV榜', bangid: '15140045' }, { id: 'mg__15140034', name: '咪咕网络榜', bangid: '15140034' }, { id: 'mg__23217754', name: 'MV榜', bangid: '23217754' }, { id: 'mg__23218151', name: '新专辑榜', bangid: '23218151' }, { id: 'mg__21958042', name: 'iTunes榜', bangid: '21958042' }, { id: 'mg__21975570', name: 'billboard榜', bangid: '21975570' }, { id: 'mg__22272815', name: '台湾Hito中文榜', bangid: '22272815' }, { id: 'mg__22272904', name: '中国TOP排行榜', bangid: '22272904' }, { id: 'mg__22272943', name: '韩国Melon榜', bangid: '22272943' }, { id: 'mg__22273437', name: '英国UK榜', bangid: '22273437' }]
|
// const boardList = [{ id: 'mg__27553319', name: '咪咕尖叫新歌榜', bangid: '27553319' }, { id: 'mg__27186466', name: '咪咕尖叫热歌榜', bangid: '27186466' }, { id: 'mg__27553408', name: '咪咕尖叫原创榜', bangid: '27553408' }, { id: 'mg__23189800', name: '咪咕港台榜', bangid: '23189800' }, { id: 'mg__23189399', name: '咪咕内地榜', bangid: '23189399' }, { id: 'mg__19190036', name: '咪咕欧美榜', bangid: '19190036' }, { id: 'mg__23189813', name: '咪咕日韩榜', bangid: '23189813' }, { id: 'mg__23190126', name: '咪咕彩铃榜', bangid: '23190126' }, { id: 'mg__15140045', name: '咪咕KTV榜', bangid: '15140045' }, { id: 'mg__15140034', name: '咪咕网络榜', bangid: '15140034' }, { id: 'mg__23217754', name: 'MV榜', bangid: '23217754' }, { id: 'mg__23218151', name: '新专辑榜', bangid: '23218151' }, { id: 'mg__21958042', name: 'iTunes榜', bangid: '21958042' }, { id: 'mg__21975570', name: 'billboard榜', bangid: '21975570' }, { id: 'mg__22272815', name: '台湾Hito中文榜', bangid: '22272815' }, { id: 'mg__22272904', name: '中国TOP排行榜', bangid: '22272904' }, { id: 'mg__22272943', name: '韩国Melon榜', bangid: '22272943' }, { id: 'mg__22273437', name: '英国UK榜', bangid: '22273437' }]
|
||||||
|
|
||||||
|
@ -144,7 +143,7 @@ export default {
|
||||||
return this.getData(this.getUrl(bangid, page)).then(({ statusCode, body }) => {
|
return this.getData(this.getUrl(bangid, page)).then(({ statusCode, body }) => {
|
||||||
// console.log(body)
|
// console.log(body)
|
||||||
if (statusCode !== 200 || body.code !== this.successCode) return this.getList(bangid, page, retryNum)
|
if (statusCode !== 200 || body.code !== this.successCode) return this.getList(bangid, page, retryNum)
|
||||||
const list = filterMusicInfoData(body.columnInfo.contents.map(m => m.objectInfo))
|
const list = filterMusicInfoList(body.columnInfo.contents.map(m => m.objectInfo))
|
||||||
return {
|
return {
|
||||||
total: list.length,
|
total: list.length,
|
||||||
list,
|
list,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { getMusicInfo } from './musicInfo'
|
import { getMusicInfo } from './musicInfo'
|
||||||
import { decrypt } from './mrc'
|
import { decrypt } from './utils/mrc'
|
||||||
|
|
||||||
const mrcTools = {
|
const mrcTools = {
|
||||||
rxps: {
|
rxps: {
|
||||||
|
|
|
@ -1,15 +1,25 @@
|
||||||
import { httpFetch } from '../../request'
|
|
||||||
import { sizeFormate } from '../../index'
|
import { sizeFormate } from '../../index'
|
||||||
|
import { createHttpFetch } from './utils'
|
||||||
|
import { formatSingerName } from '../utils'
|
||||||
|
|
||||||
const getSinger = (singers) => {
|
const createGetMusicInfosTask = (ids) => {
|
||||||
let arr = []
|
let list = ids
|
||||||
singers?.forEach(singer => {
|
let tasks = []
|
||||||
arr.push(singer.name)
|
while (list.length) {
|
||||||
})
|
tasks.push(list.slice(0, 100))
|
||||||
return arr.join('、')
|
if (list.length < 100) break
|
||||||
|
list = list.slice(100)
|
||||||
|
}
|
||||||
|
let url = 'https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceType=2'
|
||||||
|
return Promise.all(tasks.map(task => createHttpFetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
form: {
|
||||||
|
resourceId: task.join('|'),
|
||||||
|
},
|
||||||
|
}).then(data => data.resource)))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const filterMusicInfoData = (rawList) => {
|
export const filterMusicInfoList = (rawList) => {
|
||||||
// console.log(rawList)
|
// console.log(rawList)
|
||||||
let ids = new Set()
|
let ids = new Set()
|
||||||
const list = []
|
const list = []
|
||||||
|
@ -55,7 +65,7 @@ export const filterMusicInfoData = (rawList) => {
|
||||||
const intervalTest = /(\d\d:\d\d)$/.test(item.length)
|
const intervalTest = /(\d\d:\d\d)$/.test(item.length)
|
||||||
|
|
||||||
list.push({
|
list.push({
|
||||||
singer: getSinger(item.artists),
|
singer: formatSingerName(item.artists, 'name'),
|
||||||
name: item.songName,
|
name: item.songName,
|
||||||
albumName: item.album,
|
albumName: item.album,
|
||||||
albumId: item.albumId,
|
albumId: item.albumId,
|
||||||
|
@ -74,27 +84,13 @@ export const filterMusicInfoData = (rawList) => {
|
||||||
typeUrl: {},
|
typeUrl: {},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
// console.log(list)
|
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getMusicInfos = (copyrightIds, retry = 0) => {
|
export const getMusicInfo = async(copyrightId) => {
|
||||||
if (++retry > 2) return Promise.reject(new Error('Failed to get music info try max'))
|
return getMusicInfos([copyrightId]).then(data => data[0])
|
||||||
return httpFetch('https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceType=2', {
|
|
||||||
method: 'POST',
|
|
||||||
form: {
|
|
||||||
resourceId: copyrightIds.join('|'),
|
|
||||||
},
|
|
||||||
}).promise.then(({ body }) => {
|
|
||||||
if (!body) return getMusicInfos(copyrightIds, retry)
|
|
||||||
if (body.code !== '000000') return Promise.reject(new Error('Failed to get music info'))
|
|
||||||
return filterMusicInfoData(body.resource)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getMusicInfo = (copyrightId) => {
|
export const getMusicInfos = async(copyrightIds) => {
|
||||||
return getMusicInfos([copyrightId]).then(([musicInfo]) => {
|
return filterMusicInfoList(await Promise.all(createGetMusicInfosTask(copyrightIds)).then(data => data.flat()))
|
||||||
if (musicInfo) return musicInfo
|
|
||||||
throw new Error('failed')
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { sizeFormate, formatPlayTime } from '../../index'
|
import { sizeFormate, formatPlayTime } from '../../index'
|
||||||
import { toMD5 } from '../utils'
|
import { toMD5 } from '../utils'
|
||||||
|
import { formatSingerName } from '@renderer/utils/musicSdk/utils'
|
||||||
|
|
||||||
const sign = (time, str) => {
|
const sign = (time, str) => {
|
||||||
const deviceId = '963B7AA0D21511ED807EE5846EC87D20'
|
const deviceId = '963B7AA0D21511ED807EE5846EC87D20'
|
||||||
|
@ -124,13 +125,6 @@ export default {
|
||||||
})
|
})
|
||||||
return searchRequest.promise.then(({ body }) => body)
|
return searchRequest.promise.then(({ body }) => body)
|
||||||
},
|
},
|
||||||
getSinger(singers) {
|
|
||||||
let arr = []
|
|
||||||
singers.forEach(singer => {
|
|
||||||
arr.push(singer.name)
|
|
||||||
})
|
|
||||||
return arr.join('、')
|
|
||||||
},
|
|
||||||
filterData(rawData) {
|
filterData(rawData) {
|
||||||
// console.log(rawData)
|
// console.log(rawData)
|
||||||
const list = []
|
const list = []
|
||||||
|
@ -181,7 +175,7 @@ export default {
|
||||||
if (img && !/https?:/.test(data.img3)) img = 'http://d.musicapp.migu.cn' + img
|
if (img && !/https?:/.test(data.img3)) img = 'http://d.musicapp.migu.cn' + img
|
||||||
|
|
||||||
list.push({
|
list.push({
|
||||||
singer: this.getSinger(data.singerList),
|
singer: formatSingerName(data.singerList),
|
||||||
name: data.name,
|
name: data.name,
|
||||||
albumName: data.album,
|
albumName: data.album,
|
||||||
albumId: data.albumId,
|
albumId: data.albumId,
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../../request'
|
||||||
import { formatPlayTime } from '../../index'
|
import { formatPlayTime } from '../../../index'
|
||||||
// import { sizeFormate } from '../../index'
|
// import { sizeFormate } from '../../index'
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { createHttpFetch } from './utils'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
requestObj: null,
|
||||||
|
cancelTipSearch() {
|
||||||
|
if (this.requestObj && this.requestObj.cancelHttp) this.requestObj.cancelHttp()
|
||||||
|
},
|
||||||
|
tipSearchBySong(str) {
|
||||||
|
this.cancelTipSearch()
|
||||||
|
this.requestObj = createHttpFetch(`https://music.migu.cn/v3/api/search/suggest?keyword=${encodeURIComponent(str)}`, {
|
||||||
|
headers: {
|
||||||
|
referer: 'https://music.migu.cn/v3',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return this.requestObj.then(body => {
|
||||||
|
return body.songs
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleResult(rawData) {
|
||||||
|
return rawData.map(info => `${info.name} - ${info.singerName}`)
|
||||||
|
},
|
||||||
|
async search(str) {
|
||||||
|
return this.tipSearchBySong(str).then(result => this.handleResult(result))
|
||||||
|
},
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
import { httpFetch } from '../../../request'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个适用于MG的Http请求
|
||||||
|
* @param {*} url
|
||||||
|
* @param {*} options
|
||||||
|
* @param {*} retryNum
|
||||||
|
*/
|
||||||
|
export const createHttpFetch = async(url, options, retryNum = 0) => {
|
||||||
|
if (retryNum > 2) throw new Error('try max num')
|
||||||
|
let result
|
||||||
|
try {
|
||||||
|
result = await httpFetch(url, options).promise
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
return createHttpFetch(url, options, ++retryNum)
|
||||||
|
}
|
||||||
|
if (result.statusCode !== 200 ||
|
||||||
|
(
|
||||||
|
(result.body.code !== undefined
|
||||||
|
? result.body.code
|
||||||
|
: result.body.returnCode !== undefined
|
||||||
|
? result.body.returnCode
|
||||||
|
: result.body.code
|
||||||
|
) !== '000000')
|
||||||
|
) return createHttpFetch(url, options, ++retryNum)
|
||||||
|
if (result.body.data) return result.body.data
|
||||||
|
return result.body
|
||||||
|
}
|
|
@ -5,8 +5,10 @@ import musicSearch from './musicSearch'
|
||||||
import { apis } from '../api-source'
|
import { apis } from '../api-source'
|
||||||
import hotSearch from './hotSearch'
|
import hotSearch from './hotSearch'
|
||||||
import comment from './comment'
|
import comment from './comment'
|
||||||
|
// import tipSearch from './tipSearch'
|
||||||
|
|
||||||
const tx = {
|
const tx = {
|
||||||
|
// tipSearch,
|
||||||
leaderboard,
|
leaderboard,
|
||||||
songList,
|
songList,
|
||||||
musicSearch,
|
musicSearch,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { formatPlayTime, sizeFormate } from '../../index'
|
import { formatPlayTime, sizeFormate } from '../../index'
|
||||||
|
import { formatSingerName } from '../utils'
|
||||||
|
|
||||||
let boardList = [{ id: 'tx__4', name: '流行指数榜', bangid: '4' }, { id: 'tx__26', name: '热歌榜', bangid: '26' }, { id: 'tx__27', name: '新歌榜', bangid: '27' }, { id: 'tx__62', name: '飙升榜', bangid: '62' }, { id: 'tx__58', name: '说唱榜', bangid: '58' }, { id: 'tx__57', name: '喜力电音榜', bangid: '57' }, { id: 'tx__28', name: '网络歌曲榜', bangid: '28' }, { id: 'tx__5', name: '内地榜', bangid: '5' }, { id: 'tx__3', name: '欧美榜', bangid: '3' }, { id: 'tx__59', name: '香港地区榜', bangid: '59' }, { id: 'tx__16', name: '韩国榜', bangid: '16' }, { id: 'tx__60', name: '抖快榜', bangid: '60' }, { id: 'tx__29', name: '影视金曲榜', bangid: '29' }, { id: 'tx__17', name: '日本榜', bangid: '17' }, { id: 'tx__52', name: '腾讯音乐人原创榜', bangid: '52' }, { id: 'tx__36', name: 'K歌金曲榜', bangid: '36' }, { id: 'tx__61', name: '台湾地区榜', bangid: '61' }, { id: 'tx__63', name: 'DJ舞曲榜', bangid: '63' }, { id: 'tx__64', name: '综艺新歌榜', bangid: '64' }, { id: 'tx__65', name: '国风热歌榜', bangid: '65' }, { id: 'tx__67', name: '听歌识曲榜', bangid: '67' }, { id: 'tx__72', name: '动漫音乐榜', bangid: '72' }, { id: 'tx__73', name: '游戏音乐榜', bangid: '73' }, { id: 'tx__75', name: '有声榜', bangid: '75' }, { id: 'tx__131', name: '校园音乐人排行榜', bangid: '131' }]
|
let boardList = [{ id: 'tx__4', name: '流行指数榜', bangid: '4' }, { id: 'tx__26', name: '热歌榜', bangid: '26' }, { id: 'tx__27', name: '新歌榜', bangid: '27' }, { id: 'tx__62', name: '飙升榜', bangid: '62' }, { id: 'tx__58', name: '说唱榜', bangid: '58' }, { id: 'tx__57', name: '喜力电音榜', bangid: '57' }, { id: 'tx__28', name: '网络歌曲榜', bangid: '28' }, { id: 'tx__5', name: '内地榜', bangid: '5' }, { id: 'tx__3', name: '欧美榜', bangid: '3' }, { id: 'tx__59', name: '香港地区榜', bangid: '59' }, { id: 'tx__16', name: '韩国榜', bangid: '16' }, { id: 'tx__60', name: '抖快榜', bangid: '60' }, { id: 'tx__29', name: '影视金曲榜', bangid: '29' }, { id: 'tx__17', name: '日本榜', bangid: '17' }, { id: 'tx__52', name: '腾讯音乐人原创榜', bangid: '52' }, { id: 'tx__36', name: 'K歌金曲榜', bangid: '36' }, { id: 'tx__61', name: '台湾地区榜', bangid: '61' }, { id: 'tx__63', name: 'DJ舞曲榜', bangid: '63' }, { id: 'tx__64', name: '综艺新歌榜', bangid: '64' }, { id: 'tx__65', name: '国风热歌榜', bangid: '65' }, { id: 'tx__67', name: '听歌识曲榜', bangid: '67' }, { id: 'tx__72', name: '动漫音乐榜', bangid: '72' }, { id: 'tx__73', name: '游戏音乐榜', bangid: '73' }, { id: 'tx__75', name: '有声榜', bangid: '75' }, { id: 'tx__131', name: '校园音乐人排行榜', bangid: '131' }]
|
||||||
|
|
||||||
|
@ -104,13 +105,6 @@ export default {
|
||||||
const requestDataObj = httpFetch(url)
|
const requestDataObj = httpFetch(url)
|
||||||
return requestDataObj.promise
|
return requestDataObj.promise
|
||||||
},
|
},
|
||||||
getSinger(singers) {
|
|
||||||
let arr = []
|
|
||||||
singers.forEach(singer => {
|
|
||||||
arr.push(singer.name)
|
|
||||||
})
|
|
||||||
return arr.join('、')
|
|
||||||
},
|
|
||||||
filterData(rawList) {
|
filterData(rawList) {
|
||||||
// console.log(rawList)
|
// console.log(rawList)
|
||||||
return rawList.map(item => {
|
return rawList.map(item => {
|
||||||
|
@ -146,7 +140,7 @@ export default {
|
||||||
}
|
}
|
||||||
// types.reverse()
|
// types.reverse()
|
||||||
return {
|
return {
|
||||||
singer: this.getSinger(item.singer),
|
singer: formatSingerName(item.singer, 'name'),
|
||||||
name: item.name,
|
name: item.name,
|
||||||
albumName: item.album.name,
|
albumName: item.album.name,
|
||||||
albumId: item.album.mid,
|
albumId: item.album.mid,
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
// import '../../polyfill/array.find'
|
|
||||||
|
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { formatPlayTime, sizeFormate } from '../../index'
|
import { formatPlayTime, sizeFormate } from '../../index'
|
||||||
// import { debug } from '../../utils/env'
|
import { formatSingerName } from '../utils'
|
||||||
// import { formatSinger } from './util'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
limit: 50,
|
limit: 50,
|
||||||
|
@ -52,13 +49,6 @@ export default {
|
||||||
return body.req.data
|
return body.req.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getSinger(singers) {
|
|
||||||
let arr = []
|
|
||||||
singers.forEach(singer => {
|
|
||||||
arr.push(singer.name)
|
|
||||||
})
|
|
||||||
return arr.join('、')
|
|
||||||
},
|
|
||||||
handleResult(rawList) {
|
handleResult(rawList) {
|
||||||
// console.log(rawList)
|
// console.log(rawList)
|
||||||
const list = []
|
const list = []
|
||||||
|
@ -104,7 +94,7 @@ export default {
|
||||||
albumId = item.album.mid
|
albumId = item.album.mid
|
||||||
}
|
}
|
||||||
list.push({
|
list.push({
|
||||||
singer: this.getSinger(item.singer),
|
singer: formatSingerName(item.singer, 'name'),
|
||||||
name: item.name,
|
name: item.name,
|
||||||
albumName,
|
albumName,
|
||||||
albumId,
|
albumId,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { decodeName, formatPlayTime, sizeFormate, dateFormat } from '../../index'
|
import { decodeName, formatPlayTime, sizeFormate, dateFormat, formatPlayCount } from '../../index'
|
||||||
|
import { formatSingerName } from '../utils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
_requestObj_tags: null,
|
_requestObj_tags: null,
|
||||||
|
@ -125,20 +126,10 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 格式化播放数量
|
|
||||||
* @param {*} num
|
|
||||||
*/
|
|
||||||
formatPlayCount(num) {
|
|
||||||
if (num > 100000000) return parseInt(num / 10000000) / 10 + '亿'
|
|
||||||
if (num > 10000) return parseInt(num / 1000) / 10 + '万'
|
|
||||||
return num
|
|
||||||
},
|
|
||||||
filterList(data, page) {
|
filterList(data, page) {
|
||||||
return {
|
return {
|
||||||
list: data.v_playlist.map(item => ({
|
list: data.v_playlist.map(item => ({
|
||||||
play_count: this.formatPlayCount(item.access_num),
|
play_count: formatPlayCount(item.access_num),
|
||||||
id: item.tid,
|
id: item.tid,
|
||||||
author: item.creator_info.nick,
|
author: item.creator_info.nick,
|
||||||
name: item.title,
|
name: item.title,
|
||||||
|
@ -159,7 +150,7 @@ export default {
|
||||||
// console.log(content.v_item)
|
// console.log(content.v_item)
|
||||||
return {
|
return {
|
||||||
list: content.v_item.map(({ basic }) => ({
|
list: content.v_item.map(({ basic }) => ({
|
||||||
play_count: this.formatPlayCount(basic.play_cnt),
|
play_count: formatPlayCount(basic.play_cnt),
|
||||||
id: basic.tid,
|
id: basic.tid,
|
||||||
author: basic.creator.nick,
|
author: basic.creator.nick,
|
||||||
name: basic.title,
|
name: basic.title,
|
||||||
|
@ -228,17 +219,10 @@ export default {
|
||||||
img: cdlist.logo,
|
img: cdlist.logo,
|
||||||
desc: decodeName(cdlist.desc).replace(/<br>/g, '\n'),
|
desc: decodeName(cdlist.desc).replace(/<br>/g, '\n'),
|
||||||
author: cdlist.nickname,
|
author: cdlist.nickname,
|
||||||
play_count: this.formatPlayCount(cdlist.visitnum),
|
play_count: formatPlayCount(cdlist.visitnum),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getSinger(singers) {
|
|
||||||
let arr = []
|
|
||||||
singers.forEach(singer => {
|
|
||||||
arr.push(singer.name)
|
|
||||||
})
|
|
||||||
return arr.join('、')
|
|
||||||
},
|
|
||||||
filterListDetail(rawList) {
|
filterListDetail(rawList) {
|
||||||
// console.log(rawList)
|
// console.log(rawList)
|
||||||
return rawList.map(item => {
|
return rawList.map(item => {
|
||||||
|
@ -274,7 +258,7 @@ export default {
|
||||||
}
|
}
|
||||||
// types.reverse()
|
// types.reverse()
|
||||||
return {
|
return {
|
||||||
singer: this.getSinger(item.singer),
|
singer: formatSingerName(item.singer, 'name'),
|
||||||
name: item.name,
|
name: item.name,
|
||||||
albumName: item.album.name,
|
albumName: item.album.name,
|
||||||
albumId: item.album.mid,
|
albumId: item.album.mid,
|
||||||
|
@ -319,7 +303,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
list: body.data.list.map(item => {
|
list: body.data.list.map(item => {
|
||||||
return {
|
return {
|
||||||
play_count: this.formatPlayCount(item.listennum),
|
play_count: formatPlayCount(item.listennum),
|
||||||
id: item.dissid,
|
id: item.dissid,
|
||||||
author: item.creator.name,
|
author: item.creator.name,
|
||||||
name: item.dissname,
|
name: item.dissname,
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
regExps: {
|
// regExps: {
|
||||||
relWord: /RELWORD=(.+)/,
|
// relWord: /RELWORD=(.+)/,
|
||||||
},
|
// },
|
||||||
requestObj: null,
|
requestObj: null,
|
||||||
tempSearch(str) {
|
tipSearch(str) {
|
||||||
this.cancelTempSearch()
|
this.cancelTipSearch()
|
||||||
this.requestObj = httpFetch(`https://c.y.qq.com/splcloud/fcgi-bin/smartbox_new.fcg?is_xml=0&format=json&key=${encodeURIComponent(str)}&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq&needNewCode=0`, {
|
this.requestObj = httpFetch(`https://c.y.qq.com/splcloud/fcgi-bin/smartbox_new.fcg?is_xml=0&format=json&key=${encodeURIComponent(str)}&loginUin=0&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq&needNewCode=0`, {
|
||||||
headers: {
|
headers: {
|
||||||
Referer: 'https://y.qq.com/portal/player.html',
|
Referer: 'https://y.qq.com/portal/player.html',
|
||||||
|
@ -21,10 +20,10 @@ export default {
|
||||||
handleResult(rawData) {
|
handleResult(rawData) {
|
||||||
return rawData.map(info => `${info.name} - ${info.singer}`)
|
return rawData.map(info => `${info.name} - ${info.singer}`)
|
||||||
},
|
},
|
||||||
cancelTempSearch() {
|
cancelTipSearch() {
|
||||||
if (this.requestObj && this.requestObj.cancelHttp) this.requestObj.cancelHttp()
|
if (this.requestObj && this.requestObj.cancelHttp) this.requestObj.cancelHttp()
|
||||||
},
|
},
|
||||||
async search(str) {
|
async search(str) {
|
||||||
return this.tempSearch(str).then(result => this.handleResult(result.song.itemlist))
|
return this.tipSearch(str).then(result => this.handleResult(result.song.itemlist))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import crypto from 'crypto'
|
import crypto from 'crypto'
|
||||||
import dns from 'dns'
|
import dns from 'dns'
|
||||||
|
import { decodeName } from '@common/utils/common'
|
||||||
|
|
||||||
export const toMD5 = str => crypto.createHash('md5').update(str).digest('hex')
|
export const toMD5 = str => crypto.createHash('md5').update(str).digest('hex')
|
||||||
|
|
||||||
|
@ -27,3 +28,29 @@ export const dnsLookup = (hostname, options, callback) => {
|
||||||
|
|
||||||
dns.lookup(hostname, options, callback)
|
dns.lookup(hostname, options, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化歌手
|
||||||
|
* @param singers 歌手数组
|
||||||
|
* @param nameKey 歌手名键值
|
||||||
|
* @param join 歌手分割字符
|
||||||
|
*/
|
||||||
|
export const formatSingerName = (singers, nameKey = 'name', join = '、') => {
|
||||||
|
if (typeof singers == 'string') {
|
||||||
|
try {
|
||||||
|
singers = JSON.parse(singers)
|
||||||
|
} catch (err) {
|
||||||
|
return decodeName(singers)
|
||||||
|
}
|
||||||
|
} else if (Array.isArray(singers)) {
|
||||||
|
const singer = []
|
||||||
|
singers.forEach(item => {
|
||||||
|
let name = item[nameKey]
|
||||||
|
if (!name) return
|
||||||
|
singer.push(name)
|
||||||
|
})
|
||||||
|
return decodeName(singer.join(join))
|
||||||
|
}
|
||||||
|
return decodeName(String(singers ?? ''))
|
||||||
|
}
|
||||||
|
|
|
@ -6,8 +6,10 @@ import musicSearch from './musicSearch'
|
||||||
import songList from './songList'
|
import songList from './songList'
|
||||||
import hotSearch from './hotSearch'
|
import hotSearch from './hotSearch'
|
||||||
import comment from './comment'
|
import comment from './comment'
|
||||||
|
// import tipSearch from './tipSearch'
|
||||||
|
|
||||||
const wy = {
|
const wy = {
|
||||||
|
// tipSearch,
|
||||||
leaderboard,
|
leaderboard,
|
||||||
musicSearch,
|
musicSearch,
|
||||||
songList,
|
songList,
|
||||||
|
|
|
@ -6,30 +6,30 @@ const topList = [{ id: 'wy__19723756', name: '飙升榜', bangid: '19723756' },
|
||||||
{ id: 'wy__3779629', name: '新歌榜', bangid: '3779629' },
|
{ id: 'wy__3779629', name: '新歌榜', bangid: '3779629' },
|
||||||
{ id: 'wy__2884035', name: '原创榜', bangid: '2884035' },
|
{ id: 'wy__2884035', name: '原创榜', bangid: '2884035' },
|
||||||
{ id: 'wy__3778678', name: '热歌榜', bangid: '3778678' },
|
{ id: 'wy__3778678', name: '热歌榜', bangid: '3778678' },
|
||||||
{ id: 'wy__991319590', name: '云音乐说唱榜', bangid: '991319590' },
|
{ id: 'wy__991319590', name: '说唱榜', bangid: '991319590' },
|
||||||
{ id: 'wy__71384707', name: '云音乐古典榜', bangid: '71384707' },
|
{ id: 'wy__71384707', name: '古典榜', bangid: '71384707' },
|
||||||
{ id: 'wy__1978921795', name: '云音乐电音榜', bangid: '1978921795' },
|
{ id: 'wy__1978921795', name: '电音榜', bangid: '1978921795' },
|
||||||
{ id: 'wy__5453912201', name: '黑胶VIP爱听榜', bangid: '5453912201' },
|
{ id: 'wy__5453912201', name: '黑胶VIP爱听榜', bangid: '5453912201' },
|
||||||
{ id: 'wy__71385702', name: '云音乐ACG榜', bangid: '71385702' },
|
{ id: 'wy__71385702', name: 'ACG榜', bangid: '71385702' },
|
||||||
{ id: 'wy__745956260', name: '云音乐韩语榜', bangid: '745956260' },
|
{ id: 'wy__745956260', name: '韩语榜', bangid: '745956260' },
|
||||||
{ id: 'wy__10520166', name: '云音乐国电榜', bangid: '10520166' },
|
{ id: 'wy__10520166', name: '国电榜', bangid: '10520166' },
|
||||||
{ id: 'wy__180106', name: 'UK排行榜周榜', bangid: '180106' },
|
{ id: 'wy__180106', name: 'UK排行榜周榜', bangid: '180106' },
|
||||||
{ id: 'wy__60198', name: '美国Billboard榜', bangid: '60198' },
|
{ id: 'wy__60198', name: '美国Billboard榜', bangid: '60198' },
|
||||||
{ id: 'wy__3812895', name: 'Beatport全球电子舞曲榜', bangid: '3812895' },
|
{ id: 'wy__3812895', name: 'Beatport全球电子舞曲榜', bangid: '3812895' },
|
||||||
{ id: 'wy__21845217', name: 'KTV唛榜', bangid: '21845217' },
|
{ id: 'wy__21845217', name: 'KTV唛榜', bangid: '21845217' },
|
||||||
{ id: 'wy__60131', name: '日本Oricon榜', bangid: '60131' },
|
{ id: 'wy__60131', name: '日本Oricon榜', bangid: '60131' },
|
||||||
{ id: 'wy__2809513713', name: '云音乐欧美热歌榜', bangid: '2809513713' },
|
{ id: 'wy__2809513713', name: '欧美热歌榜', bangid: '2809513713' },
|
||||||
{ id: 'wy__2809577409', name: '云音乐欧美新歌榜', bangid: '2809577409' },
|
{ id: 'wy__2809577409', name: '欧美新歌榜', bangid: '2809577409' },
|
||||||
{ id: 'wy__27135204', name: '法国 NRJ Vos Hits 周榜', bangid: '27135204' },
|
{ id: 'wy__27135204', name: '法国 NRJ Vos Hits 周榜', bangid: '27135204' },
|
||||||
{ id: 'wy__3001835560', name: '云音乐ACG动画榜', bangid: '3001835560' },
|
{ id: 'wy__3001835560', name: 'ACG动画榜', bangid: '3001835560' },
|
||||||
{ id: 'wy__3001795926', name: '云音乐ACG游戏榜', bangid: '3001795926' },
|
{ id: 'wy__3001795926', name: 'ACG游戏榜', bangid: '3001795926' },
|
||||||
{ id: 'wy__3001890046', name: '云音乐ACG VOCALOID榜', bangid: '3001890046' },
|
{ id: 'wy__3001890046', name: 'ACG VOCALOID榜', bangid: '3001890046' },
|
||||||
{ id: 'wy__3112516681', name: '中国新乡村音乐排行榜', bangid: '3112516681' },
|
{ id: 'wy__3112516681', name: '中国新乡村音乐排行榜', bangid: '3112516681' },
|
||||||
{ id: 'wy__5059644681', name: '云音乐日语榜', bangid: '5059644681' },
|
{ id: 'wy__5059644681', name: '日语榜', bangid: '5059644681' },
|
||||||
{ id: 'wy__5059633707', name: '云音乐摇滚榜', bangid: '5059633707' },
|
{ id: 'wy__5059633707', name: '摇滚榜', bangid: '5059633707' },
|
||||||
{ id: 'wy__5059642708', name: '云音乐国风榜', bangid: '5059642708' },
|
{ id: 'wy__5059642708', name: '国风榜', bangid: '5059642708' },
|
||||||
{ id: 'wy__5338990334', name: '潜力爆款榜', bangid: '5338990334' },
|
{ id: 'wy__5338990334', name: '潜力爆款榜', bangid: '5338990334' },
|
||||||
{ id: 'wy__5059661515', name: '云音乐民谣榜', bangid: '5059661515' },
|
{ id: 'wy__5059661515', name: '民谣榜', bangid: '5059661515' },
|
||||||
{ id: 'wy__6688069460', name: '听歌识曲榜', bangid: '6688069460' },
|
{ id: 'wy__6688069460', name: '听歌识曲榜', bangid: '6688069460' },
|
||||||
{ id: 'wy__6723173524', name: '网络热歌榜', bangid: '6723173524' },
|
{ id: 'wy__6723173524', name: '网络热歌榜', bangid: '6723173524' },
|
||||||
{ id: 'wy__6732051320', name: '俄语榜', bangid: '6732051320' },
|
{ id: 'wy__6732051320', name: '俄语榜', bangid: '6732051320' },
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
|
|
||||||
import { weapi, linuxapi } from './utils/crypto'
|
import { weapi, linuxapi } from './utils/crypto'
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { formatPlayTime, sizeFormate, dateFormat } from '../../index'
|
import { formatPlayTime, sizeFormate, dateFormat, formatPlayCount } from '../../index'
|
||||||
import musicDetailApi from './musicDetail'
|
import musicDetailApi from './musicDetail'
|
||||||
import { eapiRequest } from './utils/index'
|
import { eapiRequest } from './utils/index'
|
||||||
|
import { formatSingerName } from '../utils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
_requestObj_tags: null,
|
_requestObj_tags: null,
|
||||||
|
@ -31,22 +32,6 @@ export default {
|
||||||
listDetailLink: /^.+(?:\?|&)id=(\d+)(?:&.*$|#.*$|$)/,
|
listDetailLink: /^.+(?:\?|&)id=(\d+)(?:&.*$|#.*$|$)/,
|
||||||
listDetailLink2: /^.+\/playlist\/(\d+)\/\d+\/.+$/,
|
listDetailLink2: /^.+\/playlist\/(\d+)\/\d+\/.+$/,
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* 格式化播放数量
|
|
||||||
* @param {*} num
|
|
||||||
*/
|
|
||||||
formatPlayCount(num) {
|
|
||||||
if (num > 100000000) return parseInt(num / 10000000) / 10 + '亿'
|
|
||||||
if (num > 10000) return parseInt(num / 1000) / 10 + '万'
|
|
||||||
return num
|
|
||||||
},
|
|
||||||
getSinger(singers) {
|
|
||||||
let arr = []
|
|
||||||
singers?.forEach(singer => {
|
|
||||||
arr.push(singer.name)
|
|
||||||
})
|
|
||||||
return arr.join('、')
|
|
||||||
},
|
|
||||||
|
|
||||||
async handleParseId(link, retryNum = 0) {
|
async handleParseId(link, retryNum = 0) {
|
||||||
if (retryNum > 2) throw new Error('link try max num')
|
if (retryNum > 2) throw new Error('link try max num')
|
||||||
|
@ -130,7 +115,7 @@ export default {
|
||||||
total: body.playlist.trackIds.length,
|
total: body.playlist.trackIds.length,
|
||||||
source: 'wy',
|
source: 'wy',
|
||||||
info: {
|
info: {
|
||||||
play_count: this.formatPlayCount(body.playlist.playCount),
|
play_count: formatPlayCount(body.playlist.playCount),
|
||||||
name: body.playlist.name,
|
name: body.playlist.name,
|
||||||
img: body.playlist.coverImgUrl,
|
img: body.playlist.coverImgUrl,
|
||||||
desc: body.playlist.description,
|
desc: body.playlist.description,
|
||||||
|
@ -198,7 +183,7 @@ export default {
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
list.push({
|
list.push({
|
||||||
singer: this.getSinger(item.ar),
|
singer: formatSingerName(item.ar, 'name'),
|
||||||
name: item.name ?? '',
|
name: item.name ?? '',
|
||||||
albumName: item.al?.name,
|
albumName: item.al?.name,
|
||||||
albumId: item.al?.id,
|
albumId: item.al?.id,
|
||||||
|
@ -232,7 +217,7 @@ export default {
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
return this._requestObj_list.promise.then(({ body }) => {
|
return this._requestObj_list.promise.then(({ body }) => {
|
||||||
console.log(body)
|
// console.log(body)
|
||||||
if (body.code !== this.successCode) return this.getList(sortId, tagId, page, ++tryNum)
|
if (body.code !== this.successCode) return this.getList(sortId, tagId, page, ++tryNum)
|
||||||
return {
|
return {
|
||||||
list: this.filterList(body.playlists),
|
list: this.filterList(body.playlists),
|
||||||
|
@ -246,7 +231,7 @@ export default {
|
||||||
filterList(rawData) {
|
filterList(rawData) {
|
||||||
// console.log(rawData)
|
// console.log(rawData)
|
||||||
return rawData.map(item => ({
|
return rawData.map(item => ({
|
||||||
play_count: this.formatPlayCount(item.playCount),
|
play_count: formatPlayCount(item.playCount),
|
||||||
id: item.id,
|
id: item.id,
|
||||||
author: item.creator.nickname,
|
author: item.creator.nickname,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
import { httpFetch } from '../../request'
|
||||||
|
import { weapi } from './utils/crypto'
|
||||||
|
import { formatSingerName } from '../utils'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
requestObj: null,
|
||||||
|
cancelTipSearch() {
|
||||||
|
if (this.requestObj && this.requestObj.cancelHttp) this.requestObj.cancelHttp()
|
||||||
|
},
|
||||||
|
tipSearchBySong(str) {
|
||||||
|
this.cancelTipSearch()
|
||||||
|
this.requestObj = httpFetch('https://music.163.com/weapi/search/suggest/web', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
referer: 'https://music.163.com/',
|
||||||
|
origin: 'https://music.163.com/',
|
||||||
|
},
|
||||||
|
form: weapi({
|
||||||
|
s: str,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
return this.requestObj.promise.then(({ statusCode, body }) => {
|
||||||
|
if (statusCode != 200 || body.code != 200) return Promise.reject(new Error('请求失败'))
|
||||||
|
return body.result.songs
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleResult(rawData) {
|
||||||
|
return rawData.map(info => `${info.name} - ${formatSingerName(info.artists, 'name')}`)
|
||||||
|
},
|
||||||
|
async search(str) {
|
||||||
|
return this.tipSearchBySong(str).then(result => this.handleResult(result))
|
||||||
|
},
|
||||||
|
}
|
Loading…
Reference in New Issue