Skip to content

Commit

Permalink
添加对wy源某些歌曲有问题的歌词进行修复
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Dec 12, 2023
1 parent 6fc5a47 commit e9539b5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions publish/changeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- 自定义源列显示源版本号、作者名字
- 优化列表全选机制,修复列表未获得焦点时仍然可以全选的问题
- 优化搜索框交互逻辑,防止鼠标操作时意外搜索候选列表的内容
- 添加对wy源某些歌曲有问题的歌词进行修复

### 修复

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/core/music/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const buildLyricInfo = async(lyricInfo: MakeOptional<LX.Player.LyricInfo,

export const getCachedLyricInfo = async(musicInfo: LX.Music.MusicInfo): Promise<LX.Player.LyricInfo | null> => {
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', '')
Expand Down
21 changes: 18 additions & 3 deletions src/renderer/utils/musicSdk/wy/lyric.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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
})
Expand Down

0 comments on commit e9539b5

Please sign in to comment.