=================================================================== RCS file: /cvs/openbsd/OpenBSDTorrents/ServerTorrents.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- openbsd/OpenBSDTorrents/ServerTorrents.pl 2005/03/24 00:42:07 1.2 +++ openbsd/OpenBSDTorrents/ServerTorrents.pl 2005/03/24 19:49:51 1.3 @@ -1,5 +1,5 @@ #!/usr/bin/perl -T -#$Id: ServerTorrents.pl,v 1.2 2005/03/24 00:42:07 andrew Exp $ +#$Id: ServerTorrents.pl,v 1.3 2005/03/24 19:49:51 andrew Exp $ use strict; use warnings; use diagnostics; @@ -13,6 +13,7 @@ %ENV = (); + use YAML; my $url_torrents = 'http://openbsd.somedomain.net/dumptorrents.php'; @@ -22,6 +23,7 @@ my $user = 'torrentup'; my $pass = 'ssapword'; +my @Sizes = ('', 'Ki', 'Mi', 'Gi', 'Ti'); my $ua = LWP::UserAgent->new; my $response = $ua->get($url_torrents); @@ -121,13 +123,24 @@ return undef; } + my $size = $t->total_size; + + my $i; + while ($size > 1024) { + $size /= 1024; + $i++; + } + $size = sprintf('%.2f', $size); + $size .= $Sizes[$i] . 'B'; + my $comment = $t->{comment}; $comment =~ s/\n.*$//s; - - my ($filename) = $comment =~ /Files from ([^<]+)/; + + my ($filename) = $comment =~ /Files from (.+)/; $filename =~ s#/# #g; - $filename .= ' (' . $time . ')'; + $comment .= " [$size]"; + $filename .= " [$time]"; my $response = $ua->post($url_upload, { username => $user,