5 transmission-client.pl - Alternative to transmission-remote
9 transmission-client.pl list;
10 transmission-client.pl session;
11 transmission-client.pl session $key $value;
12 transmission-client.pl stats;
16 This is an example application for L<Transmission::Client>
23 use Transmission::Client;
25 my $action = shift @ARGV or _help();
27 my ( $username, $password ) = split(/:/, $ENV{TR_AUTH} );
29 my $tc = Transmission::Client->new(
31 username => $username,
32 password => $password,
35 if($action eq 'list') {
36 printf "%3s %-34s %4s %4s %5s %5s\n", 'id', 'name', 'lcrs', 'sdrs', 'rate', 'eta';
38 for my $torrent ($tc->read_torrents) {
39 printf "%3i %-34s %4s %4s %5s %5s\n",
41 substr($torrent->name, 0, 34),
42 _peers($torrent->leechers),
43 _peers($torrent->seeders),
44 _rate($torrent->rate_download),
49 elsif($action eq 'session') {
50 if(my $set = shift @ARGV) {
51 $tc->session->$set(shift @ARGV);
52 $tc->session->${ \"clear_$set" };
53 printf "%s: %s\n", $set, $tc->session->$set;
57 my $res = $tc->session->read_all;
58 for my $key (sort keys %$res) {
59 printf "%-30s %s\n", $key, $res->{$key};
63 elsif($action eq 'stats') {
64 my $res = $tc->session->stats->read_all;
65 for my $key (sort keys %$res) {
66 printf "%-30s %s\n", $key, $res->{$key};
75 #==============================================================================
99 return int($kbps / 1e3) . 'k';
102 return int($kbps / 1e6) . 'M';
119 return int($sec / 6) / 10 . "m";
121 elsif($sec < 86400) {
122 return int($sec / 360) / 10 . "h";
130 exec perldoc => -tT => $0;
135 This library is free software; you can redistribute it and/or modify it under
136 the same terms as Perl itself.