NAME

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

VERSION

0.92

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');

# 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).

queue

if TRUE, commands will process in queue mode (use flock).

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);

tracker_list

The method returns information about trackers.

peer_list(tid)

The method returns information about peers we are connected (by torrent id).

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);

set_file_priority

Set file priority

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.

view_list([ARGS])

The method returns information about views in rtorrent. There are a few additional named arguments:

full

if TRUE, method will return additional information about view.

start

Start torrent (tid) download

stop

Stop torrent (tid) download

delete

Delete torrent (tid)

pause

Pause torrent (tid)

check

Check torrent hash (tid)

priority

Set torrent priority (tid, priority)

set_download_rate

Set maximum download rate for all torrents

set_upload_rate

Set maximum upload rate for all torrents

rates

Return varios current speed rates and etc.

add

Add new torrent for download from url list or filehandle

PRIVATE METHODS

_get_list_methods

returns list of rtorrent commands

_get_percent_string(PART_OF_VALUE,VALUE)

counts percent by pair values

_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

as_human_size(NUM)

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

as_human_speed

As as_human_size, but convert into speed

as_human_datetime

Return datetime string from timestemp

torrent_priority_num

Convert torrent priority name to int

file_priority_num

Convert file priority name to int

AUTHORS

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

Copyright (C) 2008 Roman V. Nikolaev <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/>.