From c7e95c5166539d82fd07ff8f6c3c7fae073f7e44 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Thu, 17 Oct 2019 17:01:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=90=84=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E8=BE=93=E5=85=A5=E6=AD=8C=E5=8D=95=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E6=88=96=E6=AD=8C=E5=8D=95ID=E6=89=93=E5=BC=80?= =?UTF-8?q?=E6=AD=8C=E5=8D=95=E8=AF=A6=E6=83=85=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 1 + src/renderer/utils/music/bd/songList.js | 7 ++++++ src/renderer/utils/music/kg/songList.js | 17 ++++++++++++++- src/renderer/utils/music/kw/songList.js | 7 ++++++ src/renderer/utils/music/mg/songList.js | 8 +++++++ src/renderer/views/SongList.vue | 29 ++++++++++++++++++++----- 6 files changed, 63 insertions(+), 6 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 84ac2ca4..1621e247 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -2,6 +2,7 @@ - 新增网易云源歌曲搜索 - 新增网易云源歌单 +- 新增各平台通过输入歌单链接或歌单ID打开歌单详情列表 #### 优化 diff --git a/src/renderer/utils/music/bd/songList.js b/src/renderer/utils/music/bd/songList.js index f96a4686..ab5ff4a1 100644 --- a/src/renderer/utils/music/bd/songList.js +++ b/src/renderer/utils/music/bd/songList.js @@ -197,6 +197,13 @@ export default { limit: this.limit_song, total: body.result.song_num, source: 'bd', + 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), + }, } }) }, diff --git a/src/renderer/utils/music/kg/songList.js b/src/renderer/utils/music/kg/songList.js index bd46d197..47119a0b 100644 --- a/src/renderer/utils/music/kg/songList.js +++ b/src/renderer/utils/music/kg/songList.js @@ -35,6 +35,7 @@ export default { ], regExps: { listData: /global\.data = (\[.+\]);/, + listInfo: /global = {[\s\S]+?name: "(.+)"[\s\S]+?pic: "(.+)"[\s\S]+?};/, }, getInfoUrl(tagId) { return tagId @@ -143,13 +144,27 @@ export default { this._requestObj_listDetail = httpFetch(this.getSongListDetailUrl(id)) return this._requestObj_listDetail.promise.then(({ body }) => { let listData = body.match(this.regExps.listData) - if (listData) listData = this.filterData(JSON.parse(RegExp.$1)) + let listInfo = body.match(this.regExps.listInfo) + if (listData) listData = this.filterData(JSON.parse(listData[1])) + let name + let pic + if (listInfo) { + name = listInfo[1] + pic = listInfo[2] + } return { list: listData, page: 1, limit: 10000, total: listData.length, source: 'kg', + info: { + name, + img: pic, + // desc: body.result.info.list_desc, + // author: body.result.info.userinfo.username, + // play_count: this.formatPlayCount(body.result.listen_num), + }, } }) }, diff --git a/src/renderer/utils/music/kw/songList.js b/src/renderer/utils/music/kw/songList.js index 5559d1fe..2101f6d3 100644 --- a/src/renderer/utils/music/kw/songList.js +++ b/src/renderer/utils/music/kw/songList.js @@ -166,6 +166,13 @@ export default { limit: body.rn, total: body.total, source: 'kw', + info: { + name: body.title, + img: body.pic, + desc: body.info, + author: body.uname, + play_count: this.formatPlayCount(body.playnum), + }, } }) }, diff --git a/src/renderer/utils/music/mg/songList.js b/src/renderer/utils/music/mg/songList.js index 5419192e..3910da97 100644 --- a/src/renderer/utils/music/mg/songList.js +++ b/src/renderer/utils/music/mg/songList.js @@ -60,12 +60,20 @@ export default { 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) + // console.log(JSON.stringify(body)) return { list: this.filterListDetail(body.list), page, limit: this.limit_song, total: body.totalCount, 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), + }, } }) }, diff --git a/src/renderer/views/SongList.vue b/src/renderer/views/SongList.vue index d9805012..374684a4 100644 --- a/src/renderer/views/SongList.vue +++ b/src/renderer/views/SongList.vue @@ -75,7 +75,11 @@ export default { list = this.source ? [...this.sourceInfo.sortList[this.source]] : [] switch (this.source) { case 'wy': + case 'kw': + case 'bd': case 'tx': + case 'mg': + case 'kg': list.push({ name: `打开${this.sourceInfo.sources.find(s => s.id == this.source).name}歌单`, id: 'importSongList', @@ -303,19 +307,34 @@ export default { }, handleParseImportSongListInputText() { if (!/[?&:/]/.test(this.importSongListText)) return - let id + let regx switch (this.source) { case 'wy': - id = this.importSongListText.replace(/^.+(?:\?|&)id=(\d+)(?:&.*$|#.*$|$)/, '$1') + regx = /^.+(?:\?|&)id=(\d+)(?:&.*$|#.*$|$)/ break case 'tx': - // https://y.qq.com/n/yqq/playsquare/4385581243.html#stat=y_new.index.playlist.pic - id = this.importSongListText.replace(/^.+\/(\d+)\.html(?:&.*$|#.*$|$)/, '$1') + regx = /^.+\/(\d+)\.html(?:\?.*|&.*$|#.*$|$)/ + break + case 'kw': + // http://www.kuwo.cn/playlist_detail/2886046289 + regx = /^.+\/playlist_detail\/(\d+)(?:\?.*|&.*$|#.*$|$)/ + break + case 'bd': + // http://music.taihe.com/songlist/566347741 + regx = /^.+\/songlist\/(\d+)(?:\?.*|&.*$|#.*$|$)/ + break + case 'mg': + // http://music.migu.cn/v3/music/playlist/161044573?page=1 + regx = /^.+\/playlist\/(\d+)(?:\?.*|&.*$|#.*$|$)/ + break + case 'kg': + // https://www.kugou.com/yy/special/single/1067062.html + regx = /^.+\/(\d+)\.html(?:\?.*|&.*$|#.*$|$)/ break default: return } - this.importSongListText = id + this.importSongListText = this.importSongListText.replace(regx, '$1') }, }, }