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 })