From 04bd88a1f757ef247bc6c82b0c5e9f7514ecf3e1 Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Thu, 23 Jan 2025 21:16:07 +0200 Subject: [PATCH] fix: python-httpx 0.28 --- nhentai/downloader.py | 2 +- nhentai/utils.py | 16 ++++++---------- requirements.txt | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/nhentai/downloader.py b/nhentai/downloader.py index a340c96..d72fb0b 100644 --- a/nhentai/downloader.py +++ b/nhentai/downloader.py @@ -75,7 +75,7 @@ async def download(self, url, folder='', filename='', retried=0, proxy=None, len logger.warning(f'Skipped download: {save_file_path} already exists') return 1, url - response = await async_request('GET', url, timeout=self.timeout, proxies=proxy) + response = await async_request('GET', url, timeout=self.timeout, proxy=proxy) if response.status_code != 200: path = urlparse(url).path diff --git a/nhentai/utils.py b/nhentai/utils.py index 341859f..445ec27 100644 --- a/nhentai/utils.py +++ b/nhentai/utils.py @@ -36,24 +36,20 @@ def request(method, url, **kwargs): return getattr(session, method)(url, verify=False, **kwargs) -async def async_request(method, url, proxies = None, **kwargs): +async def async_request(method, url, proxy = None, **kwargs): headers = { 'Referer': constant.LOGIN_URL, 'User-Agent': constant.CONFIG['useragent'], 'Cookie': constant.CONFIG['cookie'], } - if proxies is None: - proxies = constant.CONFIG['proxy'] + if proxy is None: + proxy = constant.CONFIG['proxy'] - if proxies.get('http') == '' and proxies.get('https') == '': - proxies = None + if proxy is not None and proxy.get('http') == '' and proxy.get('https') == '': + proxy = None - if proxies: - _proxies = {f'{k}://': v for k, v in proxies.items() if v} - proxies = _proxies - - async with httpx.AsyncClient(headers=headers, verify=False, proxies=proxies, **kwargs) as client: + async with httpx.AsyncClient(headers=headers, verify=False, proxy=proxy, **kwargs) as client: response = await client.request(method, url, **kwargs) return response diff --git a/requirements.txt b/requirements.txt index 43ee52e..6437569 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -httpx==0.27.2 +httpx requests soupsieve setuptools