-
Notifications
You must be signed in to change notification settings - Fork 0
/
seq_download_torrents.py
36 lines (26 loc) · 1.14 KB
/
seq_download_torrents.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
import libtorrent as lt
import time
import sys
streaming = False
ses = lt.session()
ses.listen_on(6881, 6891)
magnet = True
if magnet:
params = {"save_path": "./"}
link = "magnet:?xt=urn:btih:3d0ef9c4f15622f63611c26fac2c7be2766d82dd&dn=Die.Hard.1988.720p.BluRay.x264-NeZu&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fzer0day.ch%3A1337&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969"
h = lt.add_magnet_uri(ses, link, params)
else:
info = lt.torrent_info("active.torrent")
h = ses.add_torrent({'ti': info, 'save_path': './'})
h.set_sequential_download(True)
print('starting' + h.name())
while (not h.is_seed()):
s = h.status()
state_str = ['queued', 'checking', 'downloading metadata', \
'downloading', 'finished', 'seeding', 'allocating', 'checking fastresume']
print('\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s' % \
(s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, \
s.num_peers, state_str[s.state]),)
sys.stdout.flush()
time.sleep(1)
print(h.name(), 'complete')