修复酷我音乐lrc歌词下载解析问题
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smart-lyric",
|
"name": "smart-lyric",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "typing/index.d.ts",
|
"types": "typing/index.d.ts",
|
||||||
|
@ -238,9 +238,18 @@ export async function downloadKuwoLyric(option: IKuwoLyricDownloadOption): Promi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isLyric = (str: string) => /^\[[0-9a-zA-Z]+:/.test(str)
|
||||||
|
|
||||||
|
const tryParseRegular = (buffer: Buffer) => {
|
||||||
|
let result: string | null = lrcxUtil.decrypt(buffer)
|
||||||
|
if (!result || !isLyric(result)) result = iconv.decode(zlib.inflateSync(buffer), 'gb18030')
|
||||||
|
if (result && isLyric(result)) return result
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
if (buffer.byteLength && baseInfo.lrc_length) {
|
if (buffer.byteLength && baseInfo.lrc_length) {
|
||||||
if (baseInfo.lrcx) return { karaok: lrcxUtil.decrypt(buffer), regular: null }
|
if (baseInfo.lrcx) return { karaok: lrcxUtil.decrypt(buffer), regular: null }
|
||||||
else return { karaok: null, regular: iconv.decode(zlib.inflateSync(buffer), 'gb18030') }
|
else return { karaok: null, regular: tryParseRegular(buffer) }
|
||||||
}
|
}
|
||||||
return { karaok: null, regular: null }
|
return { karaok: null, regular: null }
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user