The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

RTPG - is a module for accessing to rtorrent's SCGI functions.

VERSION

0.3

SYNOPSIS

 use RTPG;
 
 # standard variant
 my $h = new RTPG(url=>'http://localhost/RPC2');
 
 # direct connection to rtorrent
 my $h = new RTPG(url=>'localhost:5000');
 my $h = new RTPG(url=>'/path/to/socket.rtorrent'); 

 die $! unless defined $h;

 # arrayref and error (standard version)
 my ($tlist, $error)=$h->torrents_list;

 # arrayref (died version)
 my $tlist=$h->torrents_list;
 
 for (@$tlist)
 {
         my $file_list=$h->file_list($_->{hash});
         ..
 }


 # direct commands by RPC
 my $list_methods=$h->rpc_command('system.listMethods');
 my ($list_methods, $error)=$h->rpc_command('system.listMethods');

 # system information (library versions, etc)
 my $hashref=$h->system_information;
 my ($hashref, $error)=$h->system_information;

METHODS

new

The constructor. It receives the next options:

url

is an address of rtorrent's SCGI (direct) or rtorrent's RPC (standard).

rpc_command(CMD[,ARGS])

You can use this method for send commands to rtorrent.

EXAMPLE

 # standard version
 my ($result, $error)=$h->rpc_command('system.listMethods');

 # died version
 my $result=$h->rpc_command('system.listMethods');

torrents_list([VIEW])

This method returns list of torrents. It is a link to array of hashes.

EXAMPLE

# standard version my ($tlist, $err)=$h->torrents_list; my ($tlist, $err)=$h->torrents_list('started');

 # died version
 my $tlist=$h->torrents_list;
 my $tlist=$h->torrents_list('started');

views variants

default
name
stopped
started
complete
incomplete

torrent_info(tid)

The method returns the link to hash which contains the information about the torrent (tid);

EXAMPLE

 my $tlist = $h->torrents_list;
 my $tinfo_first = $tlist->[0];
 my $tinfo_first_second_time 
    = $h->torrent_info($tlist->[0]{hash});

NOTE

Hashes $tinfo_first and $tinfo_first_second_time are equal. This method can use if You know torrent-id and do not know an other information about the torrent.

 # standard version
 my ($tinfo, $error)=$h->torrent_info($tid);

 # died version
 my $tinfo=$h->torrent_info($tid);

file_list(tid)

The method returns the link to array which contains information about each file that belong to the torrent (tid).

EXAMPLE

 # standard version
 my ($files, $error)=$h->file_list($tid);
 
 # died version
 my $files=$h->file_list($tid);

set_files_priorities(tid, pri)

This method updates priorities of all files in one torrent

EXAMPLE

 # standard version
 my $error=$h->set_files_priorities($tid, $pri);
 my ($error)=$h->set_files_priorities($tid, $pri);

 # died version
 $h->set_files_priorities($tid, $pri);

system_information

The method returns the link to hash about system information. The hash has the fields:

client_version

the version of rtorrent.

library_version

the version of librtorrent.

PRIVATE METHODS

_get_list_methods

returns list of rtorrent commands

_get_percent_string(PART_OF_VALUE,VALUE)

counts percent by pair values

_human_size(NUM)

converts big numbers to small 1024 = 1K, 1024**2 == 1M, etc

_normalize_one_torrent_info(HASHREF)

calculates:

percents, ratio, human_size, human_done, human_up_total, human_up_rate, human_down_rate

fixes:

32bit overflow in libxmlrpc-c3 version < 1.07

AUTHORS

Copyright (C) 2008 Dmitry E. Oboukhov <unera@debian.org>,

Copyright (C) 2008 Nikolaev Roman <rshadow@rambler.ru>

LICENSE

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.