[BACK]Return to ServerTorrents.pl CVS log [TXT][DIR] Up to [local] / openbsd / OpenBSDTorrents

Diff for /openbsd/OpenBSDTorrents/ServerTorrents.pl between version 1.2 and 1.8

version 1.2, 2005/03/24 00:42:07 version 1.8, 2005/04/01 01:20:15
Line 13 
Line 13 
   
 %ENV = ();  %ENV = ();
   
 use YAML;  #use YAML;
   
   justme();
   
 my $url_torrents = 'http://openbsd.somedomain.net/dumptorrents.php';  my $url_torrents = 'http://openbsd.somedomain.net/dumptorrents.php';
 my $url_upload   = 'http://openbsd.somedomain.net/newtorrents.php';  my $url_upload   = 'http://openbsd.somedomain.net/newtorrents.php';
 my $url_delete   = 'http://openbsd.somedomain.net/deltorrents.php';  my $url_delete   = 'http://openbsd.somedomain.net/deltorrents.php';
   my $url_sanity   = 'http://openbsd.somedomain.net/sanity.php';
   
 my $user = 'torrentup';  my $user = 'torrentup';
 my $pass = 'ssapword';  my $pass = 'ssapword';
   
   my @Sizes = ('', 'Ki', 'Mi', 'Gi', 'Ti');
 my $ua = LWP::UserAgent->new;  my $ua = LWP::UserAgent->new;
   
 my $response = $ua->get($url_torrents);  my $response = $ua->get($url_torrents);
Line 51 
Line 55 
 my %files;  my %files;
 opendir DIR, $TorrentDir or die "Couldn't opendir $TorrentDir: $!";  opendir DIR, $TorrentDir or die "Couldn't opendir $TorrentDir: $!";
 foreach (readdir DIR) {  foreach (readdir DIR) {
           chomp;
         if (/^([^\/]+)$/) {          if (/^([^\/]+)$/) {
                 $_ = $1;                  $_ = $1;
         } else {          } else {
                 die "Invalid character in $_: $!";                  die "Invalid character in $_: $!";
         }          }
         next unless /\.torrent$/;          next unless /\.torrent$/;
         chomp;  
         my ($name, $year, $mon, $mday, $hour, $min) =          my ($name, $year, $mon, $mday, $hour, $min) =
            /^(.*)-(\d{4})-(\d{2})-(\d{2})-(\d{2})(\d{2})/;             /^(.*)-(\d{4})-(\d{2})-(\d{2})-(\d{2})(\d{2})/;
   
           $mon--;
   
         my $epoch = timegm(0,$min,$hour,$mday,$mon,$year);          my $epoch = timegm(0,$min,$hour,$mday,$mon,$year);
   
         $files{$name}{$epoch} = {          $files{$name}{$epoch} = {
Line 106 
Line 112 
         }          }
 }  }
   
   $ua->get($url_sanity);
   
 sub Upload_Torrent  sub Upload_Torrent
 {  {
Line 121 
Line 128 
                 return undef;                  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};          my $comment = $t->{comment};
         $comment =~ s/\n.*$//s;          $comment =~ s/\n.*$//s;
   
         my ($filename) = $comment =~ /Files from ([^<]+)/;          my ($filename) = $comment =~ /Files from (.+)/;
         $filename =~ s#/# #g;          $filename =~ s#/# #g;
   
         $filename .= ' (' . $time . ')';          $comment  .= " [$size]";
           $filename .= " [$time]";
   
         my $response = $ua->post($url_upload, {          my $response = $ua->post($url_upload, {
                 username => $user,                  username => $user,
Line 142 
Line 160 
         }, Content_Type => 'form-data');          }, Content_Type => 'form-data');
   
         if ($response->is_success) {          if ($response->is_success) {
                 print "Uploaded  $file\n";                  print STDERR "Uploaded  $file\n";
                 #print $response->content;                  #print $response->content;
         } else {          } else {
                 die $response->status_line;                  die $response->status_line;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.8

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>