From e9539b5c5c23e63aa139bae47ef2b4d8f59ab2c4 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Tue, 12 Dec 2023 13:44:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9wy=E6=BA=90=E6=9F=90?= =?UTF-8?q?=E4=BA=9B=E6=AD=8C=E6=9B=B2=E6=9C=89=E9=97=AE=E9=A2=98=E7=9A=84?= =?UTF-8?q?=E6=AD=8C=E8=AF=8D=E8=BF=9B=E8=A1=8C=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 1 + src/renderer/core/music/utils.ts | 2 +- src/renderer/utils/musicSdk/wy/lyric.js | 21 ++++++++++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 95ed310056..08c00eebe7 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -19,6 +19,7 @@ - 自定义源列显示源版本号、作者名字 - 优化列表全选机制,修复列表未获得焦点时仍然可以全选的问题 - 优化搜索框交互逻辑,防止鼠标操作时意外搜索候选列表的内容 +- 添加对wy源某些歌曲有问题的歌词进行修复 ### 修复 diff --git a/src/renderer/core/music/utils.ts b/src/renderer/core/music/utils.ts index 52c446cf98..9119482d7f 100644 --- a/src/renderer/core/music/utils.ts +++ b/src/renderer/core/music/utils.ts @@ -118,7 +118,7 @@ export const buildLyricInfo = async(lyricInfo: MakeOptional => { let lrcInfo = await getStoreLyric(musicInfo) - // lrcInfo = {} + lrcInfo = {} as unknown as LX.Player.LyricInfo if (existTimeExp.test(lrcInfo.lyric) && lrcInfo.tlyric != null) { // if (musicInfo.lrc.startsWith('\ufeff[id:$00000000]')) { // let str = musicInfo.lrc.replace('\ufeff[id:$00000000]\n', '') diff --git a/src/renderer/utils/musicSdk/wy/lyric.js b/src/renderer/utils/musicSdk/wy/lyric.js index 108a2e3132..3f2964bed3 100644 --- a/src/renderer/utils/musicSdk/wy/lyric.js +++ b/src/renderer/utils/musicSdk/wy/lyric.js @@ -246,6 +246,20 @@ const parseTools = { // return requestObj // } +// https://github.com/lyswhut/lx-music-mobile/issues/370 +const fixTimeLabel = (lrc, tlrc, romalrc) => { + if (lrc) { + let newLrc = lrc.replace(/\[(\d{2}:\d{2}):(\d{2})]/g, '[$1.$2]') + let newTlrc = tlrc?.replace(/\[(\d{2}:\d{2}):(\d{2})]/g, '[$1.$2]') ?? tlrc + if (newLrc != lrc || newTlrc != tlrc) { + lrc = newLrc + tlrc = newTlrc + if (romalrc) romalrc = romalrc.replace(/\[(\d{2}:\d{2}):(\d{2,3})]/g, '[$1.$2]').replace(/\[(\d{2}:\d{2}\.\d{2})0]/g, '[$1]') + } + } + + return { lrc, tlrc, romalrc } +} // https://github.com/Binaryify/NeteaseCloudMusicApi/blob/master/module/lyric_new.js export default songmid => { @@ -261,10 +275,11 @@ export default songmid => { yrv: 0, }) requestObj.promise = requestObj.promise.then(({ body }) => { - // console.log(body) + console.log(body) if (body.code !== 200 || !body?.lrc?.lyric) return Promise.reject(new Error('Get lyric failed')) - const info = parseTools.parse(body.yrc?.lyric, body.ytlrc?.lyric, body.yromalrc?.lyric, body.lrc.lyric, body.tlyric?.lyric, body.romalrc?.lyric) - // console.log(info) + const fixTimeLabelLrc = fixTimeLabel(body.lrc.lyric, body.tlyric?.lyric, body.romalrc?.lyric) + const info = parseTools.parse(body.yrc?.lyric, body.ytlrc?.lyric, body.yromalrc?.lyric, fixTimeLabelLrc.lrc, fixTimeLabelLrc.tlrc, fixTimeLabelLrc.romalrc) + console.log(info) if (!info.lyric) return Promise.reject(new Error('Get lyric failed')) return info })