forked from premiere/premiere-libtorrent
attempt to fix #12
This commit is contained in:
parent
6b0f60e73d
commit
6186e3fce7
|
@ -146,6 +146,24 @@ def print_peer_info(console, peers):
|
||||||
|
|
||||||
write_line(console, out)
|
write_line(console, out)
|
||||||
|
|
||||||
|
|
||||||
|
def print_download_queue(console, download_queue):
|
||||||
|
|
||||||
|
out = ""
|
||||||
|
|
||||||
|
for e in download_queue:
|
||||||
|
out += '%4d: [' % e['piece_index'];
|
||||||
|
finished_blocks = e['finished_blocks']
|
||||||
|
requested_blocks = e['requested_blocks']
|
||||||
|
for index in xrange(len(e['peers']))
|
||||||
|
if (finished_blocks[index])
|
||||||
|
out += '#'
|
||||||
|
elif requested_blocks[index]
|
||||||
|
out += '+'
|
||||||
|
else
|
||||||
|
out += '-'
|
||||||
|
out += ']\n'
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
@ -279,8 +297,8 @@ def main():
|
||||||
|
|
||||||
write_line(console, out)
|
write_line(console, out)
|
||||||
|
|
||||||
peers = h.get_peer_info()
|
print_peer_info(console, h.get_peer_info())
|
||||||
print_peer_info(console, peers)
|
print_download_queue(console, h.get_download_queue())
|
||||||
|
|
||||||
if True and s.state != lt.torrent_status.seeding:
|
if True and s.state != lt.torrent_status.seeding:
|
||||||
out = '\n'
|
out = '\n'
|
||||||
|
|
|
@ -84,6 +84,42 @@ void replace_trackers(torrent_handle& info, object trackers)
|
||||||
info.replace_trackers(result);
|
info.replace_trackers(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list get_download_queue(torrent_handle& handle)
|
||||||
|
{
|
||||||
|
list ret;
|
||||||
|
|
||||||
|
std::vector<partial_piece_info> downloading;
|
||||||
|
|
||||||
|
{
|
||||||
|
allow_threading_guard guard;
|
||||||
|
handle.get_download_queue(downloading);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::vector<partial_piece_info>::iterator i = downloading.begin()
|
||||||
|
, end(downloading.end()); i != end; ++i)
|
||||||
|
{
|
||||||
|
dict partial_piece;
|
||||||
|
partial_piece["piece_index"] = i->piece_index;
|
||||||
|
partial_piece["blocks_in_piece"] = i->blocks_in_piece;
|
||||||
|
list requested;
|
||||||
|
list finished;
|
||||||
|
list peer;
|
||||||
|
for (int k = 0; k < i->blocks_in_piece; ++k)
|
||||||
|
{
|
||||||
|
requested.extend(i->requested_blocks[k]);
|
||||||
|
finished.extend(i->finished_blocks[k]);
|
||||||
|
peer.extend(i->peer[k]);
|
||||||
|
}
|
||||||
|
partial_piece["requested_blocks"] = requested;
|
||||||
|
partial_piece["finished_blocks"] = finished;
|
||||||
|
partial_piece["peer"] = peer;
|
||||||
|
|
||||||
|
ret.extend(partial_piece);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void bind_torrent_handle()
|
void bind_torrent_handle()
|
||||||
{
|
{
|
||||||
void (torrent_handle::*force_reannounce0)() const = &torrent_handle::force_reannounce;
|
void (torrent_handle::*force_reannounce0)() const = &torrent_handle::force_reannounce;
|
||||||
|
@ -123,6 +159,7 @@ void bind_torrent_handle()
|
||||||
.def("trackers", range(begin_trackers, end_trackers))
|
.def("trackers", range(begin_trackers, end_trackers))
|
||||||
.def("replace_trackers", replace_trackers)
|
.def("replace_trackers", replace_trackers)
|
||||||
.def("get_peer_info", get_peer_info)
|
.def("get_peer_info", get_peer_info)
|
||||||
|
.def("get_download_queue", get_download_queue)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue