forked from premiere/premiere-libtorrent
fixes get_download_queue in python binding
This commit is contained in:
parent
219db47776
commit
05714ab5aa
|
@ -153,17 +153,17 @@ def print_download_queue(console, download_queue):
|
||||||
|
|
||||||
for e in download_queue:
|
for e in download_queue:
|
||||||
out += '%4d: [' % e['piece_index'];
|
out += '%4d: [' % e['piece_index'];
|
||||||
finished_blocks = e['finished_blocks']
|
for fin, req in zip(e['finished_blocks'], e['requested_blocks']):
|
||||||
requested_blocks = e['requested_blocks']
|
if fin:
|
||||||
for index in xrange(len(e['peers']))
|
|
||||||
if (finished_blocks[index])
|
|
||||||
out += '#'
|
out += '#'
|
||||||
elif requested_blocks[index]
|
elif req:
|
||||||
out += '+'
|
out += '+'
|
||||||
else
|
else:
|
||||||
out += '-'
|
out += '-'
|
||||||
out += ']\n'
|
out += ']\n'
|
||||||
|
|
||||||
|
write_line(console, out)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
@ -220,8 +220,8 @@ def main():
|
||||||
ses.listen_on(options.port, options.port + 10)
|
ses.listen_on(options.port, options.port + 10)
|
||||||
ses.set_settings(settings)
|
ses.set_settings(settings)
|
||||||
ses.set_severity_level(lt.alert.severity_levels.info)
|
ses.set_severity_level(lt.alert.severity_levels.info)
|
||||||
ses.add_extension(lt.create_ut_pex_plugin);
|
# ses.add_extension(lt.create_ut_pex_plugin);
|
||||||
ses.add_extension(lt.create_metadata_plugin);
|
# ses.add_extension(lt.create_metadata_plugin);
|
||||||
|
|
||||||
handles = []
|
handles = []
|
||||||
alerts = []
|
alerts = []
|
||||||
|
|
|
@ -33,6 +33,7 @@ void bind_peer_info()
|
||||||
.def_readonly("downloading_total", &peer_info::downloading_total)
|
.def_readonly("downloading_total", &peer_info::downloading_total)
|
||||||
.def_readonly("client", &peer_info::client)
|
.def_readonly("client", &peer_info::client)
|
||||||
.def_readonly("connection_type", &peer_info::connection_type)
|
.def_readonly("connection_type", &peer_info::connection_type)
|
||||||
|
.def_readonly("source", &peer_info::source)
|
||||||
;
|
;
|
||||||
|
|
||||||
pi.attr("interesting") = (int)peer_info::interesting;
|
pi.attr("interesting") = (int)peer_info::interesting;
|
||||||
|
@ -47,5 +48,11 @@ void bind_peer_info()
|
||||||
|
|
||||||
pi.attr("standard_bittorrent") = 0;
|
pi.attr("standard_bittorrent") = 0;
|
||||||
pi.attr("web_seed") = 1;
|
pi.attr("web_seed") = 1;
|
||||||
|
|
||||||
|
pi.attr("tracker") = 0x1;
|
||||||
|
pi.attr("dht") = 0x2;
|
||||||
|
pi.attr("pex") = 0x4;
|
||||||
|
pi.attr("lsd") = 0x8;
|
||||||
|
pi.attr("resume_data") = 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,18 +103,18 @@ list get_download_queue(torrent_handle& handle)
|
||||||
partial_piece["blocks_in_piece"] = i->blocks_in_piece;
|
partial_piece["blocks_in_piece"] = i->blocks_in_piece;
|
||||||
list requested;
|
list requested;
|
||||||
list finished;
|
list finished;
|
||||||
list peer;
|
// list peer;
|
||||||
for (int k = 0; k < i->blocks_in_piece; ++k)
|
for (int k = 0; k < i->blocks_in_piece; ++k)
|
||||||
{
|
{
|
||||||
requested.extend(i->requested_blocks[k]);
|
requested.append(bool(i->requested_blocks[k]));
|
||||||
finished.extend(i->finished_blocks[k]);
|
finished.append(bool(i->finished_blocks[k]));
|
||||||
peer.extend(i->peer[k]);
|
// peer.append(i->peer[k]);
|
||||||
}
|
}
|
||||||
partial_piece["requested_blocks"] = requested;
|
partial_piece["requested_blocks"] = requested;
|
||||||
partial_piece["finished_blocks"] = finished;
|
partial_piece["finished_blocks"] = finished;
|
||||||
partial_piece["peer"] = peer;
|
// partial_piece["peer"] = peer;
|
||||||
|
|
||||||
ret.extend(partial_piece);
|
ret.append(partial_piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue