-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
58 lines (43 loc) · 1.47 KB
/
example.py
File metadata and controls
58 lines (43 loc) · 1.47 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Example usage of the Aria2 XML-RPC client."""
from aria2_client import Aria2Client
def main():
# Initialize client with custom settings
client = Aria2Client(
host="http://127.0.0.1",
port=6800,
token="your_token_here"
)
# Or update settings later
# client.set_server(host="http://example.com", port=6800, token="1234")
# Check connection
status = client.check_connection()
print(f"Connection status: {status}")
# Get Aria2 version
version = client.get_version()
print(f"Aria2 version: {version}")
# Add a single URI
gid = client.add_uri("https://example.com/file.zip")
print(f"Added download GID: {gid}")
# Add multiple URIs
uris = [
"https://example.com/file1.zip",
"https://example.com/file2.zip",
]
gids = client.add_uri(uris, save_dir="/tmp/downloads")
print(f"Added downloads: {gids}")
# Add a torrent
# gid = client.add_torrent("example.torrent", save_dir="/tmp/torrents")
# Get active downloads
active = client.tell_active(["gid", "status", "totalLength"])
print(f"Active downloads: {active}")
# Pause a download
# client.pause(gid)
# Resume a download
# client.unpause(gid)
# Get global status
global_status = client.get_global_status()
print(f"Global status: {global_status}")
# Change download speed limit
# client.change_global_option({"max-download-limit": "1M"})
if __name__ == "__main__":
main()