From a7bbac7bcc2b6571457193d53d9efa9cc5724bde Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Tue, 9 Jan 2024 10:08:21 +0000 Subject: [PATCH] Get -j, -x, and -s from aria2c config, default to 16 --- CONFIG.md | 8 ++++++++ devine/core/downloaders/aria2c.py | 10 +++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CONFIG.md b/CONFIG.md index 1f07f96..41d9cd6 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -10,6 +10,14 @@ which does not keep comments. ## aria2c (dict) +- `max_concurrent_downloads` + Maximum number of parallel downloads. Default: `5` + Note: Currently unused as downloads are multi-threaded by Devine rather than Aria2c. + Devine internally has a constant set value of 16 for it's parallel downloads. +- `max_connection_per_server` + Maximum number of connections to one server for each download. Default: `1` +- `split` + Split a file into N chunks and download each chunk on it's own connection. Default: `5` - `file_allocation` Specify file allocation method. Default: `"prealloc"` diff --git a/devine/core/downloaders/aria2c.py b/devine/core/downloaders/aria2c.py index 6389d9c..0a5e3cf 100644 --- a/devine/core/downloaders/aria2c.py +++ b/devine/core/downloaders/aria2c.py @@ -60,8 +60,12 @@ async def aria2c( async with start_pproxy(proxy) as pproxy_: return await aria2c(uri, out, headers, cookies, pproxy_, silent, segmented, progress, *args) + max_concurrent_downloads = int(config.aria2c.get("max_concurrent_downloads", 16)) + max_connection_per_server = int(config.aria2c.get("max_connection_per_server", 16)) + split = int(config.aria2c.get("split", 16)) file_allocation = config.aria2c.get("file_allocation", "prealloc") if segmented: + split = 1 file_allocation = "none" arguments = [ @@ -71,9 +75,9 @@ async def aria2c( "--all-proxy", proxy or "", "--continue=true", # [Connection Options] - "--max-concurrent-downloads=16", - "--max-connection-per-server=16", - f"--split={1 if segmented else 16}", # each split uses their own connection + f"--max-concurrent-downloads={max_concurrent_downloads}", + f"--max-connection-per-server={max_connection_per_server}", + f"--split={split}", # each split uses their own connection "--max-file-not-found=5", # counted towards --max-tries "--max-tries=5", "--retry-wait=2",