新增播放自动换源功能

This commit is contained in:
lyswhut
2021-01-09 00:45:15 +08:00
parent 6b7d2ea657
commit 9a1a537bfd
21 changed files with 90 additions and 8 deletions
+43
View File
@@ -56,4 +56,47 @@ export default {
}
},
supportQuality,
async findMusic(musicInfo) {
const tasks = []
for (const source of sources.sources) {
if (!sources[source.id].musicSearch || source.id === musicInfo.source || source.id === 'xm') continue
tasks.push(sources[source.id].musicSearch.search(`${musicInfo.name} ${musicInfo.singer || ''} ${musicInfo.albumName || ''}`.trim(), 1, { limit: 5 }).then(res => {
for (const item of res.list) {
if (item.singer === musicInfo.singer && (item.name === musicInfo.name || item.interval === musicInfo.interval)) {
return item
}
}
return null
}).catch(_ => null))
}
const result = (await Promise.all(tasks)).filter(s => s)
const newResult = []
if (result.length) {
for (let i = result.length - 1; i > -1; i--) {
const item = result[i]
if (item.singer === musicInfo.singer && item.name === musicInfo.name && item.interval === musicInfo.interval) {
newResult.push(item)
result.splice(i, 1)
}
}
for (let i = result.length - 1; i > -1; i--) {
const item = result[i]
if (item.singer === musicInfo.singer && item.interval === musicInfo.interval) {
newResult.push(item)
result.splice(i, 1)
}
}
for (let i = result.length - 1; i > -1; i--) {
const item = result[i]
if (item.singer === musicInfo.singer && item.name === musicInfo.name) {
newResult.push(item)
result.splice(i, 1)
}
}
}
// console.log(newResult)
return newResult
},
}
@@ -144,6 +144,7 @@ export default {
img: null,
lrc: null,
hash: item.HASH,
otherSource: null,
types,
_types,
typeUrl: {},
@@ -60,6 +60,7 @@ export default {
_interval: item.duration,
img: null,
lrc: null,
otherSource: null,
hash: item.hash,
types,
_types,
+1
View File
@@ -517,6 +517,7 @@ export default {
img: null,
lrc: null,
hash: item.audio_info.hash,
otherSource: null,
types,
_types,
typeUrl: {},
@@ -142,6 +142,7 @@ export default {
interval: formatPlayTime(parseInt(item.song_duration)),
img: item.pic,
lrc: null,
otherSource: null,
types,
_types,
typeUrl: {},
@@ -115,6 +115,7 @@ export default {
albumName: info.ALBUM ? decodeName(info.ALBUM) : '',
lrc: null,
img: null,
otherSource: null,
types,
_types,
typeUrl: {},
+1
View File
@@ -237,6 +237,7 @@ export default {
interval: formatPlayTime(parseInt(item.duration)),
img: null,
lrc: null,
otherSource: null,
types,
_types,
typeUrl: {},
@@ -144,6 +144,7 @@ export default {
img: item.albumImgs && item.albumImgs.length ? item.albumImgs[0].img : null,
lrc: null,
lrcUrl: item.lrcUrl,
otherSource: null,
types,
_types,
typeUrl: {},
+2 -1
View File
@@ -36,7 +36,7 @@ export default {
return arr.join('、')
},
handleResult(rawData) {
console.log(rawData)
// console.log(rawData)
let ids = new Set()
const list = []
rawData.forEach(item => {
@@ -89,6 +89,7 @@ export default {
img: item.imgItems && item.imgItems.length ? item.imgItems[0].img : null,
lrc: null,
lrcUrl: item.lyricUrl,
otherSource: null,
types,
_types,
typeUrl: {},
+1
View File
@@ -141,6 +141,7 @@ export default {
img: item.albumImgs && item.albumImgs.length ? item.albumImgs[0].img : null,
lrc: null,
lrcUrl: item.lrcUrl,
otherSource: null,
types,
_types,
typeUrl: {},
@@ -167,6 +167,7 @@ export default {
? `https://y.gtimg.cn/music/photo_new/T001R500x500M000${item.singer[0].mid}.jpg`
: `https://y.gtimg.cn/music/photo_new/T002R500x500M000${item.album.mid}.jpg`,
lrc: null,
otherSource: null,
types,
_types,
typeUrl: {},
@@ -78,6 +78,7 @@ export default {
? `https://y.gtimg.cn/music/photo_new/T001R500x500M000${item.singer[0].mid}.jpg`
: `https://y.gtimg.cn/music/photo_new/T002R500x500M000${item.album.mid}.jpg`,
lrc: null,
otherSource: null,
types,
_types,
typeUrl: {},
+1
View File
@@ -281,6 +281,7 @@ export default {
? `https://y.gtimg.cn/music/photo_new/T001R500x500M000${item.singer[0].mid}.jpg`
: `https://y.gtimg.cn/music/photo_new/T002R500x500M000${item.album.mid}.jpg`,
lrc: null,
otherSource: null,
types,
_types,
typeUrl: {},
@@ -60,6 +60,7 @@ export default {
songmid: item.id,
img: item.al.picUrl,
lrc: null,
otherSource: null,
types,
_types,
typeUrl: {},
+1
View File
@@ -161,6 +161,7 @@ export default {
songmid: item.id,
img: item.al.picUrl,
lrc: null,
otherSource: null,
types,
_types,
typeUrl: {},
@@ -127,6 +127,7 @@ export default {
songStringId: songData.songStringId,
lrc: null,
lrcUrl: songData.lyricInfo && songData.lyricInfo.lyricFile,
otherSource: null,
types,
_types,
typeUrl: {},
@@ -79,6 +79,7 @@ export default {
songStringId: songData.songStringId,
lrc: null,
lrcUrl: songData.lyricInfo && songData.lyricInfo.lyricFile,
otherSource: null,
types,
_types,
typeUrl: {},
+1
View File
@@ -142,6 +142,7 @@ export default {
img: songData.albumLogo || songData.albumLogoS,
lrc: null,
lrcUrl: songData.lyricInfo && songData.lyricInfo.lyricFile,
otherSource: null,
types,
_types,
typeUrl: {},