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