Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
Fix check
Jules-WinnfieldXd9e0c71717c5
diff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.pyindex 1216398d5..ffe704455 100644--- a/cyberdrop_dl/__init__.py+++ b/cyberdrop_dl/__init__.py@@ -1 +1 @@-__version__ = "5.0.107"+__version__ = "5.0.108"diff --git a/cyberdrop_dl/clients/download_client.py b/cyberdrop_dl/clients/download_client.pyindex 8b57ef695..21c7c6db4 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 resp.text())+ await self.client_manager.check_http_status(resp)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, await resp.text(), download=True)+ await self.client_manager.check_http_status(resp, 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.pyindex 390af39b0..c6ed2727e 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 response.text())+ await self.client_manager.check_http_status(response)content_type = response.headers.get('Content-Type')assert content_type is not Noneif 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 response.text())+ await self.client_manager.check_http_status(response)content_type = response.headers.get('Content-Type')assert content_type is not Noneif 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 response.text())+ await self.client_manager.check_http_status(response)content_type = response.headers.get('Content-Type')assert content_type is not Noneif 'json' not in content_type.lower():@@ -88,7 +88,7 @@ class ScraperClient:async with client_session.get(url, headers=self._headers, ssl=self.client_manager.ssl_context,proxy=self.client_manager.proxy) as response:text = await response.text()- await self.client_manager.check_http_status(response.status, response.headers, response.url, text)+ await self.client_manager.check_http_status(response)return text@limiter@@ -96,7 +96,7 @@ class ScraperClient:"""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 response.text())+ await self.client_manager.check_http_status(response)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.pyindex 4c21bfb6d..b27ebaff4 100644--- a/cyberdrop_dl/managers/client_manager.py+++ b/cyberdrop_dl/managers/client_manager.py@@ -7,6 +7,7 @@ from typing import TYPE_CHECKINGimport aiohttpimport certifi+from aiohttp import ClientResponsefrom aiolimiter import AsyncLimiterfrom multidict import CIMultiDictProxyfrom yarl import URL@@ -60,9 +61,12 @@ class ClientManager:"""~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"""- async def check_http_status(self, status: int, headers: CIMultiDictProxy, response_url: URL, response_text: str = None,- download: bool = False) -> None:+ async def check_http_status(self, response: ClientResponse, download: bool = False) -> None:"""Checks the HTTP status code and raises an exception if it's not acceptable"""+ status = response.status+ headers = response.headers+ response_url = response.url+if not headers.get('Content-Type'):raise DownloadFailure(status=CustomHTTPStatus.IM_A_TEAPOT, message="No content-type in response header")@@ -81,6 +85,7 @@ class ClientManager:except ValueError:phrase = "Unknown"+ response_text = await response.text()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/pyproject.toml b/pyproject.tomlindex ca406dcdc..383c3d79a 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[tool.poetry]name = "cyberdrop-dl"-version = "5.0.107"+version = "5.0.108"description = "Bulk downloader for multiple file hosts"authors = ["Jules Winnfield <[email protected]>"]readme = "README.md"