llamaX
unread,Jun 19, 2009, 1:11:03 PM6/19/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rtGui
Here's some sample code to get the "chunks seen" (d.get_bitfield) that
was added in rTorrent 0.8.5. While not quite as useful as it is in
the client (does not show which are incoming, etc.), it shows the
availability of chunks in the swarm. (Unless I'm grossly
misunderstanding it.)
The get_full_list multicall needs "d.get_bitfield=" tacked on the end
and then the array a bit down needs "$retarr[$index]['chunks_seen']=
$item[55];".
Here's a function to parse it:
function format_chunks($bitfield) {
$bitarray = str_split($bitfield, 10);
$retval = "";
$i = 0; $c = 0;
foreach ($bitarray as $seen) {
if (0 == $i % 6) {
if ($i > 0) $retval .= "<br />";
$retval .= str_pad($c*60, 3, " ", STR_PAD_LEFT);
$c++;
}
$retval .= " ".$seen;
$i++;
}
return '<code style="white-space: pre">'.$retval.'</code>';
}
And then something such as...
echo "<tr class='row1'><td class='datacol' align='right'><b>Chunks
Seen</b></td><td>".format_chunks($thistorrent['chunks_seen'])."</td></
tr>\n";
...thrown into view.php somewhere to display it.
Doubt this is useful to most folks, but if anyone wants to play around
with it, feel free. Mostly untested because 0.8.5 keeps crashing on
me. :(