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 %a = ( autodie => 1 );
28 @a{ qw(username password) } = split(/:/, $ENV{TR_AUTH}) if $ENV{TR_AUTH};
31 my $tc = Transmission::Client->new( %a );
33 if($action eq 'list') {
34 printf "%3s %-34s %4s %4s %5s %5s\n", 'id', 'name', 'lcrs', 'sdrs', 'rate', 'eta';
36 for my $torrent ($tc->read_torrents) {
37 printf "%3i %-34s %4s %4s %5s %5s\n",
39 substr($torrent->name, 0, 34),
40 _peers($torrent->leechers),
41 _peers($torrent->seeders),
42 _rate($torrent->rate_download),
47 elsif($action eq 'session') {
48 if(my $set = shift @ARGV) {
49 $tc->session->$set(shift @ARGV);
50 $tc->session->${ \"clear_$set" };
51 printf "%s: %s\n", $set, $tc->session->$set;
55 my $res = $tc->session->read_all;
56 for my $key (sort keys %$res) {
57 printf "%-30s %s\n", $key, $res->{$key};
61 elsif($action eq 'stats') {
62 my $res = $tc->session->stats->read_all;
63 for my $key (sort keys %$res) {
64 printf "%-30s %s\n", $key, $res->{$key};
68 elsif($action eq 'add') {
71 download_dir => '/rsync1/s1/torrent/download',
75 elsif($action eq 'remove') {
87 #==============================================================================
107 elsif($kbps < 1000) {
111 return int($kbps / 1e3) . 'k';
114 return int($kbps / 1e6) . 'M';
131 return int($sec / 6) / 10 . "m";
133 elsif($sec < 86400) {
134 return int($sec / 360) / 10 . "h";
142 exec perldoc => -tT => $0;
147 This library is free software; you can redistribute it and/or modify it under
148 the same terms as Perl itself.