reformat output to single line per torrent
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 8 Sep 2011 14:21:28 +0000 (16:21 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 8 Sep 2011 14:21:28 +0000 (16:21 +0200)
torrent/rtorrent-dump.pl

index fecd2f9..f8207f4 100755 (executable)
@@ -7,6 +7,28 @@ use Data::Dump qw(dump);
 
 my $h = new RTPG(url=> $ENV{SOCKET} || '/srv/cloudstore/var/torrent/socket');
 
+my $sfmt;
+my @keys;
+while (<DATA>) {
+       chomp;
+       next if /^#/;
+       my ($name,$fmt) = split(/\t+/,$_,2);
+       $sfmt .= $fmt . '|';
+       push @keys, $name;
+}
+$sfmt =~ s/\|$/\n/;
+
 # arrayref and error (standard version)
 my ($tlist, $error)=$h->torrents_list;
-print dump( $tlist, $error );
+warn dump( $tlist, $error );
+
+printf $sfmt, @keys;
+foreach my $t ( @$tlist ) {
+       printf $sfmt, map { $t->{$_} } @keys;
+}
+
+__DATA__
+#hash                  %-40s
+percent                        %5s
+status                 %-11s
+base_filename  %s