diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-04-25 11:23:26 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-04-25 11:23:26 +0300 |
| commit | 7c9a30055ffacc9304f889040abb9d39a7565684 (patch) | |
| tree | c2a41a9f48e528a1126002503add663c989f82cd /src/utils.ts | |
| parent | f05a0bb2b3433fb8c12209375ff8785916b9c841 (diff) | |
Remove puppeteer based scraping, use yt-dlp
Diffstat (limited to 'src/utils.ts')
| -rw-r--r-- | src/utils.ts | 17 |
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) { |
