兼容打开咪咕移动端分享的歌单链接,添加打开歌单的信息显示
parent
1c585dc479
commit
af2e650538
|
@ -9,6 +9,7 @@
|
||||||
- 当设置-代理启用,但主机地址为空的时,将不再使用代理配置进行网络连接,并且在离开设置界面时自动禁用代理
|
- 当设置-代理启用,但主机地址为空的时,将不再使用代理配置进行网络连接,并且在离开设置界面时自动禁用代理
|
||||||
- 优化歌曲自动换源匹配
|
- 优化歌曲自动换源匹配
|
||||||
- 分离歌词与歌曲列表信息的保存,以减小列表列表文件损坏的几率
|
- 分离歌词与歌曲列表信息的保存,以减小列表列表文件损坏的几率
|
||||||
|
- 兼容打开咪咕移动端分享的歌单链接,添加打开歌单的信息显示
|
||||||
|
|
||||||
### 修复
|
### 修复
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,11 @@ export default {
|
||||||
_requestObj_tags: null,
|
_requestObj_tags: null,
|
||||||
_requestObj_list: null,
|
_requestObj_list: null,
|
||||||
_requestObj_listDetail: null,
|
_requestObj_listDetail: null,
|
||||||
|
_requestObj_listDetailInfo: null,
|
||||||
limit_list: 10,
|
limit_list: 10,
|
||||||
limit_song: 10000,
|
limit_song: 10000,
|
||||||
successCode: '000000',
|
successCode: '000000',
|
||||||
|
cachedDetailInfo: {},
|
||||||
sortList: [
|
sortList: [
|
||||||
{
|
{
|
||||||
name: '推荐',
|
name: '推荐',
|
||||||
|
@ -66,11 +68,14 @@ export default {
|
||||||
return num
|
return num
|
||||||
},
|
},
|
||||||
|
|
||||||
getListDetail(id, page, tryNum = 0) { // 获取歌曲列表内的音乐
|
getListDetailList(id, page, tryNum = 0) {
|
||||||
if (this._requestObj_listDetail) this._requestObj_listDetail.cancelHttp()
|
if (this._requestObj_listDetail) this._requestObj_listDetail.cancelHttp()
|
||||||
if (tryNum > 2) return Promise.reject(new Error('try max num'))
|
if (tryNum > 2) return Promise.reject(new Error('try max num'))
|
||||||
|
// https://h5.nf.migu.cn/app/v4/p/share/playlist/index.html?id=184187437&channel=0146921
|
||||||
|
|
||||||
if ((/[?&:/]/.test(id))) id = id.replace(this.regExps.listDetailLink, '$1')
|
if (/playlist\/index\.html\?/.test(id)) {
|
||||||
|
id = id.replace(/.*(?:\?|&)id=(\d+)(?:&.*|$)/, '$1')
|
||||||
|
} else if ((/[?&:/]/.test(id))) id = id.replace(this.regExps.listDetailLink, '$1')
|
||||||
|
|
||||||
this._requestObj_listDetail = httpFetch(this.getSongListDetailUrl(id, page), { headers: this.defaultHeaders })
|
this._requestObj_listDetail = httpFetch(this.getSongListDetailUrl(id, page), { headers: this.defaultHeaders })
|
||||||
return this._requestObj_listDetail.promise.then(({ body }) => {
|
return this._requestObj_listDetail.promise.then(({ body }) => {
|
||||||
|
@ -83,16 +88,47 @@ export default {
|
||||||
limit: this.limit_song,
|
limit: this.limit_song,
|
||||||
total: body.totalCount,
|
total: body.totalCount,
|
||||||
source: 'mg',
|
source: 'mg',
|
||||||
// info: {
|
|
||||||
// // name: body.result.info.list_title,
|
|
||||||
// // img: body.result.info.list_pic,
|
|
||||||
// // desc: body.result.info.list_desc,
|
|
||||||
// // author: body.result.info.userinfo.username,
|
|
||||||
// // play_count: this.formatPlayCount(body.result.listen_num),
|
|
||||||
// },
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getListDetailInfo(id, tryNum = 0) {
|
||||||
|
if (this._requestObj_listDetailInfo) this._requestObj_listDetailInfo.cancelHttp()
|
||||||
|
if (tryNum > 2) return Promise.reject(new Error('try max num'))
|
||||||
|
|
||||||
|
if (this.cachedDetailInfo[id]) return Promise.resolve(this.cachedDetailInfo[id])
|
||||||
|
this._requestObj_listDetailInfo = httpFetch(`https://c.musicapp.migu.cn/MIGUM3.0/resource/playlist/v2.0?playlistId=${id}`, {
|
||||||
|
headers: this.defaultHeaders,
|
||||||
|
})
|
||||||
|
return this._requestObj_listDetailInfo.promise.then(({ body }) => {
|
||||||
|
if (body.code !== this.successCode) return this.getListDetail(id, ++tryNum)
|
||||||
|
// console.log(JSON.stringify(body))
|
||||||
|
// console.log(body)
|
||||||
|
const cachedDetailInfo = this.cachedDetailInfo[id] = {
|
||||||
|
name: body.data.title,
|
||||||
|
img: body.data.imgItem.img,
|
||||||
|
desc: body.data.summary,
|
||||||
|
author: body.data.ownerName,
|
||||||
|
play_count: this.formatPlayCount(body.data.opNumItem.playNum),
|
||||||
|
}
|
||||||
|
return cachedDetailInfo
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
getListDetail(id, page) { // 获取歌曲列表内的音乐
|
||||||
|
// https://h5.nf.migu.cn/app/v4/p/share/playlist/index.html?id=184187437&channel=0146921
|
||||||
|
if (/playlist\/index\.html\?/.test(id)) {
|
||||||
|
id = id.replace(/.*(?:\?|&)id=(\d+)(?:&.*|$)/, '$1')
|
||||||
|
} else if ((/[?&:/]/.test(id))) id = id.replace(this.regExps.listDetailLink, '$1')
|
||||||
|
|
||||||
|
return Promise.all([
|
||||||
|
this.getListDetailList(id, page),
|
||||||
|
this.getListDetailInfo(id),
|
||||||
|
]).then(([listData, info]) => {
|
||||||
|
listData.info = info
|
||||||
|
return listData
|
||||||
|
})
|
||||||
|
},
|
||||||
filterListDetail(rawList) {
|
filterListDetail(rawList) {
|
||||||
// console.log(rawList)
|
// console.log(rawList)
|
||||||
let ids = new Set()
|
let ids = new Set()
|
||||||
|
|
|
@ -419,10 +419,11 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async addSongListDetail() {
|
async addSongListDetail() {
|
||||||
if (!this.listDetail.info.name) return
|
// console.log(this.listDetail.info)
|
||||||
|
// if (!this.listDetail.info.name) return
|
||||||
const list = await this.fetchList()
|
const list = await this.fetchList()
|
||||||
this.createUserList({
|
this.createUserList({
|
||||||
name: this.listDetail.info.name,
|
name: this.listDetail.info.name || `${this.listDetail.source}-list`,
|
||||||
id: `${this.listDetail.source}__${this.listDetail.id}`,
|
id: `${this.listDetail.source}__${this.listDetail.id}`,
|
||||||
list,
|
list,
|
||||||
source: this.listDetail.source,
|
source: this.listDetail.source,
|
||||||
|
|
Loading…
Reference in New Issue