lol

python3Packages.youtube-search-python: patch for httpx >= 0.28 (#396845)

youtube-search-python: fix for proxies issue

authored by

gautaz and committed by
GitHub
a37f0b2e b8e9b34d

+41
+2
pkgs/development/python-modules/youtube-search-python/default.nix
··· 18 18 hash = "sha256-RWjR12ns1+tLuDZfBO7G42TF9w7sezdl9UPa67E1/PU="; 19 19 }; 20 20 21 + patches = [ ./fix-httpx-proxies.patch ]; 22 + 21 23 propagatedBuildInputs = [ httpx ]; 22 24 23 25 pythonImportsCheck = [ "youtubesearchpython" ];
+39
pkgs/development/python-modules/youtube-search-python/fix-httpx-proxies.patch
··· 1 + --- a/youtubesearchpython/core/requests.py 2 + +++ b/youtubesearchpython/core/requests.py 3 + @@ -11,29 +11,28 @@ class RequestCore: 4 + self.proxy = {} 5 + http_proxy = os.environ.get("HTTP_PROXY") 6 + if http_proxy: 7 + - self.proxy["http://"] = http_proxy 8 + + self.proxy["http://"] = httpx.HTTPTransport(proxy=http_proxy) 9 + https_proxy = os.environ.get("HTTPS_PROXY") 10 + if https_proxy: 11 + - self.proxy["https://"] = https_proxy 12 + + self.proxy["https://"] = httpx.HTTPTransport(proxy=https_proxy) 13 + 14 + def syncPostRequest(self) -> httpx.Response: 15 + - return httpx.post( 16 + + return httpx.Client(mounts=self.proxy).post( 17 + self.url, 18 + headers={"User-Agent": userAgent}, 19 + json=self.data, 20 + - timeout=self.timeout, 21 + - proxies=self.proxy 22 + + timeout=self.timeout 23 + ) 24 + 25 + async def asyncPostRequest(self) -> httpx.Response: 26 + - async with httpx.AsyncClient(proxies=self.proxy) as client: 27 + + async with httpx.AsyncClient(mounts=self.proxy) as client: 28 + r = await client.post(self.url, headers={"User-Agent": userAgent}, json=self.data, timeout=self.timeout) 29 + return r 30 + 31 + def syncGetRequest(self) -> httpx.Response: 32 + - return httpx.get(self.url, headers={"User-Agent": userAgent}, timeout=self.timeout, cookies={'CONSENT': 'YES+1'}, proxies=self.proxy) 33 + + return httpx.Client(mounts=self.proxy).get(self.url, headers={"User-Agent": userAgent}, timeout=self.timeout, cookies={'CONSENT': 'YES+1'}) 34 + 35 + async def asyncGetRequest(self) -> httpx.Response: 36 + - async with httpx.AsyncClient(proxies=self.proxy) as client: 37 + + async with httpx.AsyncClient(mounts=self.proxy) as client: 38 + r = await client.get(self.url, headers={"User-Agent": userAgent}, timeout=self.timeout, cookies={'CONSENT': 'YES+1'}) 39 + return r