mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-20 02:41:19 +02:00
fix: python-httpx 0.28
This commit is contained in:
parent
a83c571ec4
commit
04bd88a1f7
@ -75,7 +75,7 @@ class Downloader(Singleton):
|
|||||||
logger.warning(f'Skipped download: {save_file_path} already exists')
|
logger.warning(f'Skipped download: {save_file_path} already exists')
|
||||||
return 1, url
|
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:
|
if response.status_code != 200:
|
||||||
path = urlparse(url).path
|
path = urlparse(url).path
|
||||||
|
@ -36,24 +36,20 @@ def request(method, url, **kwargs):
|
|||||||
return getattr(session, method)(url, verify=False, **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 = {
|
headers = {
|
||||||
'Referer': constant.LOGIN_URL,
|
'Referer': constant.LOGIN_URL,
|
||||||
'User-Agent': constant.CONFIG['useragent'],
|
'User-Agent': constant.CONFIG['useragent'],
|
||||||
'Cookie': constant.CONFIG['cookie'],
|
'Cookie': constant.CONFIG['cookie'],
|
||||||
}
|
}
|
||||||
|
|
||||||
if proxies is None:
|
if proxy is None:
|
||||||
proxies = constant.CONFIG['proxy']
|
proxy = constant.CONFIG['proxy']
|
||||||
|
|
||||||
if proxies.get('http') == '' and proxies.get('https') == '':
|
if proxy is not None and proxy.get('http') == '' and proxy.get('https') == '':
|
||||||
proxies = None
|
proxy = None
|
||||||
|
|
||||||
if proxies:
|
async with httpx.AsyncClient(headers=headers, verify=False, proxy=proxy, **kwargs) as client:
|
||||||
_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:
|
|
||||||
response = await client.request(method, url, **kwargs)
|
response = await client.request(method, url, **kwargs)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
httpx==0.27.2
|
httpx
|
||||||
requests
|
requests
|
||||||
soupsieve
|
soupsieve
|
||||||
setuptools
|
setuptools
|
||||||
|
Loading…
x
Reference in New Issue
Block a user