-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_single.py
More file actions
46 lines (35 loc) · 1.29 KB
/
Copy pathexample_single.py
File metadata and controls
46 lines (35 loc) · 1.29 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
import asyncio
from mrdl import DownloadConfig, Downloader
async def main():
mirrors = [
"https://cofractal-ewr.mm.fcix.net/ubuntu-releases/",
"https://ohioix.mm.fcix.net/ubuntu-releases/",
"https://gigsouth.mm.fcix.net/ubuntu-releases/"
]
filename = "ubuntu-26.04-live-server-amd64.iso"
paths = [item + f"26.04/{filename}" for item in mirrors]
expected_hash = "sha256:dec49008a71f6098d0bcfc822021f4d042d5f2db279e4d75bdd981304f1ca5d9"
print(f"Starting download from {len(mirrors)} mirrors...")
config = DownloadConfig(
urls=paths,
filename=filename,
threads_per_mirror=8,
chunk_size=1024 * 1024,
min_speed_kbps=1024,
speed_grace_period=10,
checksum=expected_hash,
)
downloader = Downloader(config)
result = await downloader.start()
print(f"Download took {result.time_taken:.2f} seconds.")
if result.computed_hash:
print(f"Computed hash ({config.checksum}): {result.computed_hash}")
if result.status.name != "COMPLETED":
print(f"Download failed with status: {result.status.value}")
if result.error:
print(f"Error details: {result.error}")
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
pass