Skip to content

Commit ecc45e7

Browse files
committed
images from proxy update
1 parent d8ed3d5 commit ecc45e7

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

chizhik_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .manager import ChizhikAPI
22

33
__all__ = ["ChizhikAPI"]
4-
__version__ = "0.2.3"
4+
__version__ = "0.2.3.1"

chizhik_api/endpoints/general.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from io import BytesIO
44
from typing import TYPE_CHECKING
55

6+
from human_requests.abstraction import Proxy
67
from aiohttp_retry import ExponentialRetry, RetryClient
78

89
if TYPE_CHECKING:
@@ -24,12 +25,14 @@ async def download_image(
2425
self, url: str, retry_attempts: int = 3, timeout: float = 10
2526
) -> BytesIO:
2627
"""Скачать изображение по URL."""
28+
proxy = Proxy(self.proxy).as_str() if self._parent.proxy else None
29+
2730
retry_options = ExponentialRetry(
2831
attempts=retry_attempts, start_timeout=3.0, max_timeout=timeout
2932
)
3033

3134
async with RetryClient(retry_options=retry_options) as retry_client:
32-
async with retry_client.get(url, raise_for_status=True) as resp:
35+
async with retry_client.get(url, raise_for_status=True, proxy=proxy) as resp:
3336
body = await resp.read()
3437
file = BytesIO(body)
3538
file.name = url.split("/")[-1]

0 commit comments

Comments
 (0)