Skip to content

Commit

Permalink
fix: 歌词下载错误时整体进程退出
Browse files Browse the repository at this point in the history
  • Loading branch information
zonemeen committed Jun 9, 2023
1 parent 8009f61 commit da30644
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ const downloadSong = (song: SongInfo, index: number) => {

if (!existsSync(targetDir)) mkdirSync(targetDir)

// 是否下载歌词
if (withLyric) {
await lyric[service](lrcPath, lyricDownloadUrl)
await lyric[service](lrcPath, lyricDownloadUrl).catch(() => {
createWriteStream(lrcPath).write('[00:00.00]无歌词')
})
}

const onError = (err: any, songPath: string) => {
Expand Down
4 changes: 2 additions & 2 deletions src/qrcode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ export default async ({
pageNum,
pageSize,
} as SearchProps)
const lyricList = await Promise.allSettled(
const lyricList = (await Promise.allSettled(
searchSongs.map(async ({ lyricUrl }: { lyricUrl: string }) => {
return await lyric[service as ServiceType](null, lyricUrl)
})
)
)) as { value: string | undefined }[]
searchSongs.forEach((song: any, index: number) => {
song.lrc = lyricList[index].value ?? '[00:00.00]无歌词'
})
Expand Down

0 comments on commit da30644

Please sign in to comment.