diff --git a/publish/changeLog.md b/publish/changeLog.md index e0e406a3a..995be284b 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -11,6 +11,7 @@ - 更新播放栏进度条样式,进度条允许拖动调整进度 - 优化播放详情页歌曲封面、控制按钮对各尺寸屏幕的适配,修改横屏下的控制栏按钮布局 - 优化横竖屏界面的暂时判断,现在趋于方屏的屏幕按竖屏的方式显示,横屏下的播放栏添加上一曲切歌按钮 +- 添加对wy源某些歌曲有问题的歌词进行修复(#370) ### 修复 diff --git a/src/utils/musicSdk/wy/lyric.js b/src/utils/musicSdk/wy/lyric.js index 0d234253d..3f2964bed 100644 --- a/src/utils/musicSdk/wy/lyric.js +++ b/src/utils/musicSdk/wy/lyric.js @@ -126,7 +126,10 @@ const parseTools = { }) }, getIntv(interval) { - let [m, s, ms] = interval.split(/:|\./) + if (!interval.includes('.')) interval += '.0' + let arr = interval.split(/:|\./) + while (arr.length < 3) arr.unshift('0') + const [m, s, ms] = arr return parseInt(m) * 3600000 + parseInt(s) * 1000 + parseInt(ms) }, fixTimeTag(lrc, targetlrc) { @@ -243,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 => { @@ -258,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 })