Skip to content

Bulk asynchronous downloader for multiple file hosts

Explicitly say DDOS-Guard when DDOS-Guard, remove "completed" word from stats

Jules-WinnfieldX49bb2ec8e532
diff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.py
index 0f6b89651..1216398d5 100644
--- a/cyberdrop_dl/__init__.py
+++ b/cyberdrop_dl/__init__.py
@@ -1 +1 @@
-__version__ = "5.0.106"
+__version__ = "5.0.107"
diff --git a/cyberdrop_dl/clients/download_client.py b/cyberdrop_dl/clients/download_client.py
index c9c80560a..8b57ef695 100644
--- a/cyberdrop_dl/clients/download_client.py
+++ b/cyberdrop_dl/clients/download_client.py
@@ -60,7 +60,7 @@ class DownloadClient:
async with client_session.get(media_item.url, headers=headers, ssl=self.client_manager.ssl_context,
proxy=self.client_manager.proxy) as resp:
- await self.client_manager.check_http_status(resp.status, resp.headers, resp.url)
+ await self.client_manager.check_http_status(resp.status, resp.headers, resp.url, await resp.text())
return int(resp.headers.get('Content-Length', '0'))
"""~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"""
@@ -78,7 +78,7 @@ class DownloadClient:
async with client_session.get(media_item.url, headers=headers, ssl=self.client_manager.ssl_context,
proxy=self.client_manager.proxy) as resp:
- await self.client_manager.check_http_status(resp.status, resp.headers, resp.url, download=True)
+ await self.client_manager.check_http_status(resp.status, resp.headers, resp.url, await resp.text(), download=True)
content_type = resp.headers.get('Content-Type')
ext = Path(media_item.filename).suffix.lower()
if any(s in content_type.lower() for s in ('html', 'text')) and ext not in FILE_FORMATS['Text']:
diff --git a/cyberdrop_dl/clients/scraper_client.py b/cyberdrop_dl/clients/scraper_client.py
index cda4225f4..390af39b0 100644
--- a/cyberdrop_dl/clients/scraper_client.py
+++ b/cyberdrop_dl/clients/scraper_client.py
@@ -47,7 +47,7 @@ class ScraperClient:
"""Returns a BeautifulSoup object from the given URL"""
async with client_session.get(url, headers=self._headers, ssl=self.client_manager.ssl_context,
proxy=self.client_manager.proxy) as response:
- await self.client_manager.check_http_status(response.status, response.headers, response.url)
+ await self.client_manager.check_http_status(response.status, response.headers, response.url, await response.text())
content_type = response.headers.get('Content-Type')
assert content_type is not None
if not any(s in content_type.lower() for s in ("html", "text")):
@@ -60,7 +60,7 @@ class ScraperClient:
"""Returns a BeautifulSoup object and response URL from the given URL"""
async with client_session.get(url, headers=self._headers, ssl=self.client_manager.ssl_context,
proxy=self.client_manager.proxy) as response:
- await self.client_manager.check_http_status(response.status, response.headers, response.url)
+ await self.client_manager.check_http_status(response.status, response.headers, response.url, await response.text())
content_type = response.headers.get('Content-Type')
assert content_type is not None
if not any(s in content_type.lower() for s in ("html", "text")):
@@ -75,7 +75,7 @@ class ScraperClient:
async with client_session.get(url, headers=headers, ssl=self.client_manager.ssl_context,
proxy=self.client_manager.proxy, params=params) as response:
- await self.client_manager.check_http_status(response.status, response.headers, response.url)
+ await self.client_manager.check_http_status(response.status, response.headers, response.url, await response.text())
content_type = response.headers.get('Content-Type')
assert content_type is not None
if 'json' not in content_type.lower():
@@ -87,15 +87,16 @@ class ScraperClient:
"""Returns a text object from the given URL"""
async with client_session.get(url, headers=self._headers, ssl=self.client_manager.ssl_context,
proxy=self.client_manager.proxy) as response:
- await self.client_manager.check_http_status(response.status, response.headers, response.url)
- return await response.text()
+ text = await response.text()
+ await self.client_manager.check_http_status(response.status, response.headers, response.url, text)
+ return text
@limiter
async def post_data(self, domain: str, url: URL, client_session: ClientSession, data: Dict, req_resp: bool = True) -> Dict:
"""Returns a JSON object from the given URL when posting data"""
async with client_session.post(url, headers=self._headers, ssl=self.client_manager.ssl_context,
proxy=self.client_manager.proxy, data=data) as response:
- await self.client_manager.check_http_status(response.status, response.headers, response.url)
+ await self.client_manager.check_http_status(response.status, response.headers, response.url, await response.text())
if req_resp:
return json.loads(await response.content.read())
else:
diff --git a/cyberdrop_dl/managers/client_manager.py b/cyberdrop_dl/managers/client_manager.py
index 301e7f00c..4c21bfb6d 100644
--- a/cyberdrop_dl/managers/client_manager.py
+++ b/cyberdrop_dl/managers/client_manager.py
@@ -60,7 +60,7 @@ class ClientManager:
"""~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"""
- async def check_http_status(self, status: int, headers: CIMultiDictProxy, response_url: URL,
+ async def check_http_status(self, status: int, headers: CIMultiDictProxy, response_url: URL, response_text: str = None,
download: bool = False) -> None:
"""Checks the HTTP status code and raises an exception if it's not acceptable"""
if not headers.get('Content-Type'):
@@ -81,4 +81,6 @@ class ClientManager:
except ValueError:
phrase = "Unknown"
+ if "<title>DDoS-Guard</title>" in response_text:
+ raise DownloadFailure(status="DDOS-Guard", message="DDoS-Guard detected")
raise DownloadFailure(status=status, message=f"HTTP status code {status}: {phrase}")
diff --git a/cyberdrop_dl/ui/progress/downloads_progress.py b/cyberdrop_dl/ui/progress/downloads_progress.py
index e03da0f7b..6a5542aaa 100644
--- a/cyberdrop_dl/ui/progress/downloads_progress.py
+++ b/cyberdrop_dl/ui/progress/downloads_progress.py
@@ -12,7 +12,7 @@ class DownloadsProgress:
self.progress = Progress("[progress.description]{task.description}",
BarColumn(bar_width=None),
"[progress.percentage]{task.percentage:>3.2f}%",
- "{task.completed} of {task.total} Files Completed")
+ "{task.completed} of {task.total} Files")
self.progress_group = Group(self.progress)
self.total_files = 0
diff --git a/cyberdrop_dl/ui/progress/statistic_progress.py b/cyberdrop_dl/ui/progress/statistic_progress.py
index 702e176b1..a1a5d9aa2 100644
--- a/cyberdrop_dl/ui/progress/statistic_progress.py
+++ b/cyberdrop_dl/ui/progress/statistic_progress.py
@@ -12,7 +12,7 @@ class DownloadStatsProgress:
self.progress = Progress("[progress.description]{task.description}",
BarColumn(bar_width=None),
"[progress.percentage]{task.percentage:>3.2f}%",
- "{task.completed} of {task.total} Files Completed")
+ "{task.completed} of {task.total} Files")
self.progress_group = Group(self.progress)
self.failure_types: Dict[str, TaskID] = {}
@@ -54,7 +54,7 @@ class ScrapeStatsProgress:
self.progress = Progress("[progress.description]{task.description}",
BarColumn(bar_width=None),
"[progress.percentage]{task.percentage:>3.2f}%",
- "{task.completed} of {task.total} Files Completed")
+ "{task.completed} of {task.total} Files")
self.progress_group = Group(self.progress)
self.failure_types: Dict[str, TaskID] = {}
diff --git a/pyproject.toml b/pyproject.toml
index eb9c713b5..ca406dcdc 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cyberdrop-dl"
-version = "5.0.106"
+version = "5.0.107"
description = "Bulk downloader for multiple file hosts"
authors = ["Jules Winnfield <[email protected]>"]
readme = "README.md"