From aca0a4deb6e886237e6771ec20adfaa23ca6cc44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Wed, 11 Oct 2023 22:41:33 +0100 Subject: [PATCH] fix: #50 audio ext `mp4` -> `m4a` --- src/decrypt-worker/worker/handler/decrypt.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/decrypt-worker/worker/handler/decrypt.ts b/src/decrypt-worker/worker/handler/decrypt.ts index 1da803c..508d0f3 100644 --- a/src/decrypt-worker/worker/handler/decrypt.ts +++ b/src/decrypt-worker/worker/handler/decrypt.ts @@ -16,7 +16,7 @@ class DecryptCommandHandler { label: string, private parakeet: Parakeet, private buffer: ArrayBuffer, - private options: DecryptCommandOptions + private options: DecryptCommandOptions, ) { this.label = `DecryptCommandHandler(${label})`; } @@ -59,10 +59,13 @@ class DecryptCommandHandler { const decrypted = await this.log(`decrypt (${crypto.cryptoName})`, () => crypto.decrypt(this.buffer, this.options)); // Check if we had a successful decryption - const audioExt = crypto.overrideExtension ?? (await this.detectAudioExtension(decrypted)); + let audioExt = crypto.overrideExtension ?? (await this.detectAudioExtension(decrypted)); if (crypto.checkByDecryptHeader && audioExt === 'bin') { return null; } + if (audioExt.toLowerCase() === 'mp4') { + audioExt = 'm4a'; + } return { decrypted: URL.createObjectURL(toBlob(decrypted)), ext: audioExt }; } @@ -82,7 +85,7 @@ class DecryptCommandHandler { // Check by decrypt max first 8MiB const decryptedBuffer = await this.log(`${crypto.cryptoName}/decrypt-header-test`, async () => - toArrayBuffer(await crypto.decrypt(this.buffer.slice(0, TEST_FILE_HEADER_LEN), this.options)) + toArrayBuffer(await crypto.decrypt(this.buffer.slice(0, TEST_FILE_HEADER_LEN), this.options)), ); return this.parakeet.detectAudioExtension(decryptedBuffer) !== 'bin';