Add byte-range option to the aria2c downloader

This commit is contained in:
rlaphoenix 2023-02-13 18:43:36 +00:00
parent 0c02b1513a
commit af5e6acbb8
1 changed files with 5 additions and 1 deletions

View File

@ -11,7 +11,8 @@ async def aria2c(
uri: Union[str, list[str]], uri: Union[str, list[str]],
out: Path, out: Path,
headers: Optional[dict] = None, headers: Optional[dict] = None,
proxy: Optional[str] = None proxy: Optional[str] = None,
byte_range: Optional[str] = None
) -> int: ) -> int:
""" """
Download files using Aria2(c). Download files using Aria2(c).
@ -68,6 +69,9 @@ async def aria2c(
continue continue
arguments.extend(["--header", f"{header}: {value}"]) arguments.extend(["--header", f"{header}: {value}"])
if byte_range:
arguments.extend(["--header", f"Range: bytes={byte_range}"])
if proxy and proxy.lower().split(":")[0] != "http": if proxy and proxy.lower().split(":")[0] != "http":
# HTTPS proxies not supported by Aria2c. # HTTPS proxies not supported by Aria2c.
# Proxy the proxy via pproxy to access it as a HTTP proxy. # Proxy the proxy via pproxy to access it as a HTTP proxy.