From af7dc9e3c9f6845244db899da175f4443f1a4bde Mon Sep 17 00:00:00 2001 From: gashtal Date: Tue, 21 Nov 2023 07:35:50 -0800 Subject: [PATCH] Use proxy in get_filesize() (#629) Allows bypassing DDoS Guard for bunkrr and others using external proxies --- cyberdrop_dl/client/client.py | 4 ++-- cyberdrop_dl/downloader/downloaders.py | 2 +- cyberdrop_dl/downloader/old_downloaders.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cyberdrop_dl/client/client.py b/cyberdrop_dl/client/client.py index 57b9de72f..c3719dbc5 100644 --- a/cyberdrop_dl/client/client.py +++ b/cyberdrop_dl/client/client.py @@ -230,14 +230,14 @@ async def save_content(content: aiohttp.StreamReader) -> None: await self._download(media, current_throttle, proxy, headers, save_content, file) - async def get_filesize(self, url: URL, referer: str, current_throttle: float, headers: Dict) -> int: + async def get_filesize(self, url: URL, referer: str, current_throttle: float, headers: Dict, proxy: str) -> int: headers['Referer'] = referer headers['user-agent'] = self.client.user_agent 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=False) as resp: + raise_for_status=False, proxy=proxy) as resp: if resp.status > 206: if "Server" in resp.headers: if resp.headers["Server"] == "ddos-guard": diff --git a/cyberdrop_dl/downloader/downloaders.py b/cyberdrop_dl/downloader/downloaders.py index 611fedb2b..b1525bafb 100644 --- a/cyberdrop_dl/downloader/downloaders.py +++ b/cyberdrop_dl/downloader/downloaders.py @@ -328,7 +328,7 @@ async def check_file_exists(self, complete_file: Path, partial_file: Path, media while True: if not expected_size: expected_size = await self.download_session.get_filesize(media.url, str(media.referer), - current_throttle, headers) + current_throttle, headers, self.CDL_Helper.proxy) if not complete_file.exists() and not partial_file.exists(): break diff --git a/cyberdrop_dl/downloader/old_downloaders.py b/cyberdrop_dl/downloader/old_downloaders.py index 6408a25ad..061dc9838 100644 --- a/cyberdrop_dl/downloader/old_downloaders.py +++ b/cyberdrop_dl/downloader/old_downloaders.py @@ -288,7 +288,7 @@ async def check_file_exists(self, complete_file: Path, partial_file: Path, media while True: if not expected_size: expected_size = await self.download_session.get_filesize(media.url, str(media.referer), - current_throttle, headers) + current_throttle, headers, self.proxy) if not complete_file.exists() and not partial_file.exists(): break