修复歌单地址无效时无限重复请求的bug

pull/96/head
lyswhut 2019-10-18 17:46:33 +08:00
parent f81715f07f
commit 76b796bde7
8 changed files with 81 additions and 54 deletions

View File

@ -2,8 +2,8 @@
- 新增网易云源歌曲搜索 - 新增网易云源歌曲搜索
- 新增网易云源歌单 - 新增网易云源歌单
- 新增各平台通过输入歌单链接或歌单ID打开歌单详情列表目前只适配了网页版歌单链接其他方式的歌单链接可能无法解析但你可想办法获取歌单ID后输入打开。注各平台歌单ID均为纯数字 - 新增各平台通过输入歌单链接或歌单ID打开歌单详情列表目前只适配了**网页版歌单链接**其他方式的歌单链接可能无法解析但你可想办法获取歌单ID后输入打开。注各平台歌单ID均为纯数字若遇到链接里存在歌单ID但无法解析的歌单链接可以到GitHub提交issue或发送邮件或加群830125506反馈
- 新增音量调整滑动功能,现在支持鼠标按下左右拖动调整音量了 - 新增音量调整滑动功能,现在支持鼠标左右拖动调整音量了
#### 优化 #### 优化

View File

@ -108,11 +108,12 @@ export default {
}, },
// 获取标签 // 获取标签
getTags() { getTags(tryNum = 0) {
if (this._requestObj_tags) this._requestObj_tags.cancelHttp() if (this._requestObj_tags) this._requestObj_tags.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_tags = httpFetch(this.getTagsUrl()) this._requestObj_tags = httpFetch(this.getTagsUrl())
return this._requestObj_tags.promise.then(({ body }) => { return this._requestObj_tags.promise.then(({ body }) => {
if (body.error_code !== this.successCode) return this.getTags() if (body.error_code !== this.successCode) return this.getTags(++tryNum)
return { return {
hotTag: this.filterInfoHotTag(body.result.hot), hotTag: this.filterInfoHotTag(body.result.hot),
tags: this.filterTagInfo(body.result.tags), tags: this.filterTagInfo(body.result.tags),
@ -141,13 +142,14 @@ export default {
}, },
// 获取列表数据 // 获取列表数据
getList(sortId, tagId, page) { getList(sortId, tagId, page, tryNum = 0) {
if (this._requestObj_list) this._requestObj_list.cancelHttp() if (this._requestObj_list) this._requestObj_list.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_list = httpFetch( this._requestObj_list = httpFetch(
this.getListUrl(sortId, tagId, page) this.getListUrl(sortId, tagId, page)
) )
return this._requestObj_list.promise.then(({ body }) => { return this._requestObj_list.promise.then(({ body }) => {
// if (body.error_code !== this.successCode) return this.getList(sortId, tagId, page) if (body.error_code !== this.successCode) return this.getList(sortId, tagId, page, ++tryNum)
return { return {
list: this.filterList(body.diyInfo), list: this.filterList(body.diyInfo),
total: body.nums, total: body.nums,
@ -183,13 +185,14 @@ export default {
}, },
// 获取歌曲列表内的音乐 // 获取歌曲列表内的音乐
getListDetail(id, page) { getListDetail(id, page, tryNum = 0) {
if (this._requestObj_listDetail) { if (this._requestObj_listDetail) {
this._requestObj_listDetail.cancelHttp() this._requestObj_listDetail.cancelHttp()
} }
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_listDetail = httpFetch(this.getListDetailUrl(id, page)) this._requestObj_listDetail = httpFetch(this.getListDetailUrl(id, page))
return this._requestObj_listDetail.promise.then(({ body }) => { return this._requestObj_listDetail.promise.then(({ body }) => {
if (body.error_code !== this.successCode) return this.getListDetail(id, page) if (body.error_code !== this.successCode) return this.getListDetail(id, page, ++tryNum)
let listData = this.filterData(body.result.songlist) let listData = this.filterData(body.result.songlist)
return { return {
list: listData, list: listData,

View File

@ -88,18 +88,20 @@ export default {
return result return result
}, },
getSongList(sortId, tagId, page) { getSongList(sortId, tagId, page, tryNum = 0) {
if (this._requestObj_list) this._requestObj_list.cancelHttp() if (this._requestObj_list) this._requestObj_list.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_list = httpFetch( this._requestObj_list = httpFetch(
this.getSongListUrl(sortId, tagId, page) this.getSongListUrl(sortId, tagId, page)
) )
return this._requestObj_list.promise.then(({ body }) => { return this._requestObj_list.promise.then(({ body }) => {
if (body.status !== 1) return this.getSongList(sortId, tagId, page) if (body.status !== 1) return this.getSongList(sortId, tagId, page, ++tryNum)
return this.filterList(body.special_db) return this.filterList(body.special_db)
}) })
}, },
getSongListRecommend() { getSongListRecommend(tryNum = 0) {
if (this._requestObj_listRecommend) this._requestObj_listRecommend.cancelHttp() if (this._requestObj_listRecommend) this._requestObj_listRecommend.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_listRecommend = httpFetch( this._requestObj_listRecommend = httpFetch(
'http://everydayrec.service.kugou.com/guess_special_recommend', 'http://everydayrec.service.kugou.com/guess_special_recommend',
{ {
@ -121,7 +123,7 @@ export default {
} }
) )
return this._requestObj_listRecommend.promise.then(({ body }) => { return this._requestObj_listRecommend.promise.then(({ body }) => {
if (body.status !== 1) return this.getSongListRecommend() if (body.status !== 1) return this.getSongListRecommend(++tryNum)
return this.filterList(body.data.special_list) return this.filterList(body.data.special_list)
}) })
}, },
@ -139,13 +141,15 @@ export default {
})) }))
}, },
getListDetail(id, page) { // 获取歌曲列表内的音乐 getListDetail(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'))
this._requestObj_listDetail = httpFetch(this.getSongListDetailUrl(id)) this._requestObj_listDetail = httpFetch(this.getSongListDetailUrl(id))
return this._requestObj_listDetail.promise.then(({ body }) => { return this._requestObj_listDetail.promise.then(({ body }) => {
let listData = body.match(this.regExps.listData) let listData = body.match(this.regExps.listData)
let listInfo = body.match(this.regExps.listInfo) let listInfo = body.match(this.regExps.listInfo)
if (listData) listData = this.filterData(JSON.parse(listData[1])) if (!listData) return this.getListDetail(id, page, ++tryNum)
listData = this.filterData(JSON.parse(listData[1]))
let name let name
let pic let pic
if (listInfo) { if (listInfo) {
@ -224,11 +228,12 @@ export default {
}, },
// 获取列表信息 // 获取列表信息
getListInfo(tagId) { getListInfo(tagId, tryNum = 0) {
if (this._requestObj_listInfo) this._requestObj_listInfo.cancelHttp() if (this._requestObj_listInfo) this._requestObj_listInfo.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_listInfo = httpFetch(this.getInfoUrl(tagId)) this._requestObj_listInfo = httpFetch(this.getInfoUrl(tagId))
return this._requestObj_listInfo.promise.then(({ body }) => { return this._requestObj_listInfo.promise.then(({ body }) => {
if (body.status !== 1) return this.getListInfo(tagId) if (body.status !== 1) return this.getListInfo(tagId, ++tryNum)
return { return {
limit: body.data.params.pagesize, limit: body.data.params.pagesize,
page: body.data.params.p, page: body.data.params.p,
@ -261,11 +266,12 @@ export default {
}, },
// 获取标签 // 获取标签
getTags() { getTags(tryNum = 0) {
if (this._requestObj_tags) this._requestObj_tags.cancelHttp() if (this._requestObj_tags) this._requestObj_tags.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_tags = httpFetch(this.getInfoUrl()) this._requestObj_tags = httpFetch(this.getInfoUrl())
return this._requestObj_tags.promise.then(({ body }) => { return this._requestObj_tags.promise.then(({ body }) => {
if (body.status !== 1) return this.getTags() if (body.status !== 1) return this.getTags(++tryNum)
return { return {
hotTag: this.filterInfoHotTag(body.data.hotTag), hotTag: this.filterInfoHotTag(body.data.hotTag),
tags: this.filterTagInfo(body.data.tagids), tags: this.filterTagInfo(body.data.tagids),

View File

@ -38,20 +38,22 @@ export default {
// http://nplserver.kuwo.cn/pl.svc?op=getlistinfo&pid=2849349915&pn=0&rn=100&encode=utf8&keyset=pl2012&identity=kuwo&pcmp4=1&vipver=MUSIC_9.0.5.0_W1&newver=1 // http://nplserver.kuwo.cn/pl.svc?op=getlistinfo&pid=2849349915&pn=0&rn=100&encode=utf8&keyset=pl2012&identity=kuwo&pcmp4=1&vipver=MUSIC_9.0.5.0_W1&newver=1
// 获取标签 // 获取标签
getTag() { getTag(tryNum = 0) {
if (this._requestObj_tags) this._requestObj_tags.cancelHttp() if (this._requestObj_tags) this._requestObj_tags.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_tags = httpFetch(this.tagsUrl) this._requestObj_tags = httpFetch(this.tagsUrl)
return this._requestObj_tags.promise.then(({ body }) => { return this._requestObj_tags.promise.then(({ body }) => {
if (body.code !== this.successCode) return this.getTag() if (body.code !== this.successCode) return this.getTag(++tryNum)
return this.filterTagInfo(body.data) return this.filterTagInfo(body.data)
}) })
}, },
// 获取标签 // 获取标签
getHotTag() { getHotTag(tryNum = 0) {
if (this._requestObj_hotTags) this._requestObj_hotTags.cancelHttp() if (this._requestObj_hotTags) this._requestObj_hotTags.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_hotTags = httpFetch(this.hotTagUrl) this._requestObj_hotTags = httpFetch(this.hotTagUrl)
return this._requestObj_hotTags.promise.then(({ body }) => { return this._requestObj_hotTags.promise.then(({ body }) => {
if (body.code !== this.successCode) return this.getHotTag() if (body.code !== this.successCode) return this.getHotTag(++tryNum)
return this.filterInfoHotTag(body.data[0].data) return this.filterInfoHotTag(body.data[0].data)
}) })
}, },
@ -76,8 +78,9 @@ export default {
}, },
// 获取列表数据 // 获取列表数据
getList(sortId, tagId, page) { getList(sortId, tagId, page, tryNum = 0) {
if (this._requestObj_list) this._requestObj_list.cancelHttp() if (this._requestObj_list) this._requestObj_list.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
let id let id
let type let type
if (tagId) { if (tagId) {
@ -90,7 +93,7 @@ export default {
this._requestObj_list = httpFetch(this.getListUrl({ sortId, id, type, page })) this._requestObj_list = httpFetch(this.getListUrl({ sortId, id, type, page }))
return this._requestObj_list.promise.then(({ body }) => { return this._requestObj_list.promise.then(({ body }) => {
if (!id || type == '10000') { if (!id || type == '10000') {
if (body.code !== this.successCode) return this.getListUrl({ sortId, id, type, page }) if (body.code !== this.successCode) return this.getList(sortId, id, type, page, ++tryNum)
return { return {
list: this.filterList(body.data.data), list: this.filterList(body.data.data),
total: body.data.total, total: body.data.total,
@ -99,7 +102,7 @@ export default {
source: 'kw', source: 'kw',
} }
} else if (!body.length) { } else if (!body.length) {
return this.getListUrl({ sortId, id, type, page }) return this.getList(sortId, id, type, page, ++tryNum)
} }
return { return {
list: this.filterList2(body), list: this.filterList2(body),
@ -153,13 +156,14 @@ export default {
}, },
// 获取歌曲列表内的音乐 // 获取歌曲列表内的音乐
getListDetail(id, page) { getListDetail(id, page, tryNum = 0) {
if (this._requestObj_listDetail) { if (this._requestObj_listDetail) {
this._requestObj_listDetail.cancelHttp() this._requestObj_listDetail.cancelHttp()
} }
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_listDetail = httpFetch(this.getListDetailUrl(id, page)) this._requestObj_listDetail = httpFetch(this.getListDetailUrl(id, page))
return this._requestObj_listDetail.promise.then(({ body }) => { return this._requestObj_listDetail.promise.then(({ body }) => {
if (body.result !== 'ok') return this.getListDetail(id, page) if (body.result !== 'ok') return this.getListDetail(id, page, ++tryNum)
return { return {
list: this.filterListDetail(body.musiclist), list: this.filterListDetail(body.musiclist),
page, page,

View File

@ -55,11 +55,12 @@ export default {
return num return num
}, },
getListDetail(id, page) { // 获取歌曲列表内的音乐 getListDetail(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'))
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 }) => {
if (body.code !== this.successCode) return this.getListDetail(id, page) if (body.code !== this.successCode) return this.getListDetail(id, page, ++tryNum)
// console.log(JSON.stringify(body)) // console.log(JSON.stringify(body))
return { return {
list: this.filterListDetail(body.list), list: this.filterListDetail(body.list),
@ -135,8 +136,9 @@ export default {
}, },
// 获取列表数据 // 获取列表数据
getList(sortId, tagId, page) { getList(sortId, tagId, page, tryNum = 0) {
if (this._requestObj_list) this._requestObj_list.cancelHttp() if (this._requestObj_list) this._requestObj_list.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_list = httpFetch(this.getSongListUrl(sortId, tagId, page)) this._requestObj_list = httpFetch(this.getSongListUrl(sortId, tagId, page))
// return this._requestObj_list.promise.then(({ statusCode, body }) => { // return this._requestObj_list.promise.then(({ statusCode, body }) => {
// if (statusCode !== 200) return this.getList(sortId, tagId, page) // if (statusCode !== 200) return this.getList(sortId, tagId, page)
@ -158,7 +160,7 @@ export default {
// }) // })
// }) // })
return this._requestObj_list.promise.then(({ body }) => { return this._requestObj_list.promise.then(({ body }) => {
if (body.retCode !== '100000' || body.retMsg.code !== this.successCode) return this.getList(sortId, tagId, page) if (body.retCode !== '100000' || body.retMsg.code !== this.successCode) return this.getList(sortId, tagId, page, ++tryNum)
return { return {
list: this.filterList(body.retMsg.playlist), list: this.filterList(body.retMsg.playlist),
total: parseInt(body.retMsg.countSize), total: parseInt(body.retMsg.countSize),
@ -183,11 +185,12 @@ export default {
}, },
// 获取标签 // 获取标签
getTag() { getTag(tryNum = 0) {
if (this._requestObj_tags) this._requestObj_tags.cancelHttp() if (this._requestObj_tags) this._requestObj_tags.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_tags = httpFetch(this.tagsUrl, { headers: this.defaultHeaders }) this._requestObj_tags = httpFetch(this.tagsUrl, { headers: this.defaultHeaders })
return this._requestObj_tags.promise.then(({ body }) => { return this._requestObj_tags.promise.then(({ body }) => {
if (body.code !== this.successCode) return this.getTag() if (body.code !== this.successCode) return this.getTag(++tryNum)
return this.filterTagInfo(body.columnInfo.contents) return this.filterTagInfo(body.columnInfo.contents)
}) })
}, },

View File

@ -56,20 +56,22 @@ export default {
// http://nplserver.kuwo.cn/pl.svc?op=getlistinfo&pid=2849349915&pn=0&rn=100&encode=utf8&keyset=pl2012&identity=kuwo&pcmp4=1&vipver=MUSIC_9.0.5.0_W1&newver=1 // http://nplserver.kuwo.cn/pl.svc?op=getlistinfo&pid=2849349915&pn=0&rn=100&encode=utf8&keyset=pl2012&identity=kuwo&pcmp4=1&vipver=MUSIC_9.0.5.0_W1&newver=1
// 获取标签 // 获取标签
getTag() { getTag(tryNum = 0) {
if (this._requestObj_tags) this._requestObj_tags.cancelHttp() if (this._requestObj_tags) this._requestObj_tags.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_tags = httpFetch(this.tagsUrl) this._requestObj_tags = httpFetch(this.tagsUrl)
return this._requestObj_tags.promise.then(({ body }) => { return this._requestObj_tags.promise.then(({ body }) => {
if (body.code !== this.successCode) return this.getTag() if (body.code !== this.successCode) return this.getTag(++tryNum)
return this.filterTagInfo(body.tags.data.v_group) return this.filterTagInfo(body.tags.data.v_group)
}) })
}, },
// 获取标签 // 获取标签
getHotTag() { getHotTag(tryNum = 0) {
if (this._requestObj_hotTags) this._requestObj_hotTags.cancelHttp() if (this._requestObj_hotTags) this._requestObj_hotTags.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_hotTags = httpFetch(this.hotTagUrl) this._requestObj_hotTags = httpFetch(this.hotTagUrl)
return this._requestObj_hotTags.promise.then(({ statusCode, body }) => { return this._requestObj_hotTags.promise.then(({ statusCode, body }) => {
if (statusCode !== 200) return this.getHotTag() if (statusCode !== 200) return this.getHotTag(++tryNum)
return this.filterInfoHotTag(body) return this.filterInfoHotTag(body)
}) })
}, },
@ -103,13 +105,14 @@ export default {
}, },
// 获取列表数据 // 获取列表数据
getList(sortId, tagId, page) { getList(sortId, tagId, page, tryNum = 0) {
if (this._requestObj_list) this._requestObj_list.cancelHttp() if (this._requestObj_list) this._requestObj_list.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_list = httpFetch( this._requestObj_list = httpFetch(
this.getListUrl(sortId, tagId, page) this.getListUrl(sortId, tagId, page)
) )
return this._requestObj_list.promise.then(({ body }) => { return this._requestObj_list.promise.then(({ body }) => {
if (body.code !== this.successCode) return this.getList(sortId, tagId, page) if (body.code !== this.successCode) return this.getList(sortId, tagId, page, ++tryNum)
return tagId ? this.filterList2(body.playlist.data, page) : this.filterList(body.playlist.data, page) return tagId ? this.filterList2(body.playlist.data, page) : this.filterList(body.playlist.data, page)
}) })
}, },
@ -165,10 +168,11 @@ export default {
}, },
// 获取歌曲列表内的音乐 // 获取歌曲列表内的音乐
getListDetail(id) { getListDetail(id, tryNum = 0) {
if (this._requestObj_listDetail) { if (this._requestObj_listDetail) {
this._requestObj_listDetail.cancelHttp() this._requestObj_listDetail.cancelHttp()
} }
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_listDetail = httpFetch(this.getListDetailUrl(id), { this._requestObj_listDetail = httpFetch(this.getListDetailUrl(id), {
headers: { headers: {
Origin: 'https://y.qq.com', Origin: 'https://y.qq.com',
@ -176,7 +180,7 @@ export default {
}, },
}) })
return this._requestObj_listDetail.promise.then(({ body }) => { return this._requestObj_listDetail.promise.then(({ body }) => {
if (body.code !== this.successCode) return this.getListDetail(id) if (body.code !== this.successCode) return this.getListDetail(id, ++tryNum)
const cdlist = body.cdlist[0] const cdlist = body.cdlist[0]
return { return {
list: this.filterListDetail(cdlist.songlist), list: this.filterListDetail(cdlist.songlist),

View File

@ -42,8 +42,9 @@ export default {
return arr.join('、') return arr.join('、')
}, },
getListDetail(id, page) { // 获取歌曲列表内的音乐 getListDetail(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'))
this._requestObj_listDetail = httpFetch('https://music.163.com/api/linux/forward', { this._requestObj_listDetail = httpFetch('https://music.163.com/api/linux/forward', {
method: 'post', method: 'post',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',
@ -58,7 +59,7 @@ export default {
}), }),
}) })
return this._requestObj_listDetail.promise.then(({ body }) => { return this._requestObj_listDetail.promise.then(({ body }) => {
if (body.code !== this.successCode) return this.getListDetail(id, page) if (body.code !== this.successCode) return this.getListDetail(id, page, ++tryNum)
return { return {
list: this.filterListDetail(body), list: this.filterListDetail(body),
page, page,
@ -132,7 +133,8 @@ export default {
}, },
// 获取列表数据 // 获取列表数据
getList(sortId, tagId, page) { getList(sortId, tagId, page, tryNum = 0) {
if (tryNum > 2) return Promise.reject(new Error('try max num'))
if (this._requestObj_list) this._requestObj_list.cancelHttp() if (this._requestObj_list) this._requestObj_list.cancelHttp()
this._requestObj_list = httpFetch('https://music.163.com/weapi/playlist/list', { this._requestObj_list = httpFetch('https://music.163.com/weapi/playlist/list', {
method: 'post', method: 'post',
@ -146,7 +148,7 @@ export default {
}) })
return this._requestObj_list.promise.then(({ body }) => { return this._requestObj_list.promise.then(({ body }) => {
// console.log(JSON.stringify(body)) // console.log(JSON.stringify(body))
if (body.code !== this.successCode) return this.getList(sortId, tagId, page) if (body.code !== this.successCode) return this.getList(sortId, tagId, page, ++tryNum)
return { return {
list: this.filterList(body.playlists), list: this.filterList(body.playlists),
total: parseInt(body.total), total: parseInt(body.total),
@ -171,15 +173,16 @@ export default {
}, },
// 获取标签 // 获取标签
getTag() { getTag(tryNum = 0) {
if (this._requestObj_tags) this._requestObj_tags.cancelHttp() if (this._requestObj_tags) this._requestObj_tags.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_tags = httpFetch('https://music.163.com/weapi/playlist/catalogue', { this._requestObj_tags = httpFetch('https://music.163.com/weapi/playlist/catalogue', {
method: 'post', method: 'post',
form: weapi({}), form: weapi({}),
}) })
return this._requestObj_tags.promise.then(({ body }) => { return this._requestObj_tags.promise.then(({ body }) => {
// console.log(JSON.stringify(body)) // console.log(JSON.stringify(body))
if (body.code !== this.successCode) return this.getTag() if (body.code !== this.successCode) return this.getTag(++tryNum)
return this.filterTagInfo(body) return this.filterTagInfo(body)
}) })
}, },
@ -208,15 +211,16 @@ export default {
}, },
// 获取热门标签 // 获取热门标签
getHotTag() { getHotTag(tryNum = 0) {
if (this._requestObj_hotTags) this._requestObj_hotTags.cancelHttp() if (this._requestObj_hotTags) this._requestObj_hotTags.cancelHttp()
if (tryNum > 2) return Promise.reject(new Error('try max num'))
this._requestObj_hotTags = httpFetch('https://music.163.com/weapi/playlist/hottags', { this._requestObj_hotTags = httpFetch('https://music.163.com/weapi/playlist/hottags', {
method: 'post', method: 'post',
form: weapi({}), form: weapi({}),
}) })
return this._requestObj_hotTags.promise.then(({ body }) => { return this._requestObj_hotTags.promise.then(({ body }) => {
// console.log(JSON.stringify(body)) // console.log(JSON.stringify(body))
if (body.code !== this.successCode) return this.getTag() if (body.code !== this.successCode) return this.getTag(++tryNum)
return this.filterHotTagInfo(body.tags) return this.filterHotTagInfo(body.tags)
}) })
}, },

View File

@ -284,12 +284,12 @@ export default {
this.handleGetSongListDetail() this.handleGetSongListDetail()
break break
case 'blur': case 'blur':
this.handleParseImportSongListInputText() this.parseImportSongListInputText()
break break
} }
}, },
handleGetSongListDetail() { handleGetSongListDetail() {
this.handleParseImportSongListInputText() this.parseImportSongListInputText()
this.setSelectListInfo({ this.setSelectListInfo({
play_count: null, play_count: null,
id: this.importSongListText, id: this.importSongListText,
@ -305,15 +305,18 @@ export default {
this.getListDetail({ id: this.importSongListText, page: 1 }) this.getListDetail({ id: this.importSongListText, page: 1 })
}) })
}, },
handleParseImportSongListInputText() { parseImportSongListInputText() {
if (!/[?&:/]/.test(this.importSongListText)) return if (!/[?&:/]/.test(this.importSongListText)) return
const text = this.importSongListText
let regx let regx
switch (this.source) { switch (this.source) {
case 'wy': case 'wy':
regx = /^.+(?:\?|&)id=(\d+)(?:&.*$|#.*$|$)/ regx = /^.+(?:\?|&)id=(\d+)(?:&.*$|#.*$|$)/
break break
case 'tx': case 'tx':
regx = /^.+\/(\d+)\.html(?:\?.*|&.*$|#.*$|$)/ // https://y.qq.com/n/yqq/playlist/7217720898.html
// https://i.y.qq.com/n2/m/share/details/taoge.html?platform=11&appshare=android_qq&appversion=9050006&id=7217720898&ADTAG=qfshare
regx = /\/\/i\.y\.qq\.com/.test(text) ? /^.+(?:\?|&)id=(\d+)(?:&.*$|#.*$|$)/ : /^.+\/(\d+)\.html(?:\?.*|&.*$|#.*$|$)/
break break
case 'kw': case 'kw':
// http://www.kuwo.cn/playlist_detail/2886046289 // http://www.kuwo.cn/playlist_detail/2886046289
@ -334,7 +337,7 @@ export default {
default: default:
return return
} }
this.importSongListText = this.importSongListText.replace(regx, '$1') this.importSongListText = text.replace(regx, '$1')
}, },
}, },
} }