Use node as js runtime for yt-dlp

pull/359/head
aandrew-me 6 days ago
parent 8e3a38fea3
commit b459d487c7

6
.gitignore vendored

@ -4,8 +4,10 @@ test.js
.*
!/.gitignore
todo.txt
ffmpeg
ffmpeg*
ffmpeg.exe
generated-sources.json
ffmpeg.patch
deno*
deno*
node.exe
node

@ -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

@ -51,7 +51,7 @@
"./ffmpeg/**/*",
"!ffmpeg.patch",
"translations",
"deno*"
"node*"
],
"electronLanguages": [
"en-US"

@ -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 "";
}
}
},
};

@ -483,9 +483,19 @@ class YtDownloaderApp {
* @returns {Promise<string>} 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 "";
}

@ -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

Loading…
Cancel
Save