From 7c9a30055ffacc9304f889040abb9d39a7565684 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Fri, 25 Apr 2025 11:23:26 +0300 Subject: Remove puppeteer based scraping, use yt-dlp --- src/utils.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/utils.ts') 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 ( fn: () => Promise, retries: number, - backoff: number = 2000 + backoff: number = 2000, ): Promise => { let attempts = 0; while (true) { -- cgit v1.3