From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

NAME

Net::uTorrent - Perl interface to the uTorrent API.

SYNOPSIS

my $utorrent = Net::uTorrent->new (
hostname => 'localhost',
port => '12345',
user => 'my_username',
pass => 'my_password',
);
die unless $utorrent->login_success;

DESCRIPTION

Net::uTorrent is an object oriented interface to the uTorrent API. This module requires the uTorrent WebUI to be enabled.

METHODS

login_success() Returns a boolean indicating whether authentication was successful.

token() Returns the authentication token.

torrents() Returns a hashref containing all the torrents. Takes an optional hash argument with the key cid which when used will return a hashref containing all the torrents that were changed since the last time this method was used.

Examples:
$utorrent->torrents;
$utorrent->torrents( cid => 'abcd' );

cache_id() Returns the cid from the previous use of torrents(), which can be used in the next request.

get_settings() Returns an array ref containing the uTorrent settings. Takes an optional argument 'hash', which when used will return a hashref containing settings.

Examples:
$utorrent->get_settings;
$utorrent->get_settings('hash');

set_settings() Takes a hashref as argument. Allowed keys are the ones returned by get_settings().

Examples:
$utorrent->set_settings (
max_ul_rate => 5000,
max_dl_rate => 10000
);

filelist() Takes an array of infohashes as arguments and returns a hashref.

Examples:
$utorrent->filelist(qw '43E2DFD8279552543DABA81E5FCCEA2539C81D1F 663C531B51C9A466B9757282B438F635E64AC3CA');

get_properties() Takes an array of infohashes as arguments and returns a hashref.

Examples:
$utorrent->get_properties(qw '43E2DFD8279552543DABA81E5FCCEA2539C81D1F 663C531B51C9A466B9757282B438F635E64AC3CA');

set_properties() Takes an array of hashrefs as arguments, each of which contains a key 'hash' containing the infohash, and property and value like the ones returned by get_properties.

Examples:
$utorrent->set_properties (
{
hash => '43E2DFD8279552543DABA81E5FCCEA2539C81D1F',
ulrate => 1740, # Upload speed in bytes/second
},
{
hash => '663C531B51C9A466B9757282B438F635E64AC3CA',
ulrate => 7135,
dlrate => 8330
}
);

set_priority() Takes a hash as argument. Must contain the hash, an array containing the file indexes (starting from 0), and the priority.

Examples:
$utorrent->set_priority (
hash => '43E2DFD8279552543DABA81E5FCCEA2539C81D1F',
files => [1,2,3],
priority => 3 # (0 = skip, 1 = low, 2 = normal, 3 = high)
);

add_file() Takes a filename as argument, which when used will add the torrent to uTorrent. This method returns a hashref indicating if an error occured.

Examples:
$utorrent->add_file('fedora_11_dvd.torrent');

add_url() Takes a url as argument.

start() - Start torrent. Takes an array containing infohashes as argument.

Examples:
$utorrent->start(qw '43E2DFD8279552543DABA81E5FCCEA2539C81D1F 663C531B51C9A466B9757282B438F635E64AC3CA');

stop() - Stop torrent. Takes an array containing infohashes as argument.

Examples:
$utorrent->stop(qw '43E2DFD8279552543DABA81E5FCCEA2539C81D1F 663C531B51C9A466B9757282B438F635E64AC3CA');

pause() Takes an array containing infohashes as argument.

Examples:
$utorrent->pause(qw '43E2DFD8279552543DABA81E5FCCEA2539C81D1F 663C531B51C9A466B9757282B438F635E64AC3CA');

resume() Takes an array containing infohashes as argument.

Examples:
$utorrent->resume(qw '43E2DFD8279552543DABA81E5FCCEA2539C81D1F 663C531B51C9A466B9757282B438F635E64AC3CA');

force_start() Takes an array containing infohashes as argument.

Examples:
$utorrent->force_start(qw '43E2DFD8279552543DABA81E5FCCEA2539C81D1F 663C531B51C9A466B9757282B438F635E64AC3CA');

recheck() Takes an array containing infohashes as argument.

Examples:
$utorrent->recheck(qw '43E2DFD8279552543DABA81E5FCCEA2539C81D1F 663C531B51C9A466B9757282B438F635E64AC3CA');

remove_torrent() - Delete a torrent from uTorrent. Takes an array containing infohashes as argument.

Examples:
$utorrent->remove_torrent(qw '43E2DFD8279552543DABA81E5FCCEA2539C81D1F 663C531B51C9A466B9757282B438F635E64AC3CA');

remove_data() - Delete a torrent and the data associated with it. Takes an array containing infohashes as argument.

Examples:
$utorrent->remove_data(qw '43E2DFD8279552543DABA81E5FCCEA2539C81D1F 663C531B51C9A466B9757282B438F635E64AC3CA');

SEE ALSO

http://forum.utorrent.com/viewtopic.php?id=25661

AUTHOR

rarbox, <rarbox@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2009 by rarbox

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.