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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top