分离可用音质控制逻辑
This commit is contained in:
@@ -428,3 +428,6 @@ export const setWindowSize = (width, height) => rendererSend('setWindowSize', {
|
||||
export const getProxyInfo = () => window.globalObj.proxy.enable
|
||||
? `http://${window.globalObj.proxy.username}:${window.globalObj.proxy.password}@${window.globalObj.proxy.host}:${window.globalObj.proxy.port};`
|
||||
: undefined
|
||||
|
||||
|
||||
export const assertApiSupport = source => window.globalObj.qualityList[source] != undefined
|
||||
|
||||
@@ -12,7 +12,7 @@ import xm_api_test from './xm/api-test'
|
||||
// import wy_api_internal from './wy/api-internal'
|
||||
// import bd_api_internal from './bd/api-internal'
|
||||
|
||||
const apis = {
|
||||
const apiList = {
|
||||
kw_api_test,
|
||||
tx_api_test,
|
||||
kg_api_test,
|
||||
@@ -32,15 +32,15 @@ const apis = {
|
||||
const getAPI = source => {
|
||||
switch (window.globalObj.apiSource) {
|
||||
// case 'messoer':
|
||||
// return apis[`${source}_api_messoer`]
|
||||
// return apiList[`${source}_api_messoer`]
|
||||
case 'test':
|
||||
return apis[`${source}_api_test`]
|
||||
return apiList[`${source}_api_test`]
|
||||
case 'temp':
|
||||
return apis[`${source}_api_temp`]
|
||||
return apiList[`${source}_api_temp`]
|
||||
}
|
||||
}
|
||||
|
||||
export default source => {
|
||||
export const apis = source => {
|
||||
switch (source) {
|
||||
case 'tx':
|
||||
return getAPI('tx')
|
||||
@@ -58,3 +58,18 @@ export default source => {
|
||||
return getAPI('kw')
|
||||
}
|
||||
}
|
||||
|
||||
export const supportQuality = {
|
||||
temp: {
|
||||
kw: ['128k'],
|
||||
},
|
||||
test: {
|
||||
kw: ['128k'],
|
||||
kg: ['128k'],
|
||||
tx: ['128k'],
|
||||
wy: ['128k'],
|
||||
mg: ['128k'],
|
||||
xm: ['128k'],
|
||||
bd: ['128k'],
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import leaderboard from './leaderboard'
|
||||
import api_source from '../api-source'
|
||||
import { apis } from '../api-source'
|
||||
import musicInfo from './musicInfo'
|
||||
import songList from './songList'
|
||||
import { httpFetch } from '../../request'
|
||||
@@ -12,7 +12,7 @@ const bd = {
|
||||
musicSearch,
|
||||
hotSearch,
|
||||
getMusicUrl(songInfo, type) {
|
||||
return api_source('bd').getMusicUrl(songInfo, type)
|
||||
return apis('bd').getMusicUrl(songInfo, type)
|
||||
},
|
||||
getPic(songInfo) {
|
||||
const requestObj = this.getMusicInfo(songInfo)
|
||||
@@ -25,10 +25,10 @@ const bd = {
|
||||
return requestObj
|
||||
},
|
||||
// getLyric(songInfo) {
|
||||
// return api_source('bd').getLyric(songInfo)
|
||||
// return apis('bd').getLyric(songInfo)
|
||||
// },
|
||||
// getPic(songInfo) {
|
||||
// return api_source('bd').getPic(songInfo)
|
||||
// return apis('bd').getPic(songInfo)
|
||||
// },
|
||||
getMusicInfo(songInfo) {
|
||||
return musicInfo.getMusicInfo(songInfo.songmid)
|
||||
|
||||
@@ -5,6 +5,9 @@ import wy from './wy'
|
||||
import mg from './mg'
|
||||
import bd from './bd'
|
||||
import xm from './xm'
|
||||
import { supportQuality } from './api-source'
|
||||
|
||||
|
||||
const sources = {
|
||||
sources: [
|
||||
{
|
||||
@@ -52,4 +55,5 @@ export default {
|
||||
sm && sm.init && sm.init()
|
||||
}
|
||||
},
|
||||
supportQuality,
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import leaderboard from './leaderboard'
|
||||
import api_source from '../api-source'
|
||||
import { apis } from '../api-source'
|
||||
import songList from './songList'
|
||||
import musicSearch from './musicSearch'
|
||||
import pic from './pic'
|
||||
@@ -12,19 +12,19 @@ const kg = {
|
||||
musicSearch,
|
||||
hotSearch,
|
||||
getMusicUrl(songInfo, type) {
|
||||
return api_source('kg').getMusicUrl(songInfo, type)
|
||||
return apis('kg').getMusicUrl(songInfo, type)
|
||||
},
|
||||
getLyric(songInfo) {
|
||||
return lyric.getLyric(songInfo)
|
||||
},
|
||||
// getLyric(songInfo) {
|
||||
// return api_source('kg').getLyric(songInfo)
|
||||
// return apis('kg').getLyric(songInfo)
|
||||
// },
|
||||
getPic(songInfo) {
|
||||
return pic.getPic(songInfo)
|
||||
},
|
||||
// getPic(songInfo) {
|
||||
// return api_source('kg').getPic(songInfo)
|
||||
// return apis('kg').getPic(songInfo)
|
||||
// },
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { formatSinger, getToken } from './util'
|
||||
import leaderboard from './leaderboard'
|
||||
import lyric from './lyric'
|
||||
import pic from './pic'
|
||||
import api_source from '../api-source'
|
||||
import { apis } from '../api-source'
|
||||
import songList from './songList'
|
||||
import hotSearch from './hotSearch'
|
||||
|
||||
@@ -58,7 +58,7 @@ const kw = {
|
||||
},
|
||||
|
||||
getMusicUrl(songInfo, type) {
|
||||
return api_source('kw').getMusicUrl(songInfo, type)
|
||||
return apis('kw').getMusicUrl(songInfo, type)
|
||||
},
|
||||
|
||||
getMusicInfo(songInfo) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import api_source from '../api-source'
|
||||
import { apis } from '../api-source'
|
||||
import leaderboard from './leaderboard'
|
||||
import songList from './songList'
|
||||
import musicSearch from './musicSearch'
|
||||
@@ -12,7 +12,7 @@ const mg = {
|
||||
leaderboard,
|
||||
hotSearch,
|
||||
getMusicUrl(songInfo, type) {
|
||||
return api_source('mg').getMusicUrl(songInfo, type)
|
||||
return apis('mg').getMusicUrl(songInfo, type)
|
||||
},
|
||||
getLyric(songInfo) {
|
||||
return lyric.getLyric(songInfo)
|
||||
|
||||
@@ -2,7 +2,7 @@ import leaderboard from './leaderboard'
|
||||
import lyric from './lyric'
|
||||
import songList from './songList'
|
||||
import musicSearch from './musicSearch'
|
||||
import api_source from '../api-source'
|
||||
import { apis } from '../api-source'
|
||||
import hotSearch from './hotSearch'
|
||||
|
||||
const tx = {
|
||||
@@ -12,14 +12,14 @@ const tx = {
|
||||
hotSearch,
|
||||
|
||||
getMusicUrl(songInfo, type) {
|
||||
return api_source('tx').getMusicUrl(songInfo, type)
|
||||
return apis('tx').getMusicUrl(songInfo, type)
|
||||
},
|
||||
getLyric(songInfo) {
|
||||
// let singer = songInfo.singer.indexOf('、') > -1 ? songInfo.singer.split('、')[0] : songInfo.singer
|
||||
return lyric.getLyric(songInfo.songmid)
|
||||
},
|
||||
getPic(songInfo) {
|
||||
return api_source('tx').getPic(songInfo)
|
||||
return apis('tx').getPic(songInfo)
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -8,14 +8,9 @@ import crypto from 'crypto'
|
||||
|
||||
const types = ['flac', 'wav', 'ape', '320k', '192k', '128k']
|
||||
export const getMusicType = (info, type) => {
|
||||
switch (info.source) {
|
||||
// case 'kg':
|
||||
case 'wy':
|
||||
case 'tx':
|
||||
return '128k'
|
||||
case 'xm':
|
||||
if (type == 'wav') type = '320k'
|
||||
}
|
||||
let list = window.globalObj.qualityList[info.source]
|
||||
if (!list) return '128k'
|
||||
if (!list.includes(type)) type = list[list.length - 1]
|
||||
const rangeType = types.slice(types.indexOf(type))
|
||||
for (const type of rangeType) {
|
||||
if (info._types[type]) return type
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import leaderboard from './leaderboard'
|
||||
import api_source from '../api-source'
|
||||
import { apis } from '../api-source'
|
||||
import getLyric from './lyric'
|
||||
import getMusicInfo from './musicInfo'
|
||||
import musicSearch from './musicSearch'
|
||||
@@ -12,7 +12,7 @@ const wy = {
|
||||
songList,
|
||||
hotSearch,
|
||||
getMusicUrl(songInfo, type) {
|
||||
return api_source('wy').getMusicUrl(songInfo, type)
|
||||
return apis('wy').getMusicUrl(songInfo, type)
|
||||
},
|
||||
getLyric(songInfo) {
|
||||
return getLyric(songInfo.songmid)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import api_source from '../api-source'
|
||||
import { apis } from '../api-source'
|
||||
import leaderboard from './leaderboard'
|
||||
import songList from './songList'
|
||||
import musicSearch from './musicSearch'
|
||||
@@ -14,7 +14,7 @@ const xm = {
|
||||
hotSearch,
|
||||
closeVerifyModal,
|
||||
getMusicUrl(songInfo, type) {
|
||||
return api_source('xm').getMusicUrl(songInfo, type)
|
||||
return apis('xm').getMusicUrl(songInfo, type)
|
||||
},
|
||||
getLyric(songInfo) {
|
||||
return lyric.getLyric(songInfo)
|
||||
|
||||
Reference in New Issue
Block a user