API workers using Gearman::Driver
[cloudstore.git] / torrent / transmission-client.pl
index d7f7647..8ddae2f 100755 (executable)
@@ -10,6 +10,8 @@ transmission-client.pl - Alternative to transmission-remote
  transmission-client.pl session;
  transmission-client.pl session $key $value;
  transmission-client.pl stats;
+ transmission-client.pl add /path/to/file.torrent
+ transmission-client.pl remove 1 [,2,3...]
 
 =head1 DESCRIPTION
 
@@ -21,21 +23,20 @@ use strict;
 use warnings;
 use lib qw(lib);
 use Transmission::Client;
+use Data::Dump qw(dump);
 
 my $action = shift @ARGV or _help();
 
-my ( $username, $password ) = split(/:/, $ENV{TR_AUTH} );
+my %a = ( autodie => 1 );
+@a{ qw(username password) } = split(/:/, $ENV{TR_AUTH}) if $ENV{TR_AUTH};
 
-my $tc = Transmission::Client->new(
-       autodie => 1,
-       username => $username,
-       password => $password,
-);
+my $tc = Transmission::Client->new( %a );
 
 if($action eq 'list') {
     printf "%3s %-34s %4s %4s %5s %5s\n", 'id', 'name', 'lcrs', 'sdrs', 'rate', 'eta';
     print "-" x 79, "\n";
     for my $torrent ($tc->read_torrents) {
+       warn dump($torrent) if $ENV{DEBUG};
         printf "%3i %-34s %4s %4s %5s %5s\n",
             $torrent->id,
             substr($torrent->name, 0, 34),