Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Use proxy in get_filesize() (#629)
Browse files Browse the repository at this point in the history
Allows bypassing DDoS Guard for bunkrr and others using external proxies
  • Loading branch information
gashtal authored Nov 21, 2023
1 parent 228c993 commit af7dc9e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cyberdrop_dl/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion cyberdrop_dl/downloader/downloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion cyberdrop_dl/downloader/old_downloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit af7dc9e

Please sign in to comment.