vke*_*nos 5 python bittorrent libtorrent
我试过这段代码:
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'
Run Code Online (Sandbox Code Playgroud)
它打印出这个:
starting test.avi
('0.0.0.0', 0)
('0.0.0.0', 0)
.
.
.
Run Code Online (Sandbox Code Playgroud)
因此,它没有给我一个同行列表,而是给了我零。我做错了什么吗?
看起来你的 python 代码中有一个错误。
打印 lt.peer_info().ip
该行将构造一个新的peer_info对象,然后打印IP(此时将默认初始化,并包含0.0.0.0)。
我相信你想做的是:
for i in p:
print i.ip()
Run Code Online (Sandbox Code Playgroud)
即对于 torrent 中的每个对等点,打印其 IP。
| 归档时间: |
|
| 查看次数: |
2363 次 |
| 最近记录: |