Skip to content

Commit

Permalink
refactor: support download flac at app
Browse files Browse the repository at this point in the history
  • Loading branch information
little-buddy committed Dec 3, 2023
1 parent 5760f81 commit 2cd4da8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/electron/event/ipc-main/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,20 @@ const nodeDownload = async (
})
response.on('end', async () => {
const buffer = Buffer.concat(chunks)
const path = join(downloadPath, name + suffix)

let suffixName = ''
// eslint-disable-next-line no-useless-escape
const match_result = url.match(/\.[^\.]+$/)
if (match_result) {
const suffixStr = match_result[0]
if (['.mp3', '.flac'].includes(suffixStr)) {
suffixName = suffixStr
} else {
suffixName = suffix
}
}

const path = join(downloadPath, name + suffixName)
const comm = Buffer.from(String(id)).toString('base64')
const { renderBuffer, addTag } = writeBufferID3(buffer)
addTag('TIT2', name)
Expand Down

0 comments on commit 2cd4da8

Please sign in to comment.