summaryrefslogtreecommitdiffstats
path: root/src/utils.ts
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-04-25 11:23:26 +0300
committerJan Tuomi <jan@jantuomi.fi>2025-04-25 11:23:26 +0300
commit7c9a30055ffacc9304f889040abb9d39a7565684 (patch)
treec2a41a9f48e528a1126002503add663c989f82cd /src/utils.ts
parentf05a0bb2b3433fb8c12209375ff8785916b9c841 (diff)
Remove puppeteer based scraping, use yt-dlp
Diffstat (limited to 'src/utils.ts')
-rw-r--r--src/utils.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/utils.ts b/src/utils.ts
index b9b5cfa..fd8a26d 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1,10 +1,25 @@
+import { exec } from "child_process";
+
+export const asyncExec = (command: string) => {
+ return new Promise<{ stdout: string; stderr: string }>((resolve, reject) => {
+ exec(command, (error, stdout, stderr) => {
+ if (error) {
+ console.error(`exec error: ${error}`);
+ reject(error);
+ } else {
+ resolve({ stdout, stderr });
+ }
+ });
+ });
+};
+
export const wait = (ms: number) =>
new Promise((resolve) => setTimeout(resolve, ms));
export const runWithRetries = async <T>(
fn: () => Promise<T>,
retries: number,
- backoff: number = 2000
+ backoff: number = 2000,
): Promise<T> => {
let attempts = 0;
while (true) {