Skip to content

Bulk asynchronous downloader for multiple file hosts

Vet for proper ddos-guard protection (easier diagnostics in the log)

Jules-WinnfieldX37a716ef18f7
diff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.py
index 4c6dbfd35..585c83e30 100644
--- a/cyberdrop_dl/__init__.py
+++ b/cyberdrop_dl/__init__.py
@@ -1 +1 @@
-__version__ = "4.2.159"
+__version__ = "4.2.161"
diff --git a/cyberdrop_dl/client/client.py b/cyberdrop_dl/client/client.py
index 9c6bec3c3..154c3a3da 100644
--- a/cyberdrop_dl/client/client.py
+++ b/cyberdrop_dl/client/client.py
@@ -227,7 +227,12 @@ class DownloadSession:
assert url.host is not None
await self._throttle(current_throttle, url.host)
async with self.client_session.get(url, headers=headers, ssl=self.client.ssl_context,
- raise_for_status=True) as resp:
+ raise_for_status=False) as resp:
+ if resp.status > 206:
+ if "Server" in resp.headers:
+ if resp.headers["Server"] == "ddos-guard":
+ raise DownloadFailure(status=CustomHTTPStatus.IM_A_TEAPOT, message="DDoS-Guard detected, unable to download")
+ raise DownloadFailure(status=resp.status, message=f"Unexpected status code {resp.status} from {url}")
return int(resp.headers.get('Content-Length', '0'))
async def exit_handler(self) -> None:
diff --git a/cyberdrop_dl/crawlers/Reddit_Spider.py b/cyberdrop_dl/crawlers/Reddit_Spider.py
index 03f887a23..459b469a6 100644
--- a/cyberdrop_dl/crawlers/Reddit_Spider.py
+++ b/cyberdrop_dl/crawlers/Reddit_Spider.py
@@ -47,7 +47,7 @@ class RedditCrawler:
if "user" in url.parts or "u" in url.parts:
await self.get_user(url, domain_obj, reddit)
- elif "r" in url.parts:
+ elif "r" in url.parts and "comments" not in url.parts:
await self.get_subreddit(url, domain_obj, reddit)
elif "i.redd.it" in url.host:
try: