From 76b796bde7b90b624781cf96393b37a7b7007ba6 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Fri, 18 Oct 2019 17:46:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=AD=8C=E5=8D=95=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E6=97=A0=E6=95=88=E6=97=B6=E6=97=A0=E9=99=90=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E8=AF=B7=E6=B1=82=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 4 ++-- src/renderer/utils/music/bd/songList.js | 15 ++++++++------ src/renderer/utils/music/kg/songList.js | 26 +++++++++++++++---------- src/renderer/utils/music/kw/songList.js | 22 ++++++++++++--------- src/renderer/utils/music/mg/songList.js | 15 ++++++++------ src/renderer/utils/music/tx/songList.js | 20 +++++++++++-------- src/renderer/utils/music/wy/songList.js | 20 +++++++++++-------- src/renderer/views/SongList.vue | 13 ++++++++----- 8 files changed, 81 insertions(+), 54 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 44e169fa..849b98b4 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -2,8 +2,8 @@ - 新增网易云源歌曲搜索 - 新增网易云源歌单 -- 新增各平台通过输入歌单链接或歌单ID打开歌单详情列表,目前只适配了网页版歌单链接,其他方式的歌单链接可能无法解析,但你可想办法获取歌单ID后输入打开。注:各平台歌单ID均为纯数字 -- 新增音量调整滑动功能,现在支持鼠标按下左右拖动调整音量了 +- 新增各平台通过输入歌单链接或歌单ID打开歌单详情列表,目前只适配了**网页版歌单链接**,其他方式的歌单链接可能无法解析,但你可想办法获取歌单ID后输入打开。注:各平台歌单ID均为纯数字,若遇到链接里存在歌单ID但无法解析的歌单链接,可以到GitHub提交issue或发送邮件或加群830125506反馈! +- 新增音量调整滑动功能,现在支持鼠标左右拖动调整音量了 #### 优化 diff --git a/src/renderer/utils/music/bd/songList.js b/src/renderer/utils/music/bd/songList.js index ab5ff4a1..04d8d1a0 100644 --- a/src/renderer/utils/music/bd/songList.js +++ b/src/renderer/utils/music/bd/songList.js @@ -108,11 +108,12 @@ export default { }, // 获取标签 - getTags() { + getTags(tryNum = 0) { 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()) 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 { hotTag: this.filterInfoHotTag(body.result.hot), 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 (tryNum > 2) return Promise.reject(new Error('try max num')) this._requestObj_list = httpFetch( this.getListUrl(sortId, tagId, page) ) 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 { list: this.filterList(body.diyInfo), total: body.nums, @@ -183,13 +185,14 @@ export default { }, // 获取歌曲列表内的音乐 - getListDetail(id, page) { + getListDetail(id, page, tryNum = 0) { if (this._requestObj_listDetail) { this._requestObj_listDetail.cancelHttp() } + if (tryNum > 2) return Promise.reject(new Error('try max num')) this._requestObj_listDetail = httpFetch(this.getListDetailUrl(id, page)) 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) return { list: listData, diff --git a/src/renderer/utils/music/kg/songList.js b/src/renderer/utils/music/kg/songList.js index 47119a0b..9eece9b4 100644 --- a/src/renderer/utils/music/kg/songList.js +++ b/src/renderer/utils/music/kg/songList.js @@ -88,18 +88,20 @@ export default { return result }, - getSongList(sortId, tagId, page) { + getSongList(sortId, tagId, page, tryNum = 0) { 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) ) 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) }) }, - getSongListRecommend() { + getSongListRecommend(tryNum = 0) { if (this._requestObj_listRecommend) this._requestObj_listRecommend.cancelHttp() + if (tryNum > 2) return Promise.reject(new Error('try max num')) this._requestObj_listRecommend = httpFetch( 'http://everydayrec.service.kugou.com/guess_special_recommend', { @@ -121,7 +123,7 @@ export default { } ) 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) }) }, @@ -139,13 +141,15 @@ export default { })) }, - getListDetail(id, page) { // 获取歌曲列表内的音乐 + getListDetail(id, page, tryNum = 0) { // 获取歌曲列表内的音乐 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)) return this._requestObj_listDetail.promise.then(({ body }) => { let listData = body.match(this.regExps.listData) 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 pic if (listInfo) { @@ -224,11 +228,12 @@ export default { }, // 获取列表信息 - getListInfo(tagId) { + getListInfo(tagId, tryNum = 0) { 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)) 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 { limit: body.data.params.pagesize, page: body.data.params.p, @@ -261,11 +266,12 @@ export default { }, // 获取标签 - getTags() { + getTags(tryNum = 0) { 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()) return this._requestObj_tags.promise.then(({ body }) => { - if (body.status !== 1) return this.getTags() + if (body.status !== 1) return this.getTags(++tryNum) return { hotTag: this.filterInfoHotTag(body.data.hotTag), tags: this.filterTagInfo(body.data.tagids), diff --git a/src/renderer/utils/music/kw/songList.js b/src/renderer/utils/music/kw/songList.js index 2101f6d3..94d1dd77 100644 --- a/src/renderer/utils/music/kw/songList.js +++ b/src/renderer/utils/music/kw/songList.js @@ -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 // 获取标签 - getTag() { + getTag(tryNum = 0) { 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) 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) }) }, // 获取标签 - getHotTag() { + getHotTag(tryNum = 0) { 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) 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) }) }, @@ -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 (tryNum > 2) return Promise.reject(new Error('try max num')) let id let type if (tagId) { @@ -90,7 +93,7 @@ export default { this._requestObj_list = httpFetch(this.getListUrl({ sortId, id, type, page })) return this._requestObj_list.promise.then(({ body }) => { 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 { list: this.filterList(body.data.data), total: body.data.total, @@ -99,7 +102,7 @@ export default { source: 'kw', } } else if (!body.length) { - return this.getListUrl({ sortId, id, type, page }) + return this.getList(sortId, id, type, page, ++tryNum) } return { list: this.filterList2(body), @@ -153,13 +156,14 @@ export default { }, // 获取歌曲列表内的音乐 - getListDetail(id, page) { + getListDetail(id, page, tryNum = 0) { if (this._requestObj_listDetail) { this._requestObj_listDetail.cancelHttp() } + if (tryNum > 2) return Promise.reject(new Error('try max num')) this._requestObj_listDetail = httpFetch(this.getListDetailUrl(id, page)) 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 { list: this.filterListDetail(body.musiclist), page, diff --git a/src/renderer/utils/music/mg/songList.js b/src/renderer/utils/music/mg/songList.js index 3910da97..b4744d09 100644 --- a/src/renderer/utils/music/mg/songList.js +++ b/src/renderer/utils/music/mg/songList.js @@ -55,11 +55,12 @@ export default { return num }, - getListDetail(id, page) { // 获取歌曲列表内的音乐 + getListDetail(id, page, tryNum = 0) { // 获取歌曲列表内的音乐 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 }) 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)) return { 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 (tryNum > 2) return Promise.reject(new Error('try max num')) this._requestObj_list = httpFetch(this.getSongListUrl(sortId, tagId, page)) // return this._requestObj_list.promise.then(({ statusCode, body }) => { // if (statusCode !== 200) return this.getList(sortId, tagId, page) @@ -158,7 +160,7 @@ export default { // }) // }) 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 { list: this.filterList(body.retMsg.playlist), total: parseInt(body.retMsg.countSize), @@ -183,11 +185,12 @@ export default { }, // 获取标签 - getTag() { + getTag(tryNum = 0) { 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 }) 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) }) }, diff --git a/src/renderer/utils/music/tx/songList.js b/src/renderer/utils/music/tx/songList.js index 6c0b9e64..ddd8ac9d 100644 --- a/src/renderer/utils/music/tx/songList.js +++ b/src/renderer/utils/music/tx/songList.js @@ -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 // 获取标签 - getTag() { + getTag(tryNum = 0) { 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) 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) }) }, // 获取标签 - getHotTag() { + getHotTag(tryNum = 0) { 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) 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) }) }, @@ -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 (tryNum > 2) return Promise.reject(new Error('try max num')) this._requestObj_list = httpFetch( this.getListUrl(sortId, tagId, page) ) 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) }) }, @@ -165,10 +168,11 @@ export default { }, // 获取歌曲列表内的音乐 - getListDetail(id) { + getListDetail(id, tryNum = 0) { if (this._requestObj_listDetail) { this._requestObj_listDetail.cancelHttp() } + if (tryNum > 2) return Promise.reject(new Error('try max num')) this._requestObj_listDetail = httpFetch(this.getListDetailUrl(id), { headers: { Origin: 'https://y.qq.com', @@ -176,7 +180,7 @@ export default { }, }) 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] return { list: this.filterListDetail(cdlist.songlist), diff --git a/src/renderer/utils/music/wy/songList.js b/src/renderer/utils/music/wy/songList.js index 5ab652d0..ea1f4fbf 100644 --- a/src/renderer/utils/music/wy/songList.js +++ b/src/renderer/utils/music/wy/songList.js @@ -42,8 +42,9 @@ export default { return arr.join('、') }, - getListDetail(id, page) { // 获取歌曲列表内的音乐 + getListDetail(id, page, tryNum = 0) { // 获取歌曲列表内的音乐 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', { 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', @@ -58,7 +59,7 @@ export default { }), }) 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 { list: this.filterListDetail(body), 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() this._requestObj_list = httpFetch('https://music.163.com/weapi/playlist/list', { method: 'post', @@ -146,7 +148,7 @@ export default { }) return this._requestObj_list.promise.then(({ 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 { list: this.filterList(body.playlists), total: parseInt(body.total), @@ -171,15 +173,16 @@ export default { }, // 获取标签 - getTag() { + getTag(tryNum = 0) { 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', { method: 'post', form: weapi({}), }) return this._requestObj_tags.promise.then(({ 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) }) }, @@ -208,15 +211,16 @@ export default { }, // 获取热门标签 - getHotTag() { + getHotTag(tryNum = 0) { 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', { method: 'post', form: weapi({}), }) return this._requestObj_hotTags.promise.then(({ 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) }) }, diff --git a/src/renderer/views/SongList.vue b/src/renderer/views/SongList.vue index 374684a4..94589418 100644 --- a/src/renderer/views/SongList.vue +++ b/src/renderer/views/SongList.vue @@ -284,12 +284,12 @@ export default { this.handleGetSongListDetail() break case 'blur': - this.handleParseImportSongListInputText() + this.parseImportSongListInputText() break } }, handleGetSongListDetail() { - this.handleParseImportSongListInputText() + this.parseImportSongListInputText() this.setSelectListInfo({ play_count: null, id: this.importSongListText, @@ -305,15 +305,18 @@ export default { this.getListDetail({ id: this.importSongListText, page: 1 }) }) }, - handleParseImportSongListInputText() { + parseImportSongListInputText() { if (!/[?&:/]/.test(this.importSongListText)) return + const text = this.importSongListText let regx switch (this.source) { case 'wy': regx = /^.+(?:\?|&)id=(\d+)(?:&.*$|#.*$|$)/ break 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 case 'kw': // http://www.kuwo.cn/playlist_detail/2886046289 @@ -334,7 +337,7 @@ export default { default: return } - this.importSongListText = this.importSongListText.replace(regx, '$1') + this.importSongListText = text.replace(regx, '$1') }, }, }