Python で libtorrent を使用して、トレントのピアの IP を検索して取得します。私はコードで試してみます:
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()
for i in p:
print i.ip
print "\n\n"
sys.stdout.flush()
time.sleep(1)
print h.name(), 'complete'
多かれ少なかれ機能しますが、2つの問題があります。
- トレントがダウンロードされます。
- 1 つのピア リストを受け取る前に、ループが何十回も実行されます。
手伝って頂けますか?
どうもありがとう。