2 # Copyright Arvid Norberg 2008. Use, modification and distribution is
3 # subject to the Boost Software License, Version 1.0. (See accompanying
4 # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 import libtorrent
as lt
11 ses
.listen_on(6881, 6891)
13 e
= lt
.bdecode(open("test.torrent", 'rb').read())
14 info
= lt
.torrent_info(e
)
16 h
= ses
.add_torrent(info
, "./")
18 while (not h
.is_seed()):
21 state_str
= ['queued', 'checking', 'connecting', 'downloading metadata', \
22 'downloading', 'finished', 'seeding', 'allocating']
23 print '\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s' % \
24 (s
.progress
* 100, s
.download_rate
/ 1000, s
.upload_rate
/ 1000, \
25 s
.num_peers
, state_str
[s
.state
]),