Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. # Torrent Client using Libtorrent package
  2. import libtorrent as lbt
  3. import time
  4. import sys
  5.  
  6. ses = lbt.session()
  7. ses.listen_on(4000, 4001)
  8.  
  9. info = lbt.torrent_info(sys.argv[1])
  10. h = ses.add_torrent({'ti': info, 'save_path': './'})
  11. print 'starting', h.name()
  12.  
  13. while (not h.is_seed()):
  14. s = h.status()
  15.  
  16. state_str = ['Queued', 'Checking', 'Metadata', \
  17. 'Downloading', 'Completed', 'Seeding', 'Allocating', 'Checking resume']
  18. print '\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d seeds: %d ) %s' % \
  19. (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, \
  20. s.num_peers,s.num_seeds, state_str[s.state]),
  21. sys.stdout.flush()
  22.  
  23. time.sleep(1)
  24.  
  25. print h.name(), 'Complete'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement