Mojo::Transmission - Client for talking with Transmission BitTorrent daemon
Mojo::Transmission is a very lightweight client for exchanging data with the Transmission BitTorrent daemon using RPC.
The documentation in this module might seem sparse, but that is because the API is completely transparent regarding the data-structure received from the Transmission API.
my $transmission = Mojo::Transmission->new; $transmission->add(url => "http://releases.ubuntu.com/17.10/ubuntu-17.10.1-desktop-amd64.iso.torrent"); my $torrents = $transmission->torrent([]); $transmission->torrent(remove => $torrents[0]->{id}) if @$torrents;
$array_ref = $transmission->default_trackers; $transmission = $transmission->default_trackers([$url, ...]);
Holds a list of default trackers that can be used by "add".
$ua = $transmission->ua; $transmission = $transmission->ua(Mojo::UserAgent->new);
Holds a Mojo::UserAgent used to issue requests to backend.
$url = $transmission->url; $transmission = $transmission->url(Mojo::URL->new);
Mojo::URL object holding the URL to the transmission daemon. Default to the TRANSMISSION_RPC_URL environment variable or "http://localhost:9091/transmission/rpc".
TRANSMISSION_RPC_URL
# Generic call $res = $transmission->add(\%args); $transmission = $transmission->add(\%args, sub { my ($transmission, $res) = @_ }); # magnet:?xt=${xt}&dn=${dn}&tr=${tr} $transmission->add({xt => "...", dn => "...", tr => [...]}); # magnet:?xt=urn:btih:${hash}&dn=${dn}&tr=${tr} $transmission->add({hash => "...", dn => "...", tr => [...]}); # Custom URL or file $transmission->add({url => "...", tr => [...]});
This method can be used to add a torrent. tr defaults to "default_trackers".
tr
See also https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt#L356.
$promise = $transmission->add_p(\%args);
Same as "add", but returns a promise.
# session-get $transmission = $transmission->session([], sub { my ($transmission, $res) = @_; }); $res = $transmission->session([]); # session-set $transmission = $transmission->session(\%attrs, sub { my ($transmission, $res) = @_; }); $res = $transmission->session(\%attrs);
Used to get or set Transmission session arguments.
See also https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt#L444.
$promise = $transmission->session_p([]); $promise = $transmission->session_p(\%args);
Same as "session", but returns a promise.
# session-stats $transmission = $transmission->stats(sub { my ($transmission, $res) = @_; }); $res = $transmission->stats;
Used to retrieve Transmission statistics.
$promise = $transmission->stats_p;
Same as "stats", but returns a promise.
See also https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt#L531.
# torrent-get $transmission = $transmission->torrent(\@attrs, $id, sub { my ($transmission, $res) = @_; }); $res = $transmission->torrent(\@attrs, $id); # torrent-set $transmission = $transmission->torrent(\%attrs, $id, sub { my ($transmission, $res) = @_; }); $res = $transmission->torrent(\%attrs, $id); # torrent-$action $transmission = $transmission->torrent(remove => $id, sub { my ($transmission, $res) = @_; }); $transmission = $transmission->torrent(start => $id, sub { my ($transmission, $res) = @_; }); $transmission = $transmission->torrent(stop => $id, sub { my ($transmission, $res) = @_; }); $res = $transmission->torrent($action => $id); # torrent-remove + delete-local-data $transmission = $transmission->torrent(purge => $id, sub { my ($transmission, $res) = @_; });
Used to get or set torrent related attributes or execute an action on a torrent.
$id can either be a scalar or an array-ref, referring to which torrents to use.
$id
See also:
Get torrent attributes
https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt#L127.
Set torrent attributes
https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt#L90
Torrent actions
https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt#L71.
$promise = $transmission->torrent_p(\@attrs, ...); $promise = $transmission->torrent_p(\%attrs, ...); $promise = $transmission->torrent_p($action => ...);
Same as "torrent", but returns a promise.
use Mojo::Transmission "tr_status"; $str = tr_status $int;
Returns a description for the $int status:
$int
0 = stopped 1 = check_wait 2 = check 3 = download_wait 4 = download 5 = seed_wait 6 = seed
Returns empty string on invalid input.
Copyright (C) 2016, Jan Henning Thorsen
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
Jan Henning Thorsen - jhthorsen@cpan.org
jhthorsen@cpan.org
To install Mojo::Transmission, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::Transmission
CPAN shell
perl -MCPAN -e shell install Mojo::Transmission
For more information on module installation, please visit the detailed CPAN module installation guide.