更新
This commit is contained in:
parent
9b90a2d325
commit
afc3cb6bb0
@ -23,7 +23,7 @@ export default {
|
|||||||
count: {
|
count: {
|
||||||
music: body.songcount,
|
music: body.songcount,
|
||||||
album: body.albumcount,
|
album: body.albumcount,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -83,4 +83,3 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { getMusicInfo } from './musicInfo'
|
import getMusicInfo from './musicInfo'
|
||||||
import { rendererInvoke } from '@common/rendererIpc'
|
import { rendererInvoke } from '@common/rendererIpc'
|
||||||
import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames'
|
import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames'
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,20 @@
|
|||||||
import { filterMusicInfoItem } from './util'
|
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
|
import { formatPlayTime, sizeFormate } from '../../index'
|
||||||
|
|
||||||
export const getMusicInfo = id => {
|
const getSinger = (singers) => {
|
||||||
return httpFetch('https://u.y.qq.com/cgi-bin/musicu.fcg', {
|
let arr = []
|
||||||
method: 'POST',
|
singers.forEach(singer => {
|
||||||
|
arr.push(singer.name)
|
||||||
|
})
|
||||||
|
return arr.join('、')
|
||||||
|
}
|
||||||
|
|
||||||
|
export default (songmid) => {
|
||||||
|
const requestObj = httpFetch('https://u.y.qq.com/cgi-bin/musicu.fcg', {
|
||||||
|
method: 'post',
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
|
||||||
|
},
|
||||||
body: {
|
body: {
|
||||||
comm: {
|
comm: {
|
||||||
ct: '19',
|
ct: '19',
|
||||||
@ -15,19 +26,73 @@ export const getMusicInfo = id => {
|
|||||||
method: 'get_song_detail_yqq',
|
method: 'get_song_detail_yqq',
|
||||||
param: {
|
param: {
|
||||||
song_type: 0,
|
song_type: 0,
|
||||||
song_mid: id,
|
song_mid: songmid,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
headers: {
|
})
|
||||||
'User-Angent': 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
|
return requestObj.promise.then(({ body }) => {
|
||||||
},
|
// console.log(body)
|
||||||
}).then(({ body }) => {
|
if (body.code != 0 || body.req.code != 0) return Promise.reject('获取歌曲信息失败')
|
||||||
if (body.req.code != 0) throw new Error('get music info faild.')
|
|
||||||
|
|
||||||
const item = body.req.data.track_info
|
const item = body.req.data.track_info
|
||||||
if (!item.file?.media_mid) return null
|
if (!item.file?.media_mid) return null
|
||||||
|
|
||||||
return filterMusicInfoItem(item)
|
let types = []
|
||||||
|
let _types = {}
|
||||||
|
const file = item.file
|
||||||
|
if (file.size_128mp3 != 0) {
|
||||||
|
let size = sizeFormate(file.size_128mp3)
|
||||||
|
types.push({ type: '128k', size })
|
||||||
|
_types['128k'] = {
|
||||||
|
size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file.size_320mp3 !== 0) {
|
||||||
|
let size = sizeFormate(file.size_320mp3)
|
||||||
|
types.push({ type: '320k', size })
|
||||||
|
_types['320k'] = {
|
||||||
|
size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file.size_flac !== 0) {
|
||||||
|
let size = sizeFormate(file.size_flac)
|
||||||
|
types.push({ type: 'flac', size })
|
||||||
|
_types.flac = {
|
||||||
|
size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file.size_hires !== 0) {
|
||||||
|
let size = sizeFormate(file.size_hires)
|
||||||
|
types.push({ type: 'flac24bit', size })
|
||||||
|
_types.flac24bit = {
|
||||||
|
size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// types.reverse()
|
||||||
|
let albumId = ''
|
||||||
|
let albumName = ''
|
||||||
|
if (item.album) {
|
||||||
|
albumName = item.album.name
|
||||||
|
albumId = item.album.mid
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
singer: getSinger(item.singer),
|
||||||
|
name: item.name,
|
||||||
|
albumName,
|
||||||
|
albumId,
|
||||||
|
source: 'tx',
|
||||||
|
interval: formatPlayTime(item.interval),
|
||||||
|
songId: item.id,
|
||||||
|
albumMid: item.album?.mid ?? '',
|
||||||
|
strMediaMid: item.file.media_mid,
|
||||||
|
songmid: item.mid,
|
||||||
|
img: (albumId === '' || albumId === '空')
|
||||||
|
? item.singer?.length ? `https://y.gtimg.cn/music/photo_new/T001R500x500M000${item.singer[0].mid}.jpg` : ''
|
||||||
|
: `https://y.gtimg.cn/music/photo_new/T002R500x500M000${albumId}.jpg`,
|
||||||
|
types,
|
||||||
|
_types,
|
||||||
|
typeUrl: {},
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
import { filterMusicInfoItem } from './util'
|
import { formatPlayTime, sizeFormate } from '../../index'
|
||||||
|
import { formatSingerName } from '../utils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
limit: 50,
|
limit: 50,
|
||||||
@ -49,11 +50,69 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleResult(rawList) {
|
handleResult(rawList) {
|
||||||
|
// console.log(rawList)
|
||||||
const list = []
|
const list = []
|
||||||
rawList.forEach(item => {
|
rawList.forEach(item => {
|
||||||
if (!item.file?.media_mid) return
|
if (!item.file?.media_mid) return
|
||||||
list.push(filterMusicInfoItem(item))
|
|
||||||
|
let types = []
|
||||||
|
let _types = {}
|
||||||
|
const file = item.file
|
||||||
|
if (file.size_128mp3 != 0) {
|
||||||
|
let size = sizeFormate(file.size_128mp3)
|
||||||
|
types.push({ type: '128k', size })
|
||||||
|
_types['128k'] = {
|
||||||
|
size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file.size_320mp3 !== 0) {
|
||||||
|
let size = sizeFormate(file.size_320mp3)
|
||||||
|
types.push({ type: '320k', size })
|
||||||
|
_types['320k'] = {
|
||||||
|
size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file.size_flac !== 0) {
|
||||||
|
let size = sizeFormate(file.size_flac)
|
||||||
|
types.push({ type: 'flac', size })
|
||||||
|
_types.flac = {
|
||||||
|
size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file.size_hires !== 0) {
|
||||||
|
let size = sizeFormate(file.size_hires)
|
||||||
|
types.push({ type: 'flac24bit', size })
|
||||||
|
_types.flac24bit = {
|
||||||
|
size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// types.reverse()
|
||||||
|
let albumId = ''
|
||||||
|
let albumName = ''
|
||||||
|
if (item.album) {
|
||||||
|
albumName = item.album.name
|
||||||
|
albumId = item.album.mid
|
||||||
|
}
|
||||||
|
list.push({
|
||||||
|
singer: formatSingerName(item.singer, 'name'),
|
||||||
|
name: item.name,
|
||||||
|
albumName,
|
||||||
|
albumId,
|
||||||
|
source: 'tx',
|
||||||
|
interval: formatPlayTime(item.interval),
|
||||||
|
songId: item.id,
|
||||||
|
albumMid: item.album?.mid ?? '',
|
||||||
|
strMediaMid: item.file.media_mid,
|
||||||
|
songmid: item.mid,
|
||||||
|
img: (albumId === '' || albumId === '空')
|
||||||
|
? item.singer?.length ? `https://y.gtimg.cn/music/photo_new/T001R500x500M000${item.singer[0].mid}.jpg` : ''
|
||||||
|
: `https://y.gtimg.cn/music/photo_new/T002R500x500M000${albumId}.jpg`,
|
||||||
|
types,
|
||||||
|
_types,
|
||||||
|
typeUrl: {},
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
// console.log(list)
|
||||||
return list
|
return list
|
||||||
},
|
},
|
||||||
search(str, page = 1, limit) {
|
search(str, page = 1, limit) {
|
||||||
|
|||||||
@ -1,6 +1,64 @@
|
|||||||
import { createMusicuFetch, filterMusicInfoItem } from './util'
|
|
||||||
import { httpFetch } from '../../request'
|
import { httpFetch } from '../../request'
|
||||||
|
|
||||||
|
import { formatPlayTime, sizeFormate } from '../../index'
|
||||||
|
import { formatSingerName } from '../utils'
|
||||||
|
|
||||||
|
export const filterMusicInfoItem = item => {
|
||||||
|
const types = []
|
||||||
|
const _types = {}
|
||||||
|
if (item.file.size_128mp3 != 0) {
|
||||||
|
let size = sizeFormate(item.file.size_128mp3)
|
||||||
|
types.push({ type: '128k', size })
|
||||||
|
_types['128k'] = {
|
||||||
|
size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.file.size_320mp3 !== 0) {
|
||||||
|
let size = sizeFormate(item.file.size_320mp3)
|
||||||
|
types.push({ type: '320k', size })
|
||||||
|
_types['320k'] = {
|
||||||
|
size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.file.size_flac !== 0) {
|
||||||
|
let size = sizeFormate(item.file.size_flac)
|
||||||
|
types.push({ type: 'flac', size })
|
||||||
|
_types.flac = {
|
||||||
|
size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.file.size_hires !== 0) {
|
||||||
|
let size = sizeFormate(item.file.size_hires)
|
||||||
|
types.push({ type: 'flac24bit', size })
|
||||||
|
_types.flac24bit = {
|
||||||
|
size,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const albumId = item.album.id ?? ''
|
||||||
|
const albumMid = item.album.mid ?? ''
|
||||||
|
const albumName = item.album.name ?? ''
|
||||||
|
return {
|
||||||
|
source: 'tx',
|
||||||
|
singer: formatSingerName(item.singer, 'name'),
|
||||||
|
name: item.name,
|
||||||
|
albumName,
|
||||||
|
albumId,
|
||||||
|
albumMid,
|
||||||
|
interval: formatPlayTime(item.interval),
|
||||||
|
songId: item.id,
|
||||||
|
songmid: item.mid,
|
||||||
|
strMediaMid: item.file.media_mid,
|
||||||
|
img: (albumId === '' || albumId === '空')
|
||||||
|
? item.singer?.length ? `https://y.gtimg.cn/music/photo_new/T001R500x500M000${item.singer[0].mid}.jpg` : ''
|
||||||
|
: `https://y.gtimg.cn/music/photo_new/T002R500x500M000${albumMid}.jpg`,
|
||||||
|
types,
|
||||||
|
_types,
|
||||||
|
typeUrl: {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一个适用于TX的Http请求
|
* 创建一个适用于TX的Http请求
|
||||||
* @param {*} url
|
* @param {*} url
|
||||||
@ -186,6 +244,6 @@ export default {
|
|||||||
raw.map(item => {
|
raw.map(item => {
|
||||||
return filterMusicInfoItem(item.songInfo)
|
return filterMusicInfoItem(item.songInfo)
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,57 +0,0 @@
|
|||||||
import { formatPlayTime, sizeFormate } from '../../index'
|
|
||||||
import { formatSingerName } from '../utils'
|
|
||||||
|
|
||||||
export const filterMusicInfoItem = item => {
|
|
||||||
const types = []
|
|
||||||
const _types = {}
|
|
||||||
if (item.file.size_128mp3 != 0) {
|
|
||||||
let size = sizeFormate(item.file.size_128mp3)
|
|
||||||
types.push({ type: '128k', size })
|
|
||||||
_types['128k'] = {
|
|
||||||
size,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (item.file.size_320mp3 !== 0) {
|
|
||||||
let size = sizeFormate(item.file.size_320mp3)
|
|
||||||
types.push({ type: '320k', size })
|
|
||||||
_types['320k'] = {
|
|
||||||
size,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (item.file.size_flac !== 0) {
|
|
||||||
let size = sizeFormate(item.file.size_flac)
|
|
||||||
types.push({ type: 'flac', size })
|
|
||||||
_types.flac = {
|
|
||||||
size,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (item.file.size_hires !== 0) {
|
|
||||||
let size = sizeFormate(item.file.size_hires)
|
|
||||||
types.push({ type: 'flac24bit', size })
|
|
||||||
_types.flac24bit = {
|
|
||||||
size,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const albumId = item.album.id ?? ''
|
|
||||||
const albumMid = item.album.mid ?? ''
|
|
||||||
const albumName = item.album.name ?? ''
|
|
||||||
return {
|
|
||||||
source: 'tx',
|
|
||||||
singer: formatSingerName(item.singer, 'name'),
|
|
||||||
name: item.name,
|
|
||||||
albumName,
|
|
||||||
albumId,
|
|
||||||
albumMid,
|
|
||||||
interval: formatPlayTime(item.interval),
|
|
||||||
songId: item.id,
|
|
||||||
songmid: item.mid,
|
|
||||||
strMediaMid: item.file.media_mid,
|
|
||||||
img: (albumId === '' || albumId === '空')
|
|
||||||
? item.singer?.length ? `https://y.gtimg.cn/music/photo_new/T001R500x500M000${item.singer[0].mid}.jpg` : ''
|
|
||||||
: `https://y.gtimg.cn/music/photo_new/T002R500x500M000${albumMid}.jpg`,
|
|
||||||
types,
|
|
||||||
_types,
|
|
||||||
typeUrl: {},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -99,6 +99,7 @@ export default {
|
|||||||
|
|
||||||
const types = []
|
const types = []
|
||||||
const _types = {}
|
const _types = {}
|
||||||
|
let size
|
||||||
item.privilege.chargeInfoList.forEach(i => {
|
item.privilege.chargeInfoList.forEach(i => {
|
||||||
switch (i.rate) {
|
switch (i.rate) {
|
||||||
case 128000:
|
case 128000:
|
||||||
@ -116,7 +117,7 @@ export default {
|
|||||||
case 999000:
|
case 999000:
|
||||||
size = item.sqMusic ? sizeFormate(item.sqMusic.size) : null
|
size = item.sqMusic ? sizeFormate(item.sqMusic.size) : null
|
||||||
types.push({ type: 'flac', size })
|
types.push({ type: 'flac', size })
|
||||||
_typesflac = {
|
_types.flac = {
|
||||||
size,
|
size,
|
||||||
}
|
}
|
||||||
case 1999000:
|
case 1999000:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user