From 0907e215b455dfdf5660e2f44e0000c102e1084b Mon Sep 17 00:00:00 2001 From: Yuzu Date: Sun, 18 Aug 2024 10:10:53 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Puppeteer=20flags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/Request.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/utils/Request.ts b/src/utils/Request.ts index 9920125..e5b4c73 100644 --- a/src/utils/Request.ts +++ b/src/utils/Request.ts @@ -58,7 +58,27 @@ export async function getStream( } export async function getYouTubeFormats(id: string) { - if (!browser) browser = await puppeteer.launch(); + if (!browser) { + browser = await puppeteer.launch({ + headless: true, + args: [ + "--disable-gpu", + "--disable-dev-shm-usage", + "--disable-setuid-sandbox", + "--no-first-run", + "--no-sandbox", + "--no-zygote", + "--deterministic-fetch", + "--disable-features=IsolateOrigins", + "--disable-site-isolation-trials", + "--single-process", + ], + }); + + browser.once("disconnected", () => { + browser = null; + }); + } const page = await browser.newPage(); await page.goto(`https://www.youtube.com/watch?v=${id}&has_verified=1`, {