Skip to content

Instantly share code, notes, and snippets.

@ankitshekhawat
Last active March 12, 2020 05:47
Show Gist options
  • Save ankitshekhawat/940a5b768843ccf393400bffcda2e9b3 to your computer and use it in GitHub Desktop.
Save ankitshekhawat/940a5b768843ccf393400bffcda2e9b3 to your computer and use it in GitHub Desktop.
download using an aria deamon
import aria2p
# parellel run:
# aria2c --enable-rpc --rpc-listen-all
# Spawn aria server
import subprocess
subprocess.call(['gnome-terminal', '-e', 'aria2c --enable-rpc --rpc-listen-all'])
aria2 = aria2p.API(aria2p.Client(host="http://localhost",
port=6800,
secret="" ))
def download(url, directory, filename):
aria2.add_uris([url], dict(dir=directory, auto_file_renaming=False, out=filename))
#check complete list
import time
while True:
status = aria2.get_stats()
print(status.num_stopped_total,
'/',
status.num_active + status.num_waiting + status.num_stopped_total,
round(status.download_speed/1024/1024, 2),"MiB/s",
end="\r")
time.sleep(0.5)
if status.num_waiting < 1:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment