Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: remove aiofiles dependency (#163)

NTFSvolume7b4a9646f804
diff --git a/cyberdrop_dl/clients/download_client.py b/cyberdrop_dl/clients/download_client.py
index d497be86c..aafbca63e 100644
--- a/cyberdrop_dl/clients/download_client.py
+++ b/cyberdrop_dl/clients/download_client.py
@@ -9,8 +9,6 @@ from collections.abc import Generator
from http import HTTPStatus
from typing import TYPE_CHECKING, Any
-import aiofiles
-
from cyberdrop_dl import aio, constants, storage
from cyberdrop_dl.clients.response import AbstractResponse
from cyberdrop_dl.constants import FileExt
@@ -218,7 +216,7 @@ class DownloadClient:
await check_free_space()
await self._pre_download_check(media_item)
- async with aiofiles.open(media_item.partial_file, mode="ab") as f:
+ async with aio.open(media_item.partial_file, mode="ab") as f:
async for chunk in content.iter_chunked(self.client_manager.speed_limiter.chunk_size):
await check_free_space()
chunk_size = len(chunk)
diff --git a/cyberdrop_dl/downloader/mega_nz.py b/cyberdrop_dl/downloader/mega_nz.py
index 224f06b79..d55ed834a 100644
--- a/cyberdrop_dl/downloader/mega_nz.py
+++ b/cyberdrop_dl/downloader/mega_nz.py
@@ -3,7 +3,6 @@ from __future__ import annotations
import asyncio
from typing import TYPE_CHECKING, final
-import aiofiles
from mega.chunker import MegaChunker, get_chunks
from cyberdrop_dl import aio, storage
@@ -38,7 +37,7 @@ class MegaDownloadClient(DownloadClient):
crypto, file_size = self._decrypt_mapping.pop(media_item.url)
chunk_decryptor = MegaChunker(crypto.key, crypto.iv, crypto.meta_mac)
- async with aiofiles.open(media_item.partial_file, mode="ab") as f:
+ async with aio.open(media_item.partial_file, mode="ab") as f:
for _, chunk_size in get_chunks(file_size):
raw_chunk = await content.readexactly(chunk_size)
chunk = chunk_decryptor.read(raw_chunk)
diff --git a/cyberdrop_dl/scrape_mapper.py b/cyberdrop_dl/scrape_mapper.py
index 29e2aa559..952f1bbac 100644
--- a/cyberdrop_dl/scrape_mapper.py
+++ b/cyberdrop_dl/scrape_mapper.py
@@ -10,8 +10,6 @@ import time
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal, Self, TypeVar
-import aiofiles
-
from cyberdrop_dl import aio, plugins, storage
from cyberdrop_dl.clients.jdownloader import JDownloader
from cyberdrop_dl.constants import BlockedDomains
@@ -372,7 +370,7 @@ async def _parse_input_file_groups(input_file: Path) -> AsyncGenerator[tuple[str
block_quote = False
current_group_name = ""
- async with aiofiles.open(input_file, encoding="utf8") as f:
+ async with aio.open(input_file, encoding="utf8") as f:
async for line in f:
if line.startswith(("---", "===")): # New group begins here
current_group_name = line.replace("---", "").replace("===", "").strip()
diff --git a/pyproject.toml b/pyproject.toml
index 44e4fb507..e084f9f16 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -10,7 +10,6 @@ classifiers = [
]
dependencies = [
"aiodns >=4.0.0; sys_platform != 'android'",
- "aiofiles >=25.1.0",
"aiohttp >=3.13.5",
"aiolimiter >=1.2.1",
"aiosqlite>=0.22.1",
@@ -44,7 +43,7 @@ license = "GPL-3.0-only"
license-files = ["LICENSE"]
readme = "README.md"
requires-python = ">=3.11"
-version = "9.2.1.dev0"
+version = "9.2.1.dev1"
[project.optional-dependencies]
extras = [
diff --git a/uv.lock b/uv.lock
index bd93a360d..8b106d8a5 100644
--- a/uv.lock
+++ b/uv.lock
@@ -19,15 +19,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/d0/60/14ac40c03e8a26216e4f2642497b776e52f9e3214e4fd537628829bbb082/aiodns-4.0.0-py3-none-any.whl", hash = "sha256:a188a75fb8b2b7862ac8f84811a231402fb74f5b4e6f10766dc8a4544b0cf989", size = 11334, upload-time = "2026-01-10T22:33:25.65Z" },
]
-[[package]]
-name = "aiofiles"
-version = "25.1.0"
-source = { registry = "https://pypi.org/simple" }
-sdist = { url = "https://files.pythonhosted.org/packages/41/c3/534eac40372d8ee36ef40df62ec129bee4fdb5ad9706e58a29be53b2c970/aiofiles-25.1.0.tar.gz", hash = "sha256:a8d728f0a29de45dc521f18f07297428d56992a742f0cd2701ba86e44d23d5b2", size = 46354, upload-time = "2025-10-09T20:51:04.358Z" }
-wheels = [
- { url = "https://files.pythonhosted.org/packages/bc/8a/340a1555ae33d7354dbca4faa54948d76d89a27ceef032c8c3bc661d003e/aiofiles-25.1.0-py3-none-any.whl", hash = "sha256:abe311e527c862958650f9438e859c1fa7568a141b22abcd015e120e86a85695", size = 14668, upload-time = "2025-10-09T20:51:03.174Z" },
-]
-
[[package]]
name = "aiohappyeyeballs"
version = "2.6.1"
@@ -743,11 +734,10 @@ wheels = [
[[package]]
name = "cyberdrop-dl-patched"
-version = "9.2.1.dev0"
+version = "9.2.1.dev1"
source = { editable = "." }
dependencies = [
{ name = "aiodns", marker = "sys_platform != 'android'" },
- { name = "aiofiles" },
{ name = "aiohttp" },
{ name = "aiolimiter" },
{ name = "aiosqlite" },
@@ -797,7 +787,6 @@ dev = [
[package.metadata]
requires-dist = [
{ name = "aiodns", marker = "sys_platform != 'android'", specifier = ">=4.0.0" },
- { name = "aiofiles", specifier = ">=25.1.0" },
{ name = "aiohttp", specifier = ">=3.13.5" },
{ name = "aiolimiter", specifier = ">=1.2.1" },
{ name = "aiosqlite", specifier = ">=0.22.1" },