python3-youtubesearch: patch for httpx
This commit is contained in:
parent
76342e9d80
commit
1af3517672
|
@ -0,0 +1,50 @@
|
|||
commit 396c9047acff7619daa1c9f3fb665d4471348b44
|
||||
Author: Andrew Benson <abenson@gmail.com>
|
||||
Date: Fri Dec 20 15:14:01 2024 -0600
|
||||
|
||||
Use new proxy config for httpx.
|
||||
|
||||
diff --git a/youtubesearchpython/core/requests.py b/youtubesearchpython/core/requests.py
|
||||
index ea3ed7f..87715f3 100644
|
||||
--- a/youtubesearchpython/core/requests.py
|
||||
+++ b/youtubesearchpython/core/requests.py
|
||||
@@ -8,13 +8,13 @@ class RequestCore:
|
||||
self.url = None
|
||||
self.data = None
|
||||
self.timeout = 2
|
||||
- self.proxy = {}
|
||||
+ self.proxy = None
|
||||
http_proxy = os.environ.get("HTTP_PROXY")
|
||||
if http_proxy:
|
||||
- self.proxy["http://"] = http_proxy
|
||||
+ self.proxy = http_proxy
|
||||
https_proxy = os.environ.get("HTTPS_PROXY")
|
||||
if https_proxy:
|
||||
- self.proxy["https://"] = https_proxy
|
||||
+ self.proxy = https_proxy
|
||||
|
||||
def syncPostRequest(self) -> httpx.Response:
|
||||
return httpx.post(
|
||||
@@ -22,18 +22,18 @@ class RequestCore:
|
||||
headers={"User-Agent": userAgent},
|
||||
json=self.data,
|
||||
timeout=self.timeout,
|
||||
- proxies=self.proxy
|
||||
+ proxy=self.proxy
|
||||
)
|
||||
|
||||
async def asyncPostRequest(self) -> httpx.Response:
|
||||
- async with httpx.AsyncClient(proxies=self.proxy) as client:
|
||||
+ async with httpx.AsyncClient(proxy=self.proxy) as client:
|
||||
r = await client.post(self.url, headers={"User-Agent": userAgent}, json=self.data, timeout=self.timeout)
|
||||
return r
|
||||
|
||||
def syncGetRequest(self) -> httpx.Response:
|
||||
- return httpx.get(self.url, headers={"User-Agent": userAgent}, timeout=self.timeout, cookies={'CONSENT': 'YES+1'}, proxies=self.proxy)
|
||||
+ return httpx.get(self.url, headers={"User-Agent": userAgent}, timeout=self.timeout, cookies={'CONSENT': 'YES+1'}, proxy=self.proxy)
|
||||
|
||||
async def asyncGetRequest(self) -> httpx.Response:
|
||||
- async with httpx.AsyncClient(proxies=self.proxy) as client:
|
||||
+ async with httpx.AsyncClient(proxy=self.proxy) as client:
|
||||
r = await client.get(self.url, headers={"User-Agent": userAgent}, timeout=self.timeout, cookies={'CONSENT': 'YES+1'})
|
||||
return r
|
|
@ -1,7 +1,7 @@
|
|||
# Template file for 'python3-youtubesearch'
|
||||
pkgname=python3-youtubesearch
|
||||
version=1.6.6
|
||||
revision=4
|
||||
revision=5
|
||||
build_style=python3-module
|
||||
hostmakedepends="python3-setuptools"
|
||||
depends="python3-httpx"
|
||||
|
|
Loading…
Reference in New Issue