修复本地 FLAC 文件内嵌歌词无法读取的问题

pull/2270/head
lyswhut 2025-02-12 22:00:03 +08:00
parent 27f6168a29
commit 43c4e13c11
2 changed files with 13 additions and 7 deletions

View File

@ -3,6 +3,7 @@
- 修复 Windows 下桌面歌词最小高度与宽度设置问题(#2244
- 修复 Windows 下界面缩放后移动桌面歌词会改变歌词窗口大小的问题(#2244
- 修复 tx 歌单搜索名字、描述出现乱码的问题(#2250
- 修复本地 FLAC 文件内嵌歌词无法读取的问题
### 优化

View File

@ -208,7 +208,7 @@ export const getLocalMusicFileLyric = async(path: string): Promise<LX.Music.Lyri
// 尝试读取文件内歌词
const metadata = await getFileMetadata(path)
// console.log(metadata)
// console.log(metadata?.common)
if (!metadata) return null
let lyricInfo = metadata.common.lyrics?.[0]
if (lyricInfo) {
@ -221,12 +221,17 @@ export const getLocalMusicFileLyric = async(path: string): Promise<LX.Music.Lyri
}
// console.log(metadata)
for (const info of Object.values(metadata.native)) {
const ust = info.find(i => i.id == 'USLT')
if (ust) {
const value = ust.value as IComment
if (value.text && value.text.length > 10) {
return {
lyric: value.text,
for (const ust of info) {
switch (ust.id) {
case 'LYRICS': {
const value = typeof ust.value == 'string' ? ust.value : (ust as IComment).text
if (value && value.length > 10) return { lyric: value }
break
}
case 'USLT': {
const value = ust.value as IComment
if (value.text && value.text.length > 10) return { lyric: value.text }
break
}
}
}