修复某些tx源歌词因数据异常解析失败的问题
parent
783799b2a4
commit
2597ab4ea1
|
@ -12,6 +12,7 @@
|
|||
- 修复我的列表名右键菜单-排序歌曲按专辑名排序无效的问题(#1440)
|
||||
- 修复若路径存在 # 字符时,软件无法启动的问题
|
||||
- 修复搜索框在某些情况下输入内容后搜索时会自动清空的问题(#1472)
|
||||
- 修复某些tx源歌词因数据异常解析失败的问题
|
||||
|
||||
### 其他
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { inflate } from 'zlib'
|
||||
import { createInflate, constants as zlibConstants } from 'node:zlib'
|
||||
// import path from 'path'
|
||||
import { mainHandle } from '@common/mainIpc'
|
||||
import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames'
|
||||
|
@ -8,15 +8,29 @@ import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames'
|
|||
|
||||
let qrc_decode: (buf: Buffer, len: number) => Buffer
|
||||
|
||||
const inflate = async(lrcBuf: Buffer) => new Promise<string>((resolve, reject) => {
|
||||
const buffer_builder: Buffer[] = []
|
||||
const decompress_stream = createInflate()
|
||||
.on('data', (chunk) => {
|
||||
buffer_builder.push(chunk)
|
||||
})
|
||||
.on('close', () => {
|
||||
resolve(Buffer.concat(buffer_builder).toString())
|
||||
})
|
||||
.on('error', (err: any) => {
|
||||
// console.log(err)
|
||||
if (err.errno !== zlibConstants.Z_BUF_ERROR) { // EOF: expected
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
// decompress_stream.write(lrcBuf)
|
||||
decompress_stream.end(lrcBuf)
|
||||
})
|
||||
|
||||
const decode = async(str: string): Promise<string> => {
|
||||
if (!str) return ''
|
||||
const buf = Buffer.from(str, 'hex')
|
||||
return new Promise((resolve, reject) => {
|
||||
inflate(qrc_decode(buf, buf.length), (err, lrc) => {
|
||||
if (err) reject(err)
|
||||
else resolve(lrc.toString())
|
||||
})
|
||||
})
|
||||
return inflate(qrc_decode(buf, buf.length))
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue