Reputation: 737
I have tried this code :
import libtorrent as lt
import time
ses = lt.session()
ses.listen_on(6881, 6891)
info = lt.torrent_info('test.torrent')
h = ses.add_torrent({'ti': info, 'save_path': './'})
print 'starting', h.name()
while (not h.is_seed()):
s = h.status()
p = h.get_peer_info()
print lt.peer_info().ip
sys.stdout.flush()
time.sleep(15)
print h.name(), 'complete'
and it prints this:
starting test.avi
('0.0.0.0', 0)
('0.0.0.0', 0)
.
.
.
so instead of giving me a peer list it gives me zeros.Am i doing something wrong?
Upvotes: 5
Views: 2478
Reputation: 11245
It looks like you have a bug in your python code.
print lt.peer_info().ip
That line will construct a fresh peer_info object, and then print the IP (which will be default initialized at that time, and contained 0.0.0.0).
What I believe you want to do is:
for i in p:
print i.ip()
i.e. for each peer in the torrent, print its IP.
Upvotes: 5