From 254f2cf1ab7cd1af15bf87c9f23436b807b99ed0 Mon Sep 17 00:00:00 2001 From: killer069 <65385476+killer069@users.noreply.github.com> Date: Thu, 2 Dec 2021 12:14:34 +0530 Subject: [PATCH] 429 Errors Removed --- play-dl/YouTube/search.ts | 6 +++++- play-dl/YouTube/utils/extractor.ts | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/play-dl/YouTube/search.ts b/play-dl/YouTube/search.ts index 22c4e29..ea673ea 100644 --- a/play-dl/YouTube/search.ts +++ b/play-dl/YouTube/search.ts @@ -38,7 +38,11 @@ export async function yt_search(search: string, options: ParseSearchInterface = } } const body = await request(url, { - headers: { 'accept-language': 'en-US,en-IN;q=0.9,en;q=0.8,hi;q=0.7' } + headers: { + 'accept-language': 'en-US,en-IN;q=0.9,en;q=0.8,hi;q=0.7', + 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36', + 'accept-encoding' : 'gzip, deflate, br' + } }); if (body.indexOf('Our systems have detected unusual traffic from your computer network.') !== -1) throw new Error('Captcha page: YouTube has detected that you are a bot!'); diff --git a/play-dl/YouTube/utils/extractor.ts b/play-dl/YouTube/utils/extractor.ts index 129e11a..85af649 100644 --- a/play-dl/YouTube/utils/extractor.ts +++ b/play-dl/YouTube/utils/extractor.ts @@ -124,7 +124,11 @@ export async function video_basic_info(url: string, options: InfoOptions = {}): const new_url = `https://www.youtube.com/watch?v=${video_id}&has_verified=1`; body = await request(new_url, { proxies: options.proxy ?? [], - headers: { 'accept-language': 'en-US,en-IN;q=0.9,en;q=0.8,hi;q=0.7' }, + headers: { + 'accept-language': 'en-US,en-IN;q=0.9,en;q=0.8,hi;q=0.7', + 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36', + 'accept-encoding' : 'gzip, deflate, br' + }, cookies: true }); } @@ -323,7 +327,11 @@ export async function playlist_info(url: string, options: PlaylistOptions = {}): const body = await request(new_url, { proxies: options.proxy ?? undefined, - headers: { 'accept-language': 'en-US,en-IN;q=0.9,en;q=0.8,hi;q=0.7' } + headers: { + 'accept-language': 'en-US,en-IN;q=0.9,en;q=0.8,hi;q=0.7', + 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36', + 'accept-encoding' : 'gzip, deflate, br' + } }); if (body.indexOf('Our systems have detected unusual traffic from your computer network.') !== -1) throw new Error('Captcha page: YouTube has detected that you are a bot!');