From cec66853c4bebe4ea00adb1e07b04001f510f241 Mon Sep 17 00:00:00 2001 From: stratuma Date: Mon, 8 Jul 2024 15:36:54 +0200 Subject: [PATCH] moved from exec to execFile --- src/api/routes/service/service.service.ts | 10 +++++++--- src/api/services/audio.ts | 10 +++++++--- src/api/services/shaka.ts | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/api/routes/service/service.service.ts b/src/api/routes/service/service.service.ts index 2e299eb..aa66ded 100644 --- a/src/api/routes/service/service.service.ts +++ b/src/api/routes/service/service.service.ts @@ -23,7 +23,7 @@ import settings from 'electron-settings' import { server } from '../../api' import { createChapterFile } from '../../services/chapter' import { app } from 'electron' -const exec = util.promisify(require('child_process').exec) +const execFile = util.promisify(require('child_process').execFile) settings.configure({ dir: app.getPath('documents') + '/Crunchyroll Downloader/settings/' @@ -1354,9 +1354,13 @@ async function mergeParts(parts: { filename: string; url: string }[], downloadID await updatePlaylistByID(downloadID, 'decrypting video') console.log('Video Decryption started') - const command = `${shaka} input="${tmp}/temp-main.m4s",stream=video,output="${tmp}/main.m4s" --enable_raw_key_decryption --keys key_id=${drmkeys[1].kid}:key=${drmkeys[1].key}` + await execFile(shaka, [ + `input=${tmp}/temp-main.m4s,stream=video,output=${tmp}/main.m4s`, + '--enable_raw_key_decryption', + '--keys', + `key_id=${drmkeys[1].kid}:key=${drmkeys[1].key}` + ]) - await exec(command) console.log('Video Decryption finished') concatenatedFile = `${tmp}/main.m4s` } diff --git a/src/api/services/audio.ts b/src/api/services/audio.ts index 5cfbebf..21ab922 100644 --- a/src/api/services/audio.ts +++ b/src/api/services/audio.ts @@ -9,7 +9,7 @@ const ffmpegP = getFFMPEGPath() const shaka = getShakaPath() import util from 'util' import { server } from '../api' -const exec = util.promisify(require('child_process').exec) +const execFile = util.promisify(require('child_process').execFile) import { finished } from 'stream/promises' import { messageBox } from '../../electron/background' @@ -163,9 +163,13 @@ async function mergePartsAudio( console.log(`Audio Decryption started`) - const command = `${shaka} input="${tmp}/temp-main.m4s",stream=audio,output="${tmp}/main.m4s" --enable_raw_key_decryption --keys key_id=${drmkeys[1].kid}:key=${drmkeys[1].key}` + await execFile(shaka, [ + `input=${tmp}/temp-main.m4s,stream=audio,output=${tmp}/main.m4s`, + '--enable_raw_key_decryption', + '--keys', + `key_id=${drmkeys[1].kid}:key=${drmkeys[1].key}` + ]) - await exec(command) concatenatedFile = `${tmp}/main.m4s` console.log(`Audio Decryption finished`) } diff --git a/src/api/services/shaka.ts b/src/api/services/shaka.ts index 13c0227..483c8d2 100644 --- a/src/api/services/shaka.ts +++ b/src/api/services/shaka.ts @@ -14,7 +14,7 @@ export function getShakaPath() { return shaka } else { - const shaka = `"${path.join(shakaFolderPath, 'shaka.exe')}"` + const shaka = path.join(shakaFolderPath, 'shaka.exe') return shaka }