Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
test: update for max invalid responses (flaresolverr)
NTFSvolume7291f2e1b3ab
diff --git a/cyberdrop_dl/clients/flaresolverr.py b/cyberdrop_dl/clients/flaresolverr.pyindex bc1a85d04..03cf5670a 100644--- a/cyberdrop_dl/clients/flaresolverr.py+++ b/cyberdrop_dl/clients/flaresolverr.py@@ -8,7 +8,7 @@ import timefrom contextvars import ContextVarfrom enum import StrEnumfrom http.cookies import SimpleCookie-from typing import TYPE_CHECKING, Any, Literal, Self, TypedDict, Unpack+from typing import TYPE_CHECKING, Any, ClassVar, Literal, Self, TypedDict, Unpackimport aiohttpfrom multidict import CIMultiDict, CIMultiDictProxy@@ -178,6 +178,8 @@ class Limiter:class Client:"""Class that handles communication with Flaresolverr."""+ MAX_INVALID_RESPONSES: ClassVar[int] = 5+def __init__(self, http: aiohttp.ClientSession, config: Config) -> None:self.http: aiohttp.ClientSession = httpself.config: Config = config@@ -218,8 +220,8 @@ class Client:raiseexcept _InvalidResponseError:self._invalid_responses += 1- if self._invalid_responses > (max_wrong := 5):- self.disable(f"Too many invalid/missing solutions [{max_wrong}+]")+ if self._invalid_responses > self.MAX_INVALID_RESPONSES:+ self.disable(f"Too many invalid/missing solutions [{self.MAX_INVALID_RESPONSES}+]")raiseexcept Exception:self.disable()diff --git a/tests/test_flaresolverr.py b/tests/test_flaresolverr.pyindex c36c11ae7..f1b962e21 100644--- a/tests/test_flaresolverr.py+++ b/tests/test_flaresolverr.py@@ -200,8 +200,10 @@ async def test_request_error_response(async with aiohttp.ClientSession() as session:client = Client(session, _config(proxy=False, use_session=False))monkeypatch.setattr(client, "_request", fake_request)- with pytest.raises(expected_error):- await client.request(AbsoluteHttpURL("https://example.com"))+ for _ in range(client.MAX_INVALID_RESPONSES + 1):+ assert client.is_down is False+ with pytest.raises(expected_error):+ await client.request(AbsoluteHttpURL("https://example.com"))assert client.is_down is disabled