From d98b789beb29d263bb18e31a9ab4b5e3d48631f4 Mon Sep 17 00:00:00 2001 From: Lucas Tiago de Moraes Date: Tue, 28 Jun 2022 22:05:55 -0300 Subject: [PATCH] Added option socks_proxy --- youtubesearchpython/core/requests.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/youtubesearchpython/core/requests.py b/youtubesearchpython/core/requests.py index ea3ed7f..e5d1d54 100644 --- a/youtubesearchpython/core/requests.py +++ b/youtubesearchpython/core/requests.py @@ -9,12 +9,18 @@ def __init__(self): self.data = None self.timeout = 2 self.proxy = {} - http_proxy = os.environ.get("HTTP_PROXY") - if http_proxy: - self.proxy["http://"] = http_proxy - https_proxy = os.environ.get("HTTPS_PROXY") - if https_proxy: - self.proxy["https://"] = https_proxy + + socks_proxy = os.environ.get("SOCKS_PROXY") + if socks_proxy: + self.proxy = socks_proxy + + if self.proxy == {}: + http_proxy = os.environ.get("HTTP_PROXY") + if http_proxy: + self.proxy["http://"] = http_proxy + https_proxy = os.environ.get("HTTPS_PROXY") + if https_proxy: + self.proxy["https://"] = https_proxy def syncPostRequest(self) -> httpx.Response: return httpx.post(