-
Notifications
You must be signed in to change notification settings - Fork 139
/
aria.py
37 lines (27 loc) · 785 Bytes
/
aria.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import aria2p
import socket
import os
from aria2p.downloads import Download
# Resolve IP of aria2 by hostname
host = socket.gethostbyname('aria2-pro')
# Instance of Aria2 api
# This line connects the bot to the aria2 rpc server
aria2: aria2p.API = aria2p.API(
aria2p.Client(
host=f"http://{host}",
secret=os.environ.get("RPC_SECRET")
)
)
def addDownload(link: str) -> None:
"""Adds download link to aria and starts the download
Args:
link: Download url link
"""
link = link.replace('/mirror', '')
link = link.strip()
download: Download = aria2.add_magnet(link)
while download.is_active:
print("downloading")
if(download.is_complete):
print("Download complete")
downloads = aria2.get_downloads()