How to get percent downloaded using PHP API?

Discussion of Transmission that doesn't fit in the other categories
Post Reply
brucegregory
Posts: 1
Joined: Wed Feb 20, 2013 10:32 pm

How to get percent downloaded using PHP API?

Post by brucegregory »

PHP CODE:

<?php
if (!function_exists("preprint")) {
function preprint($s, $return=false) {
$x = "<pre>";
$x .= print_r($s, 1);
$x .= "</pre>";
if ($return) return $x;
else print $x;
}
}


require_once( dirname( __FILE__ ) . '/class/TransmissionRPC.class.php' );

$rpc = new TransmissionRPC();

try
{
$rpc->return_as_array = true;
$result = $rpc->get();

preprint($result);

$rpc->return_as_array = false;
} catch (Exception $e) {
die('[ERROR] ' . $e->getMessage() . PHP_EOL);
}

?>

PHP RESULT:
Array
(
[arguments] => Array
(
[torrents] => Array
(
[0] => Array
(
[doneDate] => 0
[haveValid] => 2861867665
[id] => 23
[name] => World of Warcraft 3.3.5a (no install)
[status] => 0
[totalSize] => 17856504465
)

)

)

[result] => success
)

PROBLEM:

I need to retrieve how much has downloaded (%) if that is possible.

Thanks!
Post Reply