Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
fix: do not timeout when downloading very large files (#1189)
NTFSvolumef66904ec9d63
diff --git a/cyberdrop_dl/config/global_model.py b/cyberdrop_dl/config/global_model.pyindex 1a268e7dd..02826117a 100755--- a/cyberdrop_dl/config/global_model.py+++ b/cyberdrop_dl/config/global_model.py@@ -77,7 +77,8 @@ class RateLimiting(BaseModel):def model_post_init(self, *_) -> None:self._timeout = Timeout(self.connection_timeout, self.read_timeout)- self._aiohttp_timeout = aiohttp.ClientTimeout(self._timeout.total, self._timeout.connect)+ self._scrape_timeout = aiohttp.ClientTimeout(total=self._timeout.total, connect=self._timeout.connect)+ self._download_timeout = aiohttp.ClientTimeout(total=None, connect=self._timeout.connect, sock_read=20)@field_validator("file_host_cache_expire_after", "forum_cache_expire_after", mode="before")@staticmethoddiff --git a/cyberdrop_dl/downloader/mega_nz.py b/cyberdrop_dl/downloader/mega_nz.pyindex 23d4e0e8b..512410051 100644--- a/cyberdrop_dl/downloader/mega_nz.py+++ b/cyberdrop_dl/downloader/mega_nz.py@@ -835,6 +835,13 @@ class MegaDownloadClient(DownloadClient):return asyncio.to_thread(prepare)+ async def download_file(self, manager: Manager, domain: str, media_item: MediaItem) -> bool:+ try:+ return await super().download_file(manager, domain, media_item)+ except DownloadError as e:+ e.retry = False # can not retry+ raise e+class MegaDownloader(Downloader):def __init__(self, manager: Manager, domain: str) -> None:diff --git a/cyberdrop_dl/managers/client_manager.py b/cyberdrop_dl/managers/client_manager.pyindex e1b8c223c..5d3497e18 100644--- a/cyberdrop_dl/managers/client_manager.py+++ b/cyberdrop_dl/managers/client_manager.py@@ -164,13 +164,19 @@ class ClientManager:def _new_session(self, cached: bool = False, trace_configs: list[aiohttp.TraceConfig] | None = None) -> CachedSession | ClientSession:- session_cls = CachedSession if cached else ClientSession- kwargs: dict[str, Any] = {"cache": self.manager.cache_manager.request_cache} if cached else {}+ if cached:+ timeout = self.manager.global_config.rate_limiting_options._scrape_timeout+ session_cls = CachedSession+ kwargs: dict[str, Any] = {"cache": self.manager.cache_manager.request_cache}+ else:+ timeout = self.manager.global_config.rate_limiting_options._download_timeout+ session_cls = ClientSession+ kwargs = {}return session_cls(headers=self._headers,raise_for_status=False,cookie_jar=self.cookies,- timeout=self.manager.global_config.rate_limiting_options._aiohttp_timeout,+ timeout=timeout,trace_configs=trace_configs,proxy=self.manager.global_config.general.proxy,connector=self._new_tcp_connector(),@@ -392,7 +398,7 @@ class Flaresolverr:return await self._make_request(command, client_session, **kwargs)async def _make_request(self, command: str, client_session: ClientSession, **kwargs) -> dict[str, Any]:- timeout = self.client_manager.manager.global_config.rate_limiting_options._aiohttp_timeout+ timeout = self.client_manager.manager.global_config.rate_limiting_options._scrape_timeoutif command == "sessions.create":timeout = aiohttp.ClientTimeout(total=5 * 60, connect=60) # 5 minutes to create session