This commit is contained in:
unknowableshade committed 2021-12-29 23:42:59 +03:00
1 parent 8a31f533ab
commit 74364487fe
2 files changed
+13 -1

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
import { exec } from "child_process"
import { promisify } from "util";
const execAsync = promisify(exec);
export async function buildUp(): Promise<void> {
await execAsync("mkdir -p foo $1/dist/assets/SearchTakts/bin");
await execAsync("curl -L https://yt-dl.org/downloads/latest/youtube-dl -o $1/dist/assets/SearchTakts/bin/youtube-dl");
await execAsync("chmod a+rx $1/dist/assets/SearchTakts/bin/youtube-dl");
await execAsync("PATH=$PATH:$1/bin/");
}
+2 -1
View File
@@ -2,6 +2,7 @@ import { ytdlArgs, ytdlResponse } from "./Types"
import { execFile } from "child_process"
import { promisify } from "util";
import { getTracks, getPreview } from "spotify-url-info";
import { buildUp } from "./BuildUp";
const execFileAsync = promisify(execFile);
@@ -27,7 +28,7 @@ async function ytdlExec(query: string, args: ytdlArgs): Promise<ytdlResponse | u
return JSON.parse(executable.stdout);
}
catch {
console.log("youtube-dl not found. Please install it first with npm run build.");
await buildUp();
return undefined;
}
}