添加支持对酷狗码打开的打开

pull/225/head
lyswhut 2020-04-19 13:56:08 +08:00
parent 116ee25e28
commit 0c4f943d72
7 changed files with 368 additions and 5582 deletions

5838
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -51,7 +51,7 @@
"lint:fix": "eslint --ext .js,.vue -f ./node_modules/eslint-formatter-friendly --fix src"
},
"browserslist": [
"Electron 8.2.2"
"Electron 8.2.3"
],
"engines": {
"node": ">= 12"
@ -160,15 +160,15 @@
"cross-env": "^7.0.2",
"css-loader": "^3.5.2",
"del": "^5.1.0",
"electron": "^8.2.2",
"electron-builder": "^22.4.1",
"electron": "^8.2.3",
"electron-builder": "^22.5.1",
"electron-debug": "^3.0.1",
"electron-devtools-installer": "^3.0.0",
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.1",
"eslint-formatter-friendly": "^7.0.0",
"eslint-loader": "^4.0.0",
"eslint-plugin-html": "^6.0.1",
"eslint-plugin-html": "^6.0.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
@ -186,7 +186,7 @@
"pug": "^2.0.4",
"pug-loader": "^2.4.0",
"pug-plain-loader": "^1.0.0",
"raw-loader": "^4.0.0",
"raw-loader": "^4.0.1",
"rimraf": "^3.0.2",
"spinnies": "^0.5.1",
"stylus": "^0.54.7",
@ -216,7 +216,7 @@
"request": "^2.88.2",
"vue": "^2.6.11",
"vue-electron": "^1.0.6",
"vue-i18n": "^8.17.0",
"vue-i18n": "^8.17.1",
"vue-router": "^3.1.6",
"vuex": "^3.1.3",
"vuex-electron": "^1.0.3",

View File

@ -2,5 +2,9 @@
"back": "返回",
"loding_list": "列表加载中...",
"loding_list_fail": "列表加载失败",
"open_list": "打开{name}歌单"
"open_list": "打开{name}歌单",
"input_text": "输入歌单链接或歌单ID",
"tip_1": "不支持跨源打开歌单,请确认要打开的歌单与当前歌单源是否对应",
"tip_2": "若遇到无法打开的歌单链接,欢迎反馈",
"tip_3": "酷狗源不支持用歌单ID打开但支持酷狗码打开"
}

View File

@ -2,5 +2,9 @@
"back": "返回",
"loding_list": "列表加载中...",
"loding_list_fail": "列表加載失敗",
"open_list": "打開{name}歌單"
"open_list": "打開{name}歌單",
"input_text": "輸入歌單鏈接或歌單ID",
"tip_1": "不支持跨源打開歌單,請確認要打開的歌單與當前歌單源是否對應",
"tip_2": "若遇到無法打開的歌單鏈接,歡迎反饋",
"tip_3": "酷狗源不支持用歌單ID打開但支持酷狗碼打開"
}

View File

@ -2,5 +2,9 @@
"back": "Back",
"loding_list": "Loading the list...",
"loding_list_fail": "List loading failed",
"open_list": "open {name} playlist"
"open_list": "open {name} playlist",
"input_text": "Enter songlist link or songlist ID",
"tip_1": "Cross-source playlists are not supported, please confirm whether the playlist to be opened corresponds to the current playlist source",
"tip_2": "If you encounter a link to a playlist that cannot be opened, welcome feedback",
"tip_3": "Kugou source does not support opening with playlist ID, but supports Kugou code opening"
}

View File

@ -156,7 +156,15 @@ export default {
return this.createHttp(url, options, ++retryNum)
}
// console.log(result.statusCode, result.body)
if (result.statusCode !== 200 || ((result.body.error_code === undefined ? result.body.errcode : result.body.error_code) !== 0)) return this.createHttp(url, options, ++retryNum)
if (result.statusCode !== 200 ||
(
(result.body.error_code !== undefined
? result.body.error_code
: result.body.errcode !== undefined
? result.body.errcode
: result.body.err_code
) !== 0)
) return this.createHttp(url, options, ++retryNum)
return result.body.data || result.body.info
},
@ -189,13 +197,58 @@ export default {
}).then(data => data.map(s => s[0])))
},
async getUserListDetailByCode(id) {
const songInfo = await this.createHttp('http://t.kugou.com/command/', {
method: 'POST',
headers: {
'KG-RC': 1,
'KG-THash': 'network_super_call.cpp:3676261689:379',
'User-Agent': '',
},
body: { appid: 1001, clientver: 9020, mid: '21511157a05844bd085308bc76ef3343', clienttime: 640612895, key: '36164c4015e704673c588ee202b9ecb8', data: id },
})
// console.log(songInfo)
let songList
let info = songInfo.info
if (info.userid != null) {
songList = await this.createHttp('http://www2.kugou.kugou.com/apps/kucodeAndShare/app/', {
method: 'POST',
headers: {
'KG-RC': 1,
'KG-THash': 'network_super_call.cpp:3676261689:379',
'User-Agent': '',
},
body: { appid: 1001, clientver: 9020, mid: '21511157a05844bd085308bc76ef3343', clienttime: 640612895, key: '36164c4015e704673c588ee202b9ecb8', data: { id: info.id, type: 3, userid: info.userid, collect_type: 0, page: 1, pagesize: info.count } },
})
// console.log(songList)
}
let result = await Promise.all(this.createTask((songList || songInfo.list).map(item => ({ hash: item.hash })))).then(([...datas]) => datas.flat())
return {
list: this.filterData2(result) || [],
page: 1,
limit: info.count,
total: info.count,
source: 'kg',
info: {
name: info.name,
img: (info.img_size && info.img_size.replace('{size}', 240)) || info.img,
// desc: body.result.info.list_desc,
author: info.username,
// play_count: this.formatPlayCount(info.count),
},
}
},
async getUserListDetail3(chain, page) {
const songInfo = await this.createHttp(`http://m.kugou.com/schain/transfer?pagesize=${this.listDetailLimit}&chain=${chain}&su=1&page=${page}&n=0.7928855356604456`, {
headers: {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
},
})
if (!songInfo.list) return this.getUserListDetail2(songInfo.global_collection_id)
if (!songInfo.list) {
if (songInfo.global_collection_id) return this.getUserListDetail2(songInfo.global_collection_id)
else throw new Error('fail')
}
let result = await Promise.all(this.createTask(songInfo.list.map(item => ({ hash: item.hash })))).then(([...datas]) => datas.flat())
// console.log(info, songInfo)
return {
@ -327,6 +380,8 @@ export default {
id = id.replace(this.regExps.listDetailLink, '$1')
} else if (/http(?:s):/.test(id)) {
return this.getUserListDetail(id.replace(/^.*http/, 'http'), page)
} else if (/^\d+$/.test(id)) {
return this.getUserListDetailByCode(id)
}
// if ((/[?&:/]/.test(id))) id = id.replace(this.regExps.listDetailLink, '$1')

View File

@ -40,9 +40,15 @@
material-pagination(:count="listData.total" :limit="listData.limit" :page="listData.page" @btn-click="handleToggleListPage")
transition(enter-active-class="animated-fast fadeIn" leave-active-class="animated-fast fadeOut")
div(:class="$style.importSongListContent" v-show="sortId === 'importSongList'")
material-search-input(v-model="importSongListText" @event="handleImportSongListEvent" big placeholder="输入歌单链接或歌单ID")
svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 451.846 451.847' space='preserve')
use(xlink:href='#icon-right')
div(:style="{ width: '500px' }")
material-search-input(v-model="importSongListText" @event="handleImportSongListEvent" big :placeholder="$t('view.song_list.input_text')")
svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 451.846 451.847' space='preserve')
use(xlink:href='#icon-right')
div(:class="$style.tips")
ul
li {{$t('view.song_list.tip_1')}}
li {{$t('view.song_list.tip_2')}}
li {{$t('view.song_list.tip_3')}}
transition(enter-active-class="animated-fast fadeIn" leave-active-class="animated-fast fadeOut")
div(v-show="!listData.list.length" :class="$style.noitem")
p {{$t('view.song_list.loding_list')}}
@ -534,6 +540,17 @@ export default {
}
}
.tips {
padding: 15px 0;
font-size: 12px;
color: @color-theme_2-font;
line-height: 1.5;
ul {
list-style: decimal;
padding-left: 15px;
}
}
each(@themes, {
:global(#container.@{value}) {
.song-list-header-middle {