修复wy源我喜欢个人云盘歌曲信息获取问题

pull/1066/head
lyswhut 2022-11-27 19:14:27 +08:00
parent ae467cd515
commit e467b92bb9
2 changed files with 83 additions and 43 deletions

View File

@ -6,7 +6,7 @@ import { formatPlayTime, sizeFormate } from '../../index'
export default { export default {
getSinger(singers) { getSinger(singers) {
let arr = [] let arr = []
singers.forEach(singer => { singers?.forEach(singer => {
arr.push(singer.name) arr.push(singer.name)
}) })
return arr.join('、') return arr.join('、')
@ -46,21 +46,39 @@ export default {
types.reverse() types.reverse()
list.push({ if (item.pc) {
singer: this.getSinger(item.ar), list.push({
name: item.name, singer: item.pc.ar,
albumName: item.al.name, name: item.pc.sn,
albumId: item.al.id, albumName: item.pc.alb,
source: 'wy', albumId: item.al?.id,
interval: formatPlayTime(item.dt / 1000), source: 'wy',
songmid: item.id, interval: formatPlayTime(item.dt / 1000),
img: item.al.picUrl, songmid: item.id,
lrc: null, img: item.al?.picUrl ?? '',
otherSource: null, lrc: null,
types, otherSource: null,
_types, types,
typeUrl: {}, _types,
}) typeUrl: {},
})
} else {
list.push({
singer: this.getSinger(item.ar),
name: item.name,
albumName: item.al?.name,
albumId: item.al?.id,
source: 'wy',
interval: formatPlayTime(item.dt / 1000),
songmid: item.id,
img: item.al?.picUrl,
lrc: null,
otherSource: null,
types,
_types,
typeUrl: {},
})
}
}) })
// console.log(list) // console.log(list)
return list return list

View File

@ -42,7 +42,7 @@ export default {
}, },
getSinger(singers) { getSinger(singers) {
let arr = [] let arr = []
singers.forEach(singer => { singers?.forEach(singer => {
arr.push(singer.name) arr.push(singer.name)
}) })
return arr.join('、') return arr.join('、')
@ -107,20 +107,24 @@ export default {
let limit = 1000 let limit = 1000
let rangeStart = (page - 1) * limit let rangeStart = (page - 1) * limit
// console.log(body) // console.log(body)
let musicDetail let list
try { if (body.playlist.trackIds.length == body.privileges.length) {
musicDetail = await musicDetailApi.getList(body.playlist.trackIds.slice(rangeStart, limit * page).map(trackId => trackId.id)) list = this.filterListDetail(body)
} catch (err) { } else {
console.log(err) try {
if (err.message == 'try max num') { list = (await musicDetailApi.getList(body.playlist.trackIds.slice(rangeStart, limit * page).map(trackId => trackId.id))).list
throw err } catch (err) {
} else { console.log(err)
return this.getListDetail(id, page, ++tryNum) if (err.message == 'try max num') {
throw err
} else {
return this.getListDetail(id, page, ++tryNum)
}
} }
} }
// console.log(musicDetail) // console.log(list)
return { return {
list: musicDetail.list, list,
page, page,
limit, limit,
total: body.playlist.trackIds.length, total: body.playlist.trackIds.length,
@ -169,21 +173,39 @@ export default {
types.reverse() types.reverse()
list.push({ if (item.pc) {
singer: this.getSinger(item.ar), list.push({
name: item.name, singer: item.pc.ar,
albumName: item.al.name, name: item.pc.sn,
albumId: item.al.id, albumName: item.pc.alb,
source: 'wy', albumId: item.al?.id,
interval: formatPlayTime(item.dt / 1000), source: 'wy',
songmid: item.id, interval: formatPlayTime(item.dt / 1000),
img: item.al.picUrl, songmid: item.id,
lrc: null, img: item.al?.picUrl ?? '',
otherSource: null, lrc: null,
types, otherSource: null,
_types, types,
typeUrl: {}, _types,
}) typeUrl: {},
})
} else {
list.push({
singer: this.getSinger(item.ar),
name: item.name,
albumName: item.al?.name,
albumId: item.al?.id,
source: 'wy',
interval: formatPlayTime(item.dt / 1000),
songmid: item.id,
img: item.al?.picUrl,
lrc: null,
otherSource: null,
types,
_types,
typeUrl: {},
})
}
}) })
return list return list
}, },