diff --git a/publish/changeLog.md b/publish/changeLog.md index 3bc4aae3..56d47270 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -13,6 +13,7 @@ - 修复 kw 歌单详情出现打开失败的问题(#2317) - 修复 kg 热门评论无法获取的问题 - 修复桌面歌词被遮挡时会被暂停的问题(#2320) +- 修复 kg 歌单打开失败的问题(thanks @Folltoshe) ### 优化 diff --git a/src/renderer/utils/musicSdk/kg/songList.js b/src/renderer/utils/musicSdk/kg/songList.js index df4bc289..640f6079 100644 --- a/src/renderer/utils/musicSdk/kg/songList.js +++ b/src/renderer/utils/musicSdk/kg/songList.js @@ -414,6 +414,28 @@ export default { }) }, + async decodeGcid(gcid) { + const params = 'dfid=-&appid=1005&mid=0&clientver=20109&clienttime=640612895&uuid=-' + const body = { + ret_info: 1, + data: [ + { + id: gcid, + id_type: 2, + }, + ], + } + const result = await this.createHttp(`https://t.kugou.com/v1/songlist/batch_decode?${params}&signature=${signatureParams(params, 'android', JSON.stringify(body))}`, { + method: 'POST', + headers: { + 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; HUAWEI HMA-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Mobile Safari/537.36', + Referer: 'https://m.kugou.com/', + }, + body, + }) + return result.list[0].global_collection_id + }, + async getUserListDetailByLink({ info }, link) { let listInfo = info['0'] let total = listInfo.count @@ -592,6 +614,13 @@ export default { if (retryNum > 3) return Promise.reject(new Error('link try max num')) if (link.includes('#')) link = link.replace(/#.*$/, '') if (link.includes('global_collection_id')) return this.getUserListDetail2(link.replace(/^.*?global_collection_id=(\w+)(?:&.*$|#.*$|$)/, '$1')) + if (link.includes('gcid_')) { + let gcid = link.match(/gcid_\w+/)?.[0] + if (gcid) { + const global_collection_id = await this.decodeGcid(gcid) + if (global_collection_id) return this.getUserListDetail2(global_collection_id) + } + } if (link.includes('chain=')) return this.getUserListDetail3(link.replace(/^.*?chain=(\w+)(?:&.*$|#.*$|$)/, '$1'), page) if (link.includes('.html')) { if (link.includes('zlist.html')) { @@ -616,6 +645,13 @@ export default { if (location) { // console.log(location) if (location.includes('global_collection_id')) return this.getUserListDetail2(location.replace(/^.*?global_collection_id=(\w+)(?:&.*$|#.*$|$)/, '$1')) + if (location.includes('gcid_')) { + let gcid = link.match(/gcid_\w+/)?.[0] + if (gcid) { + const global_collection_id = await this.decodeGcid(gcid) + if (global_collection_id) return this.getUserListDetail2(global_collection_id) + } + } if (location.includes('chain=')) return this.getUserListDetail3(location.replace(/^.*?chain=(\w+)(?:&.*$|#.*$|$)/, '$1'), page) if (location.includes('.html')) { if (location.includes('zlist.html')) { @@ -631,7 +667,16 @@ export default { // console.log('location', location) return this.getUserListDetail(location, page, ++retryNum) } - if (typeof body == 'string') return this.getUserListDetail2(body.replace(/^[\s\S]+?"global_collection_id":"(\w+)"[\s\S]+?$/, '$1')) + if (typeof body == 'string') { + let global_collection_id = body.match(/"global_collection_id":"(\w+)"/)?.[1] + if (!global_collection_id) { + let gcid = body.match(/"encode_gic":"(\w+)"/)?.[1] + if (!gcid) gcid = body.match(/"encode_src_gid":"(\w+)"/)?.[1] + if (gcid) global_collection_id = await this.decodeGcid(gcid) + } + if (!global_collection_id) throw new Error('get list error') + return this.getUserListDetail2(global_collection_id) + } if (body.errcode !== 0) return this.getUserListDetail(link, page, ++retryNum) return this.getUserListDetailByLink(body, link) },