Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: check for ddos guard even on successful requests (#132)

NTFSvolumefc1d66688e9a
diff --git a/cyberdrop_dl/ddos_guard.py b/cyberdrop_dl/ddos_guard.py
index 7d265f47d..f64a14737 100644
--- a/cyberdrop_dl/ddos_guard.py
+++ b/cyberdrop_dl/ddos_guard.py
@@ -22,10 +22,13 @@ class _Response(Protocol):
async def text(self) -> str: ...
-async def check(content: _Response | str, /) -> None:
+async def check(content: _Response | str | BeautifulSoup, /) -> None:
if isinstance(content, str):
soup = BeautifulSoup(content, "html.parser")
+ elif isinstance(content, BeautifulSoup):
+ soup = content
+
elif "html" not in content.content_type:
return
diff --git a/cyberdrop_dl/managers/client_manager.py b/cyberdrop_dl/managers/client_manager.py
index 4c77329a7..1ff75167b 100644
--- a/cyberdrop_dl/managers/client_manager.py
+++ b/cyberdrop_dl/managers/client_manager.py
@@ -363,6 +363,7 @@ class ClientManager:
check_etag()
if HTTPStatus.OK <= response.status < HTTPStatus.BAD_REQUEST:
# Check DDosGuard even on successful pages
+ await ddos_guard.check(response)
return
await self._check_json(response)