Add ability to silence aria2c's output

This commit is contained in:
rlaphoenix 2023-02-22 03:06:17 +00:00
parent 0913b0dda6
commit 4406e3bbab
1 changed files with 4 additions and 1 deletions

View File

@ -15,6 +15,7 @@ async def aria2c(
headers: Optional[dict] = None, headers: Optional[dict] = None,
proxy: Optional[str] = None, proxy: Optional[str] = None,
byte_range: Optional[str] = None, byte_range: Optional[str] = None,
silent: bool = False,
*args: str *args: str
) -> int: ) -> int:
""" """
@ -88,7 +89,9 @@ async def aria2c(
p = await asyncio.create_subprocess_exec( p = await asyncio.create_subprocess_exec(
executable, executable,
*arguments, *arguments,
stdin=subprocess.PIPE stdin=subprocess.PIPE,
stderr=[None, subprocess.DEVNULL][silent],
stdout=[None, subprocess.DEVNULL][silent]
) )
await p.communicate(uri.encode()) await p.communicate(uri.encode())