fix: add connections limit parameter to http downloader

This commit is contained in:
Hachi-R
2025-04-12 16:25:45 -03:00
parent be232d88e4
commit 007fa6f009
3 changed files with 6 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ class HttpDownloader:
self.process = None
self.last_status = None
def start_download(self, url: str, save_path: str, header: str = None, out: str = None, allow_multiple_connections: bool = False):
def start_download(self, url: str, save_path: str, header: str = None, out: str = None, allow_multiple_connections: bool = False, connections_limit: int = 1):
cmd = [self.hydra_exe]
cmd.append(url)
@@ -25,7 +25,7 @@ class HttpDownloader:
cmd.extend(["--header", header])
if allow_multiple_connections:
cmd.extend(["--connections", "24"])
cmd.extend(["--connections", str(connections_limit)])
else:
cmd.extend(["--connections", "1"])

View File

@@ -148,11 +148,11 @@ def action():
torrent_downloader.start_download(url, data['save_path'])
else:
if existing_downloader and isinstance(existing_downloader, HttpDownloader):
existing_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'), data.get('allow_multiple_connections', False))
existing_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'), data.get('allow_multiple_connections', False), data.get('connections_limit', 24))
else:
http_downloader = HttpDownloader(hydra_httpdl_bin)
downloads[game_id] = http_downloader
http_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'), data.get('allow_multiple_connections', False))
http_downloader.start_download(url, data['save_path'], data.get('header'), data.get('out'), data.get('allow_multiple_connections', False), data.get('connections_limit', 24))
downloading_game_id = game_id