Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
perf: use aio.run
NTFSvolume174cb3f45f83
diff --git a/cyberdrop_dl/aio.py b/cyberdrop_dl/aio.pyindex ac50b58bb..5155ab561 100644--- a/cyberdrop_dl/aio.py+++ b/cyberdrop_dl/aio.py@@ -8,11 +8,10 @@ import contextlibimport dataclassesimport functoolsimport shutil-import tempfileimport timefrom pathlib import Pathfrom stat import S_ISREG-from typing import IO, TYPE_CHECKING, Any, AnyStr, Self, cast, overload+from typing import IO, TYPE_CHECKING, Any, Self, cast, overloadfrom weakref import WeakValueDictionaryfrom aiolimiter.leakybucket import AsyncLimiter@@ -422,6 +421,8 @@ async def get_size(path: Path) -> int | None:@contextlib.asynccontextmanagerasync def temp_dir() -> AsyncGenerator[Path]:+ import tempfile+temp_dir = await asyncio.to_thread(tempfile.TemporaryDirectory, prefix="cdl_", ignore_cleanup_errors=True)try:yield Path(temp_dir.name)diff --git a/cyberdrop_dl/program_ui.py b/cyberdrop_dl/program_ui.pyindex be7861241..dfca3a1d5 100644--- a/cyberdrop_dl/program_ui.py+++ b/cyberdrop_dl/program_ui.py@@ -1,6 +1,5 @@from __future__ import annotations-import asyncioimport osimport sysfrom pathlib import Path@@ -14,7 +13,7 @@ from rich.console import Consolefrom rich.markdown import Markdownfrom rich.text import Text-from cyberdrop_dl import __version__, stats+from cyberdrop_dl import __version__, aio, statsfrom cyberdrop_dl.hasher import Hasher, hash_directoryfrom cyberdrop_dl.progress import hyperlinkfrom cyberdrop_dl.sorter import Sorter@@ -64,7 +63,7 @@ _console = _ConsoleWrapper()def _changelog() -> str:global _changelog_content # noqa: PLW0603if not _changelog_content:- _changelog_content = asyncio.run(_fetch_changelog())+ _changelog_content = aio.run(_fetch_changelog())return _changelog_content@@ -94,7 +93,7 @@ def _scan_and_create_hashes(manager: Manager) -> None:default=manager.config.download_folder,)hasher = Hasher.create(manager.config, manager.database, path)- hash_stats = asyncio.run(hash_directory(hasher))+ hash_stats = aio.run(hash_directory(hasher))stats.print(hash_stats)_enter_to_continue()@@ -105,7 +104,7 @@ def _sort_files(manager: Manager) -> None:f"You are about to sort files from '{sorter.input_dir}' to '{sorter.output_dir}'",)if _ask_confirmation(explicit=True):- asyncio.run(sorter.run())+ aio.run(sorter.run())_enter_to_continue()