python bindings and examples fixes
This commit is contained in:
@@ -244,7 +244,7 @@ def main():
|
|||||||
resume_data = None
|
resume_data = None
|
||||||
|
|
||||||
h = ses.add_torrent(info, options.save_path,
|
h = ses.add_torrent(info, options.save_path,
|
||||||
resume_data=resume_data, compact_mode=compact_allocation)
|
resume_data, lt.storage_mode_t.storage_mode_sparse)
|
||||||
|
|
||||||
handles.append(h)
|
handles.append(h)
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ def main():
|
|||||||
|
|
||||||
for h in handles:
|
for h in handles:
|
||||||
if h.has_metadata():
|
if h.has_metadata():
|
||||||
name = h.torrent_info().name()[:40]
|
name = h.get_torrent_info().name()[:40]
|
||||||
else:
|
else:
|
||||||
name = '-'
|
name = '-'
|
||||||
out += 'name: %-40s\n' % name
|
out += 'name: %-40s\n' % name
|
||||||
@@ -306,7 +306,7 @@ def main():
|
|||||||
if True and s.state != lt.torrent_status.seeding:
|
if True and s.state != lt.torrent_status.seeding:
|
||||||
out = '\n'
|
out = '\n'
|
||||||
fp = h.file_progress()
|
fp = h.file_progress()
|
||||||
ti = h.torrent_info()
|
ti = h.get_torrent_info()
|
||||||
for f,p in zip(ti.files(), fp):
|
for f,p in zip(ti.files(), fp):
|
||||||
out += progress_bar(p, 20)
|
out += progress_bar(p, 20)
|
||||||
out += ' ' + f.path + '\n'
|
out += ' ' + f.path + '\n'
|
||||||
@@ -349,7 +349,7 @@ def main():
|
|||||||
continue
|
continue
|
||||||
h.pause()
|
h.pause()
|
||||||
data = lt.bencode(h.write_resume_data())
|
data = lt.bencode(h.write_resume_data())
|
||||||
open(os.path.join(options.save_path, h.torrent_info().name() + '.fastresume'), 'wb').write(data)
|
open(os.path.join(options.save_path, h.get_torrent_info().name() + '.fastresume'), 'wb').write(data)
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
@@ -13,16 +13,16 @@ ses.listen_on(6881, 6891)
|
|||||||
e = lt.bdecode(open("test.torrent", 'rb').read())
|
e = lt.bdecode(open("test.torrent", 'rb').read())
|
||||||
info = lt.torrent_info(e)
|
info = lt.torrent_info(e)
|
||||||
|
|
||||||
h = ses.add_torrent(info, "./", compact_mode = True)
|
h = ses.add_torrent(info, "./")
|
||||||
|
|
||||||
while (not h.is_seed()):
|
while (not h.is_seed()):
|
||||||
s = h.status()
|
s = h.status()
|
||||||
|
|
||||||
state_str = ['queued', 'checking', 'connecting', 'downloading metadata', \
|
state_str = ['queued', 'checking', 'connecting', 'downloading metadata', \
|
||||||
'downloading', 'finished', 'seeding', 'allocating']
|
'downloading', 'finished', 'seeding', 'allocating']
|
||||||
print '%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s' % \
|
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.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, \
|
||||||
s.num_peers, state_str[s.state])
|
s.num_peers, state_str[s.state]),
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <libtorrent/torrent_handle.hpp>
|
#include <libtorrent/torrent_handle.hpp>
|
||||||
#include <boost/python.hpp>
|
#include <boost/python.hpp>
|
||||||
|
#include <boost/python/tuple.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include "gil.hpp"
|
#include "gil.hpp"
|
||||||
|
|
||||||
@@ -170,6 +171,8 @@ void replace_trackers(torrent_handle& info, object trackers)
|
|||||||
|
|
||||||
list get_download_queue(torrent_handle& handle)
|
list get_download_queue(torrent_handle& handle)
|
||||||
{
|
{
|
||||||
|
using boost::python::make_tuple;
|
||||||
|
|
||||||
list ret;
|
list ret;
|
||||||
|
|
||||||
std::vector<partial_piece_info> downloading;
|
std::vector<partial_piece_info> downloading;
|
||||||
@@ -193,7 +196,7 @@ list get_download_queue(torrent_handle& handle)
|
|||||||
block_info["num_peers"] = i->blocks[k].num_peers;
|
block_info["num_peers"] = i->blocks[k].num_peers;
|
||||||
block_info["bytes_progress"] = i->blocks[k].bytes_progress;
|
block_info["bytes_progress"] = i->blocks[k].bytes_progress;
|
||||||
block_info["block_size"] = i->blocks[k].block_size;
|
block_info["block_size"] = i->blocks[k].block_size;
|
||||||
block_info["peer"] = std::make_pair(
|
block_info["peer"] = make_tuple(
|
||||||
boost::lexical_cast<std::string>(i->blocks[k].peer.address()), i->blocks[k].peer.port());
|
boost::lexical_cast<std::string>(i->blocks[k].peer.address()), i->blocks[k].peer.port());
|
||||||
block_list.append(block_info);
|
block_list.append(block_info);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user