@@ -85,7 +85,7 @@ import { getkeyMap } from '../../main/hotKey.js'
const localStorage = require('../../main/localStorage').default
const { shell, getCurrentWebContents } = require('electron').remote
const packjsonUrl = 'http://cocomusic-1252075019.file.myqcloud.com/package.json'
-const CURRENT_VERSION = '2.0.5'
+const CURRENT_VERSION = '2.0.6'
export default {
data () {
diff --git a/src/renderer/store/modules/Player.js b/src/renderer/store/modules/Player.js
index 5fb29c4..300af35 100644
--- a/src/renderer/store/modules/Player.js
+++ b/src/renderer/store/modules/Player.js
@@ -1,4 +1,4 @@
-import { getSongVkey, getLyric, getKey } from '../../../spider/index'
+import { getSongVkey, getLyric, getKey, getCdn } from '../../../spider/index'
import { throttle, random } from 'lodash'
import { setMprisProp, setPosition, mpris } from '../../mpris'
const { dialog, app } = require('electron').remote
@@ -58,7 +58,8 @@ const state = {
loop: window.localStorage.loop !== undefined
? !!window.localStorage.loop
: true,
- vkey: ''
+ vkey: '',
+ cdn: ''
}
const mutations = {
@@ -132,6 +133,10 @@ const actions = {
* @param {Object} state
*/
async initPlayer ({ state, commit, dispatch, getters }) {
+ commit('setPlayerState', {
+ cdn: await getCdn(state.guid)
+ })
+
state.player.append(state.source, state.sourceBac1, state.sourceBac2)
let { player, playVolume, mode } = state
@@ -202,7 +207,7 @@ const actions = {
* @param {Number} index 歌曲索引
*/
async setPlay ({ state, commit, getters }, index) {
- const { guid } = state
+ const { guid, cdn } = state
const current = state.playList[index] // 保存当前播放的引用
commit('setPlayerState', { loading: true })
@@ -218,7 +223,7 @@ const actions = {
})
commit('setPlayerSrc', [
- `http://113.105.155.25/amobile.music.tc.qq.com/${song.fileName}?vkey=${vkey}&guid=${guid}&uin=0&fromtag=66`
+ `${cdn}${song.fileName}?vkey=${vkey}&guid=${guid}&uin=0&fromtag=66`
])
// TODO 添加 cdn 选择,不过我觉得没有必要,毕竟要搞新坑了
diff --git a/src/spider/index.js b/src/spider/index.js
index 0a52041..3f35838 100644
--- a/src/spider/index.js
+++ b/src/spider/index.js
@@ -82,11 +82,11 @@ export async function getSingerMusicList ({page, singerMid}) {
return {
total: Math.floor(total / 30),
list: list.map(
- ({musicData: {songmid, strMediaMid, songname, albumname, albummid, singer, type}}) =>
+ ({musicData: {
+ songmid, strMediaMid, songname, albumname, albummid, singer, type}}) =>
new Music(songname, songmid, strMediaMid,
new Album(albumname, albummid),
- singer.map(
- ({mid, name}) => new Singer(name,mid))
+ singer.map(({mid, name}) => new Singer(name, mid))
, type))
}
}
@@ -188,10 +188,10 @@ export async function getSearch ({keyword, page}) {
return {direct, totalPage: Math.ceil(totalnum / 20),
songList: list.map(
({name, mid, file: {media_mid}, singer, album, type}) =>
- new Music(name, mid, media_mid,
+ new Music(
+ name, mid, media_mid,
new Album(album.name, album.mid),
- singer.map(
- singerItem =>
+ singer.map(singerItem =>
new Singer(singerItem.name, singerItem.mid)),
type))
}
@@ -209,10 +209,10 @@ export async function getAlbum ({albumMid}) {
return {
musicList: list.map(
({songname, songmid, strMediaMid, albumname, albummid, singer, type}) =>
- new Music(songname, songmid, strMediaMid,
+ new Music(
+ songname, songmid, strMediaMid,
new Album(albumname, albummid),
- singer.map(
- ({mid, name}) => new Singer(name, mid)),
+ singer.map(({mid, name}) => new Singer(name, mid)),
type)),
album: new Album(name, albumMid)
}
@@ -247,10 +247,24 @@ export async function getPlayListInfo (playListMid) {
playListName: dissname,
list: songlist.map(
({songname, songmid, strMediaMid, albumname, albummid, singer, type}) =>
- new Music(songname, songmid, strMediaMid,
+ new Music(
+ songname, songmid, strMediaMid,
new Album(albumname, albummid),
singer.map(
({mid, name}) => new Singer(name, mid))
, type))
}
}
+
+export async function getCdn (guid) {
+ const url = `https://u.y.qq.com/cgi-bin/musicu.fcg?data=${encodeURIComponent(`{"req":{"module":"CDN.SrfCdnDispatchServer","method":"GetCdnDispatch","param":{"guid":${guid},"calltype":0,"userip":""}},"req_0":{"module":"vkey.GetVkeyServer","method":"CgiGetVkey","param":{"guid":"${guid}","songmid":["000KDHyB23K7Eq"],"songtype":[0],"uin":"0","loginflag":1,"platform":"20"}},"comm":{"uin":0,"format":"json","ct":24,"cv":0}}`)}`
+ const { data: { req: { data: { sip: cdnList, testfilewifi: testUrl } } }} = await baseRequest(url)
+ return new Promise((resolve, reject) => {
+ cdnList.map(cdn => {
+ baseRequest(cdn + testUrl).then(() => {
+ console.log(cdn)
+ resolve(cdn)
+ })
+ })
+ })
+}
\ No newline at end of file