#!/bin/python
# Copyright Arvid Norberg 2008. Use, modification and distribution is
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)


import libtorrent as lt
import time

ses = lt.session()
ses.listen_on(6881, 6891)

e = lt.bdecode(open("test.torrent", 'rb').read())
info = lt.torrent_info(e)

h = ses.add_torrent(info, "./")

while (not h.is_seed()):
	s = h.status()

	state_str = ['queued', 'checking', 'connecting', 'downloading metadata', \
		'downloading', 'finished', 'seeding', 'allocating']
	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]),

	time.sleep(1)


@@ -383,16 +383,192 @@
 nfo(e)%0A%0A
+atp = %7B%7D%0Aatp%5B%22ti%22%5D = info%0Aatp%5B%22save_path%22%5D = %22./%22%0Aatp%5B%22storage_mode%22%5D = lt.storage_mode_t(1)%0Aatp%5B%22paused%22%5D = False%0Aatp%5B%22auto_managed%22%5D = True%0Aatp%5B%22duplicate_is_error%22%5D = True%0A%0A
 h = ses.
@@ -583,18 +583,11 @@
 ent(
-info, %22./%22
+atp
 )%0A%0Aw
@@ -666,22 +666,8 @@
 ng',
- 'connecting',
  'do

update simple_client.py