Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: read chunks of equal size

NTFSvolumeef4ec74da02b
diff --git a/cyberdrop_dl/clients/download_client.py b/cyberdrop_dl/clients/download_client.py
index c91604d2c..13b396896 100644
--- a/cyberdrop_dl/clients/download_client.py
+++ b/cyberdrop_dl/clients/download_client.py
@@ -196,7 +196,7 @@ class DownloadClient:
if not media_item.partial_file.is_file():
media_item.partial_file.touch()
async with aiofiles.open(media_item.partial_file, mode="ab") as f: # type: ignore
- async for chunk, _ in content.iter_chunks():
+ async for chunk, _ in content.iter_chunked(self.client_manager.speed_limiter.chunk_size):
chunk_size = len(chunk)
async with self.client_manager.speed_limiter(chunk_size):
await asyncio.sleep(0)
diff --git a/cyberdrop_dl/managers/download_speed_manager.py b/cyberdrop_dl/managers/download_speed_manager.py
index 714b0c9a4..f227e81a6 100644
--- a/cyberdrop_dl/managers/download_speed_manager.py
+++ b/cyberdrop_dl/managers/download_speed_manager.py
@@ -13,6 +13,7 @@ class DownloadSpeedLimiter(AsyncLimiter):
self.download_speed_limit = (
manager.config_manager.global_settings_data.rate_limiting_options.download_speed_limit
)
+ self.chunk_size = 1024 * 1024 * 10 # 10MB
super().__init__(self.download_speed_limit, 1)
async def acquire(self, amount: float = 1) -> None: