Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
Add adjustable connection timeout.
Jules-WinnfieldX7082a5656ec2
diff --git a/README.md b/README.mdindex cceb4c38a..867340558 100644--- a/README.md+++ b/README.md@@ -85,6 +85,7 @@ optional arguments:--db-file history DB file to write to--threads THREADS number of threads to use (0 = max)--attempts ATTEMPTS number of attempts to download each file+ --connection-timeout number of seconds to wait attempting to connect to a URL during the downloading phase--disable-attempt-limit disables stopping the program based on attempt limits--include-id include the ID in the download folder name--exclude-videos exclude video files from downloadingdiff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.pyindex 158a549eb..807710503 100644--- a/cyberdrop_dl/__init__.py+++ b/cyberdrop_dl/__init__.py@@ -1 +1 @@-__version__ = "3.3.8"+__version__ = "3.3.9"diff --git a/cyberdrop_dl/client/client.py b/cyberdrop_dl/client/client.pyindex f3621cd36..9c45fbe92 100644--- a/cyberdrop_dl/client/client.py+++ b/cyberdrop_dl/client/client.py@@ -84,11 +84,12 @@ class Session:class DownloadSession:- def __init__(self, client):+ def __init__(self, client: Client, conn_timeout: int):self.client = clientself.headers = {"user-agent": client.user_agent}+ self.timeouts = aiohttp.ClientTimeout(5*60, conn_timeout)self.client_session = aiohttp.ClientSession(headers=self.headers, raise_for_status=True,- cookie_jar=self.client.cookies)+ cookie_jar=self.client.cookies, timeout=self.timeouts)self.throttle_times = {}async def get_filename(self, url: URL, referer: str, current_throttle: int):diff --git a/cyberdrop_dl/client/downloaders.py b/cyberdrop_dl/client/downloaders.pyindex 88af1ff94..9feccb0a9 100644--- a/cyberdrop_dl/client/downloaders.py+++ b/cyberdrop_dl/client/downloaders.py@@ -263,9 +263,9 @@ class Downloader:for func in tqdm(asyncio.as_completed(coros), total=len(coros), desc=self.title, unit='FILES'):await func- async def download_content(self, show_progress: bool = True) -> None:+ async def download_content(self, show_progress: bool = True, conn_timeout: int = 15) -> None:"""Download the content of all links and save them as files."""- session = DownloadSession(self.client)+ session = DownloadSession(self.client, conn_timeout)await self.download_all(self.album_obj, session, show_progress=show_progress)self.SQL_helper.conn.commit()diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.pyindex a88511572..79568cabd 100644--- a/cyberdrop_dl/main.py+++ b/cyberdrop_dl/main.py@@ -27,6 +27,7 @@ def parse_args():parser.add_argument("--db-file", help="history database file to write to", default="download_history.sqlite")parser.add_argument("--threads", type=int, help="number of threads to use (0 = max)", default=0)parser.add_argument("--attempts", type=int, help="number of attempts to download each file", default=10)+ parser.add_argument("--connection-timeout", type=int, help="number of seconds to wait attempting to connect to a URL during the downloading phase", default=15)parser.add_argument("--disable-attempt-limit", help="disables the attempt limitation", action="store_true")parser.add_argument("--include-id", help="include the ID in the download folder name", action="store_true")parser.add_argument("--exclude-videos", help="skip downloading of video files", action="store_true")@@ -102,7 +103,7 @@ async def download_all(args: argparse.Namespace):excludes=excludes, SQL_helper=SQL_helper, client=client)for downloader in downloaders:- await downloader.download_content()+ await downloader.download_content(conn_timeout=args.connection_timeout)logger.debug("Finished")partial_downloads = [str(f) for f in args.output_folder.rglob("*.part") if f.is_file()]