移除虾米源,允许播放除了搜索列表以外的所有歌曲

pull/459/head
lyswhut 2021-02-05 23:06:08 +08:00
parent a0254eb4f2
commit c78811fe36
13 changed files with 134 additions and 65 deletions

View File

@ -34,18 +34,20 @@
"publish:gh:linux": "node build-config/pack.js && npm run publish:linux", "publish:gh:linux": "node build-config/pack.js && npm run publish:linux",
"publish:linux": "npm run publish:linux:deb && npm run publish:linux:appImage && npm run publish:linux:rpm && npm run publish:linux:pacman", "publish:linux": "npm run publish:linux:deb && npm run publish:linux:appImage && npm run publish:linux:rpm && npm run publish:linux:pacman",
"publish:linux:appImage": "cross-env ARCH=x64 electron-builder -l=AppImage -p onTagOrDraft", "publish:linux:appImage": "cross-env ARCH=x64 electron-builder -l=AppImage -p onTagOrDraft",
"publish:linux:deb": "npm run publish:linux:deb:x64 && npm run publish:linux:deb:x86 && npm run publish:linux:deb:arm64", "publish:linux:deb": "npm run publish:linux:deb:x64 && npm run publish:linux:deb:x86 && npm run publish:linux:deb:arm64 && npm run publish:linux:deb:armv7l",
"publish:linux:deb:x64": "cross-env ARCH=x64 electron-builder -l=deb --x64 -p onTagOrDraft", "publish:linux:deb:x64": "cross-env ARCH=x64 electron-builder -l=deb --x64 -p onTagOrDraft",
"publish:linux:deb:x86": "cross-env ARCH=x86 electron-builder -l=deb --ia32 -p onTagOrDraft", "publish:linux:deb:x86": "cross-env ARCH=x86 electron-builder -l=deb --ia32 -p onTagOrDraft",
"publish:linux:deb:arm64": "cross-env ARCH=arm64 electron-builder -l=deb --arm64 -p onTagOrDraft", "publish:linux:deb:arm64": "cross-env ARCH=arm64 electron-builder -l=deb --arm64 -p onTagOrDraft",
"publish:linux:deb:armv7l": "cross-env ARCH=armv7l electron-builder -l=deb --armv7l -p onTagOrDraft",
"publish:linux:rpm": "cross-env ARCH=x64 electron-builder -l=rpm --x64 -p onTagOrDraft", "publish:linux:rpm": "cross-env ARCH=x64 electron-builder -l=rpm --x64 -p onTagOrDraft",
"publish:linux:pacman": "cross-env ARCH=x64 electron-builder -l=pacman --x64 -p onTagOrDraft", "publish:linux:pacman": "cross-env ARCH=x64 electron-builder -l=pacman --x64 -p onTagOrDraft",
"pack:linux": "node build-config/pack.js && npm run pack:linux:deb && npm run pack:linux:appImage && npm run pack:linux:rpm && npm run pack:linux:pacman", "pack:linux": "node build-config/pack.js && npm run pack:linux:deb && npm run pack:linux:appImage && npm run pack:linux:rpm && npm run pack:linux:pacman",
"pack:linux:appImage": "cross-env ARCH=x64 electron-builder -l=AppImage", "pack:linux:appImage": "cross-env ARCH=x64 electron-builder -l=AppImage",
"pack:linux:deb": "npm run pack:linux:deb:x64 && npm run pack:linux:deb:x86 && npm run pack:linux:deb:arm64", "pack:linux:deb": "npm run pack:linux:deb:x64 && npm run pack:linux:deb:x86 && npm run pack:linux:deb:arm64 && npm run pack:linux:deb:armv7l",
"pack:linux:deb:x64": "cross-env ARCH=x64 electron-builder -l=deb --x64", "pack:linux:deb:x64": "cross-env ARCH=x64 electron-builder -l=deb --x64",
"pack:linux:deb:x86": "cross-env ARCH=x86 electron-builder -l=deb --ia32", "pack:linux:deb:x86": "cross-env ARCH=x86 electron-builder -l=deb --ia32",
"pack:linux:deb:arm64": "cross-env ARCH=arm64 electron-builder -l=deb --arm64", "pack:linux:deb:arm64": "cross-env ARCH=arm64 electron-builder -l=deb --arm64",
"pack:linux:deb:armv7l": "cross-env ARCH=armv7l electron-builder -l=deb --armv7l",
"pack:linux:rpm": "cross-env ARCH=x64 electron-builder -l=rpm --x64", "pack:linux:rpm": "cross-env ARCH=x64 electron-builder -l=rpm --x64",
"pack:linux:pacman": "cross-env ARCH=x64 electron-builder -l=pacman --x64", "pack:linux:pacman": "cross-env ARCH=x64 electron-builder -l=pacman --x64",
"pack:mac": "node build-config/pack.js && electron-builder -m=dmg", "pack:mac": "node build-config/pack.js && electron-builder -m=dmg",

View File

@ -2,6 +2,14 @@
- 新增设置-其他-列表缓存信息清理功能,注:此功能一般情况下不要使用 - 新增设置-其他-列表缓存信息清理功能,注:此功能一般情况下不要使用
### 优化
- 允许播放除了搜索列表以外的所有歌曲,即原来没有播放按钮或者灰色的歌曲都可以点击尝试去播放。注:该功能的原理是尝试自动切换到其他源播放,所以不一定会播放成功,特别是对于那些独家的资源
### 移除
- 移除虾米源。注:虽然已移除该源,但仍可尝试去播放之前添加的歌曲,虽然不一定会成功
### 修复 ### 修复
- 修复音乐搜索列表的稍后播放功能无效的问题 - 修复音乐搜索列表的稍后播放功能无效的问题

View File

@ -91,7 +91,6 @@ import { formatPlayTime2, getRandom, checkPath, setTitle, clipboardWriteText, de
import { mapGetters, mapActions, mapMutations } from 'vuex' import { mapGetters, mapActions, mapMutations } from 'vuex'
import { requestMsg } from '../../utils/message' import { requestMsg } from '../../utils/message'
import { player as eventPlayerNames } from '../../../common/hotKey' import { player as eventPlayerNames } from '../../../common/hotKey'
import musicSdk from '@renderer/utils/music'
import path from 'path' import path from 'path'
let audio let audio
@ -327,6 +326,7 @@ export default {
}, },
methods: { methods: {
...mapActions('player', ['getUrl', 'getPic', 'getLrc', 'playPrev', 'playNext']), ...mapActions('player', ['getUrl', 'getPic', 'getLrc', 'playPrev', 'playNext']),
...mapActions('list', ['getOtherSource']),
...mapMutations('player', [ ...mapMutations('player', [
'setPlayMusicInfo', 'setPlayMusicInfo',
'setPlayIndex', 'setPlayIndex',
@ -492,7 +492,7 @@ export default {
this.setImg(targetSong.musicInfo) this.setImg(targetSong.musicInfo)
this.setLrc(targetSong.musicInfo) this.setLrc(targetSong.musicInfo)
} else { } else {
if (!this.assertApiSupport(targetSong.source)) return this.playNext() // if (!this.assertApiSupport(targetSong.source)) return this.playNext()
this.musicInfo.songmid = targetSong.songmid this.musicInfo.songmid = targetSong.songmid
this.musicInfo.singer = targetSong.singer this.musicInfo.singer = targetSong.singer
this.musicInfo.name = targetSong.name this.musicInfo.name = targetSong.name
@ -573,7 +573,7 @@ export default {
togglePlay() { togglePlay() {
if (!audio.src) { if (!audio.src) {
if (this.restorePlayTime != null) { if (this.restorePlayTime != null) {
if (!this.assertApiSupport(this.targetSong.source)) return this.playNext() // if (!this.assertApiSupport(this.targetSong.source)) return this.playNext()
this.setUrl(this.targetSong) this.setUrl(this.targetSong)
} }
return return
@ -613,10 +613,7 @@ export default {
this.status = this.statusText = 'Try toggle source...' this.status = this.statusText = 'Try toggle source...'
return (originMusic.otherSource && originMusic.otherSource.length ? Promise.resolve(originMusic.otherSource) : musicSdk.findMusic(originMusic)).then(res => { return this.getOtherSource(originMusic).then(otherSource => {
this.updateMusicInfo({ id: this.listId, index: this.playIndex, data: { otherSource: res }, musicInfo: originMusic })
return res
}).then(otherSource => {
console.log('find otherSource', otherSource) console.log('find otherSource', otherSource)
if (otherSource.length) { if (otherSource.length) {
for (const item of otherSource) { for (const item of otherSource) {

View File

@ -50,7 +50,7 @@ export default {
singer: '', singer: '',
}, },
page: 1, page: 1,
total: 10, total: 0,
maxPage: 1, maxPage: 1,
limit: 20, limit: 20,
isHotLoading: true, isHotLoading: true,

View File

@ -31,8 +31,6 @@ div(:class="$style.songList")
td(:style="{ width: rowWidth.r6 }" style="padding-left: 0; padding-right: 0;") td(:style="{ width: rowWidth.r6 }" style="padding-left: 0; padding-right: 0;")
material-list-buttons(:index="index" :class="$style.btns" material-list-buttons(:index="index" :class="$style.btns"
:remove-btn="false" @btn-click="handleListBtnClick" :remove-btn="false" @btn-click="handleListBtnClick"
:listAdd-btn="assertApiSupport(item.source)"
:play-btn="assertApiSupport(item.source)"
:download-btn="assertApiSupport(item.source)") :download-btn="assertApiSupport(item.source)")
//- button.btn-info(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k'] || item._types.flac" @click.stop='openDownloadModal(index)') //- button.btn-info(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k'] || item._types.flac" @click.stop='openDownloadModal(index)')
//- button.btn-secondary(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k']" @click.stop='testPlay(index)') //- button.btn-secondary(type='button' v-if="item._types['128k'] || item._types['192k'] || item._types['320k']" @click.stop='testPlay(index)')
@ -243,7 +241,7 @@ export default {
this.clickIndex = index this.clickIndex = index
return return
} }
this.emitEvent(this.assertApiSupport(this.source) ? 'testPlay' : 'search', index) this.emitEvent('testPlay', index)
this.clickTime = 0 this.clickTime = 0
this.clickIndex = -1 this.clickIndex = -1
}, },
@ -340,9 +338,9 @@ export default {
}, },
handleListItemRigthClick(event, index) { handleListItemRigthClick(event, index) {
this.listMenu.itemMenuControl.sourceDetail = !!musicSdk[this.list[index].source].getMusicDetailPageUrl this.listMenu.itemMenuControl.sourceDetail = !!musicSdk[this.list[index].source].getMusicDetailPageUrl
this.listMenu.itemMenuControl.play = // this.listMenu.itemMenuControl.play =
this.listMenu.itemMenuControl.playLater = // this.listMenu.itemMenuControl.playLater =
this.listMenu.itemMenuControl.download = this.listMenu.itemMenuControl.download =
this.assertApiSupport(this.list[index].source) this.assertApiSupport(this.list[index].source)
let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected') let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected')
if (dom_selected) dom_selected.classList.remove('selected') if (dom_selected) dom_selected.classList.remove('selected')

View File

@ -1,3 +1,5 @@
import musicSdk from '../../utils/music'
let allList = {} let allList = {}
window.allList = allList window.allList = allList
@ -48,7 +50,12 @@ const getters = {
// actions // actions
const actions = { const actions = {
getOtherSource({ state, commit }, musicInfo) {
return (musicInfo.otherSource && musicInfo.otherSource.length ? Promise.resolve(musicInfo.otherSource) : musicSdk.findMusic(musicInfo)).then(otherSource => {
commit('setOtherSource', { musicInfo, otherSource })
return otherSource
})
},
} }
// mitations // mitations
@ -217,6 +224,9 @@ const mutations = {
} }
} }
}, },
setOtherSource(state, { musicInfo, otherSource }) {
musicInfo.otherSource = otherSource
},
} }
export default { export default {

View File

@ -18,8 +18,8 @@ const state = {
} }
let urlRequest let urlRequest
let picRequest // let picRequest
let lrcRequest // let lrcRequest
const filterList = async({ playedList, listInfo, savePath, commit }) => { const filterList = async({ playedList, listInfo, savePath, commit }) => {
// if (this.list.listName === null) return // if (this.list.listName === null) return
@ -44,7 +44,7 @@ const filterList = async({ playedList, listInfo, savePath, commit }) => {
} }
} else { } else {
list = listInfo.list.filter(s => { list = listInfo.list.filter(s => {
if (!assertApiSupport(s.source)) return false // if (!assertApiSupport(s.source)) return false
canPlayList.push(s) canPlayList.push(s)
let index = filteredPlayedList.indexOf(s) let index = filteredPlayedList.indexOf(s)
@ -62,6 +62,42 @@ const filterList = async({ playedList, listInfo, savePath, commit }) => {
return list return list
} }
const getPic = function(musicInfo, retryedSource = [], originMusic) {
console.log(musicInfo.source)
return music[musicInfo.source].getPic(musicInfo).promise.catch(err => {
if (!retryedSource.includes(musicInfo.source)) retryedSource.push(musicInfo.source)
return this.dispatch('list/getOtherSource', musicInfo).then(otherSource => {
if (!originMusic) originMusic = musicInfo
console.log('find otherSource', otherSource)
if (otherSource.length) {
for (const item of otherSource) {
if (retryedSource.includes(item.source)) continue
console.log('try toggle to: ', item.source, item.name, item.singer, item.interval)
return getPic.call(this, item, retryedSource, originMusic)
}
}
return Promise.reject(err)
})
})
}
const getLyric = function(musicInfo, retryedSource = [], originMusic) {
return music[musicInfo.source].getLyric(musicInfo).promise.catch(err => {
if (!retryedSource.includes(musicInfo.source)) retryedSource.push(musicInfo.source)
return this.dispatch('list/getOtherSource', musicInfo).then(otherSource => {
if (!originMusic) originMusic = musicInfo
console.log('find otherSource', otherSource)
if (otherSource.length) {
for (const item of otherSource) {
if (retryedSource.includes(item.source)) continue
console.log('try toggle to: ', item.source, item.name, item.singer, item.interval)
return getLyric.call(this, item, retryedSource, originMusic)
}
}
return Promise.reject(err)
})
})
}
// getters // getters
const getters = { const getters = {
list: state => state.listInfo.list, list: state => state.listInfo.list,
@ -120,7 +156,11 @@ const actions = {
} }
if (urlRequest && urlRequest.cancelHttp) urlRequest.cancelHttp() if (urlRequest && urlRequest.cancelHttp) urlRequest.cancelHttp()
if (musicInfo.typeUrl[type] && !isRefresh) return Promise.resolve(musicInfo.typeUrl[type]) if (musicInfo.typeUrl[type] && !isRefresh) return Promise.resolve(musicInfo.typeUrl[type])
urlRequest = music[musicInfo.source].getMusicUrl(musicInfo, type) try {
urlRequest = music[musicInfo.source].getMusicUrl(musicInfo, type)
} catch (err) {
return Promise.reject(err)
}
return urlRequest.promise.then(({ url }) => { return urlRequest.promise.then(({ url }) => {
if (originMusic) commit('setUrl', { musicInfo: originMusic, url, type }) if (originMusic) commit('setUrl', { musicInfo: originMusic, url, type })
commit('setUrl', { musicInfo, url, type }) commit('setUrl', { musicInfo, url, type })
@ -132,18 +172,18 @@ const actions = {
}) })
}, },
getPic({ commit, state }, musicInfo) { getPic({ commit, state }, musicInfo) {
if (picRequest && picRequest.cancelHttp) picRequest.cancelHttp() // if (picRequest && picRequest.cancelHttp) picRequest.cancelHttp()
picRequest = music[musicInfo.source].getPic(musicInfo) // picRequest = music[musicInfo.source].getPic(musicInfo)
return picRequest.promise.then(url => { return getPic.call(this, musicInfo).then(url => {
picRequest = null // picRequest = null
commit('getPic', { musicInfo, url }) commit('getPic', { musicInfo, url })
}).catch(err => { }).catch(err => {
picRequest = null // picRequest = null
return Promise.reject(err) return Promise.reject(err)
}) })
}, },
getLrc({ commit, state }, musicInfo) { getLrc({ commit, state }, musicInfo) {
if (lrcRequest && lrcRequest.cancelHttp) lrcRequest.cancelHttp() // if (lrcRequest && lrcRequest.cancelHttp) lrcRequest.cancelHttp()
if (musicInfo.lrc && musicInfo.tlrc != null) { if (musicInfo.lrc && musicInfo.tlrc != null) {
if (musicInfo.lrc.startsWith('\ufeff[id:$00000000]')) { if (musicInfo.lrc.startsWith('\ufeff[id:$00000000]')) {
let str = musicInfo.lrc.replace('\ufeff[id:$00000000]\n', '') let str = musicInfo.lrc.replace('\ufeff[id:$00000000]\n', '')
@ -153,12 +193,12 @@ const actions = {
} }
lrcRequest = music[musicInfo.source].getLyric(musicInfo) // lrcRequest = music[musicInfo.source].getLyric(musicInfo)
return lrcRequest.promise.then(({ lyric, tlyric }) => { return getLyric.call(this, musicInfo).then(({ lyric, tlyric }) => {
lrcRequest = null // lrcRequest = null
commit('setLrc', { musicInfo, lyric, tlyric }) commit('setLrc', { musicInfo, lyric, tlyric })
}).catch(err => { }).catch(err => {
lrcRequest = null // lrcRequest = null
return Promise.reject(err) return Promise.reject(err)
}) })
}, },

View File

@ -11,7 +11,6 @@ module.exports = [
tx: ['128k'], tx: ['128k'],
wy: ['128k'], wy: ['128k'],
mg: ['128k'], mg: ['128k'],
xm: ['128k'],
// bd: ['128k'], // bd: ['128k'],
}, },
}, },

View File

@ -87,7 +87,7 @@ export default {
item.name = trimStr(item.name) item.name = trimStr(item.name)
item.lowerCaseName = String(item.name).toLowerCase() item.lowerCaseName = String(item.name).toLowerCase()
item.lowerCaseAlbumName = String(item.albumName).toLowerCase() item.lowerCaseAlbumName = String(item.albumName).toLowerCase()
console.log(lowerCaseName, item.lowerCaseName) // console.log(lowerCaseName, item.lowerCaseName)
if ( if (
( (
item.sortedSinger === sortedSinger && item.sortedSinger === sortedSinger &&

View File

@ -1,39 +1,54 @@
import { apis } from '../api-source' // import { apis } from '../api-source'
import leaderboard from './leaderboard' // import leaderboard from './leaderboard'
import songList from './songList' // import songList from './songList'
import musicSearch from './musicSearch' // import musicSearch from './musicSearch'
// import pic from './pic' // 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 musicInfo from './musicInfo' // import musicInfo from './musicInfo'
import { closeVerifyModal } from './util' // import { closeVerifyModal } from './util'
const xm = { const xm = {
songList, // songList,
musicSearch, // musicSearch,
leaderboard, // leaderboard,
hotSearch, // hotSearch,
closeVerifyModal, // closeVerifyModal,
comment, comment: {
getComment() {
return Promise.reject(new Error('fail'))
},
getHotComment() {
return Promise.reject(new Error('fail'))
},
},
getMusicUrl(songInfo, type) { getMusicUrl(songInfo, type) {
return apis('xm').getMusicUrl(songInfo, type) return {
promise: Promise.reject(new Error('fail')),
}
// return apis('xm').getMusicUrl(songInfo, type)
}, },
getLyric(songInfo) { getLyric(songInfo) {
return lyric.getLyric(songInfo) return {
promise: Promise.reject(new Error('fail')),
}
// return lyric.getLyric(songInfo)
}, },
getPic(songInfo) { getPic(songInfo) {
return Promise.reject(new Error('fail')) return {
promise: Promise.reject(new Error('fail')),
}
// return pic.getPic(songInfo) // return pic.getPic(songInfo)
}, },
getMusicDetailPageUrl(songInfo) { // getMusicDetailPageUrl(songInfo) {
if (songInfo.songStringId) return `https://www.xiami.com/song/${songInfo.songStringId}` // if (songInfo.songStringId) return `https://www.xiami.com/song/${songInfo.songStringId}`
musicInfo.getMusicInfo(songInfo).then(({ data }) => { // musicInfo.getMusicInfo(songInfo).then(({ data }) => {
songInfo.songStringId = data.songStringId // songInfo.songStringId = data.songStringId
}) // })
return `https://www.xiami.com/song/${songInfo.songmid}` // return `https://www.xiami.com/song/${songInfo.songmid}`
}, // },
// init() { // init() {
// getToken() // getToken()
// }, // },

View File

@ -68,7 +68,7 @@ export const xmRequest = (path, params = '') => {
isCancelled: false, isCancelled: false,
cancelHttp() { cancelHttp() {
if (!this.isInited) this.isCancelled = true if (!this.isInited) this.isCancelled = true
this.requestObj.cancelHttp() this.requestObj && this.requestObj.cancelHttp()
}, },
} }

View File

@ -569,7 +569,7 @@ export default {
} }
}, },
testPlay(index) { testPlay(index) {
if (!this.assertApiSupport(this.list[index].source)) return // if (!this.assertApiSupport(this.list[index].source)) return
this.setPlayList({ list: this.listData, index }) this.setPlayList({ list: this.listData, index })
}, },
handleRemove(index) { handleRemove(index) {
@ -579,7 +579,7 @@ export default {
switch (info.action) { switch (info.action) {
case 'download': { case 'download': {
const minfo = this.list[info.index] const minfo = this.list[info.index]
if (!this.assertApiSupport(minfo.source)) return // if (!this.assertApiSupport(minfo.source)) return
this.musicInfo = minfo this.musicInfo = minfo
this.$nextTick(() => { this.$nextTick(() => {
this.isShowDownload = true this.isShowDownload = true
@ -732,9 +732,9 @@ export default {
}, },
handleListItemRigthClick(event, index) { handleListItemRigthClick(event, index) {
this.listMenu.itemMenuControl.sourceDetail = !!musicSdk[this.list[index].source].getMusicDetailPageUrl this.listMenu.itemMenuControl.sourceDetail = !!musicSdk[this.list[index].source].getMusicDetailPageUrl
this.listMenu.itemMenuControl.play = // this.listMenu.itemMenuControl.play =
this.listMenu.itemMenuControl.playLater = // this.listMenu.itemMenuControl.playLater =
this.listMenu.itemMenuControl.download = this.listMenu.itemMenuControl.download =
this.assertApiSupport(this.list[index].source) this.assertApiSupport(this.list[index].source)
let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected') let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected')
if (dom_selected) dom_selected.classList.remove('selected') if (dom_selected) dom_selected.classList.remove('selected')

View File

@ -239,7 +239,7 @@ export default {
break break
case 'play': case 'play':
if (this.selectedData.length) { if (this.selectedData.length) {
this.listAddMultiple({ id: 'default', list: this.filterList(this.selectedData) }) this.listAddMultiple({ id: 'default', list: [...this.selectedData] })
this.resetSelect() this.resetSelect()
} }
this.testPlay(info.index) this.testPlay(info.index)