Libtorrent cannot find peer with trackers

104 views Asked by At

I am having some issues with the libtorrent library. Torrents are created successfully, however trying to download them with any number of torrent clients (bittorent, webtorrent, utorrent) does not work.

I am using libtorrent for python, version: 2.0.7

import sys
import time
import libtorrent as lt
import os

fs = lt.file_storage()
lt.add_files(fs, "test")
t = lt.create_torrent(fs)
t.add_tracker("http://opensharing.org:2710/announce", 0)
t.add_tracker("http://open.acgnxtracker.com:80/announce",1)
t.set_creator('libtorrent %s' % lt.version)
t.set_comment("Test")
lt.set_piece_hashes(t, ".")
torrent = t.generate()    

f = open("mytorrent2.torrent", "wb")

f.write(lt.bencode(torrent))
f.close()
print(lt.make_magnet_uri(lt.torrent_info("mytorrent2.torrent")))
#Seed torrent
ses = lt.session()

h = ses.add_torrent({'ti': lt.torrent_info('mytorrent2.torrent'), 'save_path': '.'}) 

print("Total size: " + str(h.status().total_wanted))
print("Name: " + h.name())
h.resume()
while True:
    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)
0

There are 0 answers