diff --git a/.gitignore b/.gitignore index d8aff02..360f81c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,10 @@ test.js .* !/.gitignore todo.txt -ffmpeg +ffmpeg* ffmpeg.exe generated-sources.json ffmpeg.patch -deno* \ No newline at end of file +deno* +node.exe +node \ No newline at end of file diff --git a/linux.sh b/linux.sh index 48069f5..b72b7d4 100644 --- a/linux.sh +++ b/linux.sh @@ -7,8 +7,8 @@ if ! command -V curl > /dev/null 2>&1; then fi wget "https://github.com/aandrew-me/ffmpeg-builds/releases/download/v8/ffmpeg_linux_amd64.tar.xz" -wget "https://github.com/aandrew-me/ffmpeg-builds/releases/download/v8/deno_linux_amd64" -O deno -chmod +x deno +wget "https://github.com/aandrew-me/ffmpeg-builds/releases/download/v8/node_linux_amd64" -O node +chmod +x node tar -xf ffmpeg_linux_amd64.tar.xz mv ffmpeg_linux_amd64 ffmpeg chmod +x ffmpeg/bin/ffmpeg diff --git a/package.json b/package.json index 8b6f72d..a4eb440 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "./ffmpeg/**/*", "!ffmpeg.patch", "translations", - "deno*" + "node*" ], "electronLanguages": [ "en-US" diff --git a/src/playlist.js b/src/playlist.js index 941b8a8..3b81bc0 100644 --- a/src/playlist.js +++ b/src/playlist.js @@ -14,7 +14,7 @@ const playlistDownloader = { ytDlpPath: null, ytDlpWrap: null, ffmpegPath: null, - denoPath: null, + jsRuntimePath: null, playlistName: "", originalCount: 0, currentDownloadProcess: null, @@ -123,9 +123,9 @@ const playlistDownloader = { localStorage.setItem("downloadPath", defaultDownloadsDir); } - // ffmpeg and deno path setup + // ffmpeg and js runtime path setup this.state.ffmpegPath = this.getFfmpegPath(); - this.state.denoPath = this.getJsRuntimePath(); + this.state.jsRuntimePath = this.getJsRuntimePath(); if (localStorage.getItem("preferredVideoQuality")) { this.ui.videoQualitySelect.value = localStorage.getItem( @@ -263,8 +263,8 @@ const playlistDownloader = { `"${start}:${end}"`, "--ffmpeg-location", `"${this.state.ffmpegPath}"`, - ...(this.state.denoPath - ? ["--no-js-runtimes", "--js-runtime", this.state.denoPath] + ...(this.state.jsRuntimePath + ? ["--no-js-runtimes", "--js-runtime", this.state.jsRuntimePath] : []), this.config.cookie.arg, this.config.cookie.browser, @@ -658,19 +658,41 @@ const playlistDownloader = { }, getJsRuntimePath() { - if ( - process.env.YTDOWNLOADER_DENO_PATH && - fs.existsSync(process.env.YTDOWNLOADER_DENO_PATH) - ) { - return `deno:"${process.env.YTDOWNLOADER_DENO_PATH}"`; - } + { + const exeName = "node"; - if (os.platform() === "darwin") return ""; + if (process.env.YTDOWNLOADER_NODE_PATH) { + if (fs.existsSync(process.env.YTDOWNLOADER_NODE_PATH)) { + return `$node:"${process.env.YTDOWNLOADER_NODE_PATH}"`; + } - let denoExe = os.platform() === "win32" ? "deno.exe" : "deno"; - const denoPath = path.join(__dirname, "..", denoExe); + return ""; + } + + if (process.env.YTDOWNLOADER_DENO_PATH) { + if (fs.existsSync(process.env.YTDOWNLOADER_DENO_PATH)) { + return `$deno:"${process.env.YTDOWNLOADER_DENO_PATH}"`; + } + + return ""; + } - return fs.existsSync(denoPath) ? `deno:"${denoPath}"` : ""; + if (os.platform() === "darwin") { + return ""; + } + + let jsRuntimePath = path.join(__dirname, "..", exeName); + + if (os.platform() === "win32") { + jsRuntimePath = path.join(__dirname, "..", `${exeName}.exe`); + } + + if (fs.existsSync(jsRuntimePath)) { + return `${exeName}:"${jsRuntimePath}"`; + } else { + return ""; + } + } }, }; diff --git a/src/renderer.js b/src/renderer.js index 884c2fa..bb1a758 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -483,9 +483,19 @@ class YtDownloaderApp { * @returns {Promise} A promise that resolves with the JS runtime path. */ async _getJsRuntimePath() { + const exeName = "node"; + + if (process.env.YTDOWNLOADER_NODE_PATH) { + if (existsSync(process.env.YTDOWNLOADER_NODE_PATH)) { + return `$node:"${process.env.YTDOWNLOADER_NODE_PATH}"`; + } + + return ""; + } + if (process.env.YTDOWNLOADER_DENO_PATH) { if (existsSync(process.env.YTDOWNLOADER_DENO_PATH)) { - return `deno:"${process.env.YTDOWNLOADER_DENO_PATH}"`; + return `$deno:"${process.env.YTDOWNLOADER_DENO_PATH}"`; } return ""; @@ -495,14 +505,14 @@ class YtDownloaderApp { return ""; } - let denoPath = join(__dirname, "..", "deno"); + let jsRuntimePath = join(__dirname, "..", exeName); if (platform() === "win32") { - denoPath = join(__dirname, "..", "deno.exe"); + jsRuntimePath = join(__dirname, "..", `${exeName}.exe`); } - if (existsSync(denoPath)) { - return `deno:"${denoPath}"`; + if (existsSync(jsRuntimePath)) { + return `${exeName}:"${jsRuntimePath}"`; } else { return ""; } diff --git a/windows.ps1 b/windows.ps1 index a0357de..a64abee 100644 --- a/windows.ps1 +++ b/windows.ps1 @@ -1,4 +1,4 @@ -Invoke-WebRequest -Uri "https://github.com/aandrew-me/ffmpeg-builds/releases/download/v8/deno.exe" -OutFile deno.exe +Invoke-WebRequest -Uri "https://github.com/aandrew-me/ffmpeg-builds/releases/download/v8/node.exe" -OutFile node.exe Invoke-WebRequest -Uri "https://github.com/aandrew-me/ffmpeg-builds/releases/download/v8/ffmpeg_win64.zip" -OutFile ffmpeg_win64.zip Expand-Archive -Path ffmpeg_win64.zip -DestinationPath . Remove-Item -Path ffmpeg_win64.zip