1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
|
NAME
Transmission::Client - Interface to Transmission
VERSION
0.0805
DESCRIPTION
Transmission::Client is the main module in a collection of modules to
communicate with Transmission. Transmission is:
Transmission is a cross-platform BitTorrent client that is:
* Easy
* Lean
* Native
* Powerful
* Free
If you want to communicate with "transmission-daemon", this is a module
which can help you with that.
The documentation is half copy/paste from the Transmission RPC spec:
<https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt>
This module differs from P2P::Transmission in (at least) two ways: This
one use Moose and it won't die. The latter is especially annoying in the
constructor.
SYNOPSIS
use Transmission::Client;
my $client = Transmission::Client->new;
my $torrent_id = 2;
my $data = base64_encoded_data();
$client->add(metainfo => $data) or confess $client->error;
$client->remove($torrent_id) or confess $client->error;
for my $torrent (@{ $client->torrents }) {
print $torrent->name, "\n";
for my $file (@{ $torrent->files }) {
print "> ", $file->name, "\n";
}
}
print $client->session->download_dir, "\n";
FAULT HANDLING
In 0.06 Transmission::Client can be constructed with "autodie" set to
true, to make this object confess instead of just setting "error".
Example:
my $client = Transmission::Client->new(autodie => 1);
eval {
$self->add(filename => 'foo.torrent');
} or do {
# add() failed...
};
SEE ALSO
Transmission::AttributeRole Transmission::Session Transmission::Torrent
Transmission::Utils
ATTRIBUTES
url
$str = $self->url;
Returns an URL to where the Transmission rpc api is. Default value is
"http://localhost:9091/transmission/rpc";
error
$str = $self->error;
Returns the last error known to the object. All methods can return empty
list in addition to what specified. Check this attribute if so happens.
Like "autodie"? Create your object with "autodie" set to true and this
module will throw exceptions in addition to setting this variable.
username
$str = $self->username;
Used to authenticate against Transmission.
password
$str = $self->password;
Used to authenticate against Transmission.
timeout
$int = $self->timeout;
Number of seconds to wait for RPC response.
session
$session_obj = $self->session;
$stats_obj = $self->stats;
Returns an instance of Transmission::Session. "stats()" is a proxy
method on "session".
torrents
$array_ref = $self->torrents;
$self->clear_torrents;
Returns an array-ref of Transmission::Torrent objects. Default value is
a full list of all known torrents, with as little data as possible read
from Transmission. This means that each request on a attribute on an
object will require a new request to Transmission. See "read_torrents"
for more information.
version
$str = $self->version;
Get Transmission version.
session_id
$self->session_id($str);
$str = $self->session_id;
The session ID used to communicate with Transmission.
METHODS
add
$bool = $self->add(%args);
key | value type & description
-----------------+-------------------------------------------------
download_dir | string path to download the torrent to
filename | string filename or URL of the .torrent file
metainfo | string torrent content
paused | boolean if true, don't start the torrent
peer_limit | number maximum number of peers
Either "filename" or "metainfo" MUST be included. All other arguments
are optional.
See "3.4 Adding a torrent" from
<https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt>
remove
$bool = $self->remove(%args);
key | value type & description
-------------------+-------------------------------------------------
ids | array torrent list, as described in 3.1
delete_local_data | boolean delete local data. (default: false)
"ids" can also be the string "all". "ids" is required.
See "3.4 Removing a torrent" from
<https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt>
move
$bool = $self->move(%args);
string | value type & description
------------+-------------------------------------------------
ids | array torrent list, as described in 3.1
location | string the new torrent location
move | boolean if true, move from previous location.
| otherwise, search "location" for files
"ids" can also be the string "all". "ids" and "location" is required.
See "3.5 moving a torrent" from
<https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt>
start
$bool = $self->start($ids);
Will start one or more torrents. $ids can be a single int, an array of
ints or the string "all".
stop
$bool = $self->stop($ids);
Will stop one or more torrents. $ids can be a single int, an array of
ints or the string "all".
verify
$bool = $self->stop($ids);
Will verify one or more torrents. $ids can be a single int, an array of
ints or the string "all".
read_torrents
@list = $self->read_torrents(%args);
$array_ref = $self->read_torrents(%args);
key | value type & description
------------+-------------------------------------------------
ids | array torrent list, as described in 3.1
| this is optional
lazy_read | will create objects with as little data as possible.
List context
Returns a list of Transmission::Torrent objects and sets the
"torrents" attribute.
Scalar context
Returns an array-ref of Transmission::Torrent.
rpc
$any = $self->rpc($method, %args);
Communicate with backend. This methods is meant for internal use.
read_all
1 == $self->read_all;
This method will try to populate ALL torrent, session and stats
information, using three requests.
LICENSE
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
COPYRIGHT
Copyright 2009-2013, Jan Henning Thorsen <jhthorsen@cpan.org>
and contributors
Current maintainer: Olof Johansson - "olof@cpan.org"
|