forked from DRMTalks/devine
Move unsupported proxy check to start of aria2c function
This commit is contained in:
parent
484338cf50
commit
e54d4b4f41
|
@ -54,12 +54,19 @@ async def aria2c(
|
||||||
if not executable:
|
if not executable:
|
||||||
raise EnvironmentError("Aria2c executable not found...")
|
raise EnvironmentError("Aria2c executable not found...")
|
||||||
|
|
||||||
|
if proxy and proxy.lower().split(":")[0] != "http":
|
||||||
|
# HTTPS proxies are not supported by aria2(c).
|
||||||
|
# Proxy the proxy via pproxy to access it as an HTTP proxy.
|
||||||
|
async with start_pproxy(proxy) as pproxy_:
|
||||||
|
return await aria2c(uri, out, headers, cookies, pproxy_, silent, segmented, progress, *args)
|
||||||
|
|
||||||
arguments = [
|
arguments = [
|
||||||
"-c", # Continue downloading a partially downloaded file
|
"-c", # Continue downloading a partially downloaded file
|
||||||
"--remote-time", # Retrieve timestamp of the remote file from the and apply if available
|
"--remote-time", # Retrieve timestamp of the remote file from the and apply if available
|
||||||
"-x", "16", # The maximum number of connections to one server for each download
|
"-x", "16", # The maximum number of connections to one server for each download
|
||||||
"-j", "16", # The maximum number of parallel downloads for every static (HTTP/FTP) URL
|
"-j", "16", # The maximum number of parallel downloads for every static (HTTP/FTP) URL
|
||||||
"-s", ("1" if segmented else "16"), # Download a file using N connections
|
"-s", ("1" if segmented else "16"), # Download a file using N connections
|
||||||
|
"--all-proxy", proxy or "",
|
||||||
"--allow-overwrite=true",
|
"--allow-overwrite=true",
|
||||||
"--auto-file-renaming=false",
|
"--auto-file-renaming=false",
|
||||||
"--retry-wait", "2", # Set the seconds to wait between retries.
|
"--retry-wait", "2", # Set the seconds to wait between retries.
|
||||||
|
@ -96,14 +103,6 @@ async def aria2c(
|
||||||
continue
|
continue
|
||||||
arguments.extend(["--header", f"{header}: {value}"])
|
arguments.extend(["--header", f"{header}: {value}"])
|
||||||
|
|
||||||
if proxy:
|
|
||||||
if proxy.lower().split(":")[0] != "http":
|
|
||||||
# HTTPS proxies are not supported by aria2(c).
|
|
||||||
# Proxy the proxy via pproxy to access it as an HTTP proxy.
|
|
||||||
async with start_pproxy(proxy) as pproxy_:
|
|
||||||
return await aria2c(uri, out, headers, cookies, pproxy_, silent, segmented, progress, *args)
|
|
||||||
arguments += ["--all-proxy", proxy]
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
p = await asyncio.create_subprocess_exec(
|
p = await asyncio.create_subprocess_exec(
|
||||||
executable,
|
executable,
|
||||||
|
|
Loading…
Reference in New Issue