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

Diff for /openbsd/OpenBSDTorrents/ServerTorrents.pl between version 1.23 and 1.26

version 1.23, 2007/10/01 21:17:23 version 1.26, 2008/12/29 22:02:14
Line 1 
Line 1 
 #!/usr/bin/perl -T  #!/usr/bin/perl -T
 #$RedRiver: ServerTorrents.pl,v 1.22 2006/07/24 18:03:53 andrew Exp $  #$RedRiver: ServerTorrents.pl,v 1.25 2008/09/23 16:35:45 andrew Exp $
 use strict;  use strict;
 use warnings;  use warnings;
 use diagnostics;  use diagnostics;
Line 35 
Line 35 
             my ($name, $hash, $disabled) = split /\t/;              my ($name, $hash, $disabled) = split /\t/;
             next if $name eq 'File';              next if $name eq 'File';
   
             $name =~ s#^/torrents/##;              $name =~ s#.*/##;
             $server_torrents{$name}{$hash} = $disabled;              $server_torrents{$name}{$hash} = $disabled;
         }          }
     }      }
Line 99 
Line 99 
         foreach my $epoch ( sort { $b <=> $a } keys %{ $files{$name} } ) {          foreach my $epoch ( sort { $b <=> $a } keys %{ $files{$name} } ) {
                 #print "\t$epoch\n";                  #print "\t$epoch\n";
                 my $torrent = $files{$name}{$epoch}{file};                  my $torrent = $files{$name}{$epoch}{file};
                   my $hash = unpack("H*", $files{$name}{$epoch}{'details'}->info_hash );
                   #printf "LOCAL:  [%s] [%s]\n", $hash, $torrent;
   
                 my $hash = $files{$name}{$epoch}{'details'}->info_hash;  
                 $hash = unpack("H*", $hash);  
   
                 $torrents{$torrent}{$hash} = $files{$name}{$epoch};                  $torrents{$torrent}{$hash} = $files{$name}{$epoch};
   
                 unless (exists $server_torrents{$torrent}{$hash}) {                  unless (exists $server_torrents{$torrent}{$hash}) {
Line 113 
Line 112 
   
 foreach my $torrent (keys %server_torrents) {  foreach my $torrent (keys %server_torrents) {
         foreach my $hash (keys %{ $server_torrents{$torrent} }) {          foreach my $hash (keys %{ $server_torrents{$torrent} }) {
                 unless (                  #printf "SERVER: [%s] [%s]\n", $hash, $torrent;
                         exists $torrents{$torrent}{$hash} ||                  if ((! exists $torrents{$torrent}{$hash}) &&
                         $server_torrents{$torrent}{$hash} == 1                       defined $server_torrents{$torrent}{$hash} &&
                        $server_torrents{$torrent}{$hash} != 1
                 ) {                  ) {
                         Delete_Torrent($torrent, $hash);                          Delete_Torrent($torrent, $hash);
                 }                  }
Line 159 
Line 159 
         $comment =~ s/\n.*$//s;          $comment =~ s/\n.*$//s;
   
         my $filename =          my $filename =
                  $comment =~ /Files from (.+)/ ? $1                   $comment =~ /($OBT->{BASENAME}.+)/ ? $1
                 :                                $file;                  :                                $file;
         $filename =~ s#/# #g;          $filename =~ s#/# #g;
         $filename =~ s/\.torrent\z//;          $filename =~ s/\.torrent\z//;
Line 193 
Line 193 
         my $hash = shift;          my $hash = shift;
         die "No hash passed!" unless $hash;          die "No hash passed!" unless $hash;
   
         print "Disabling $filename\n";          print "Removing $filename [$hash]\n";
   
         my $response = $ua->post($OBT->{'URL_DELETE'}, {          my $response = $ua->post($OBT->{'URL_DELETE'}, {
                 username => $OBT->{UPLOAD_USER},                  username => $OBT->{UPLOAD_USER},
Line 203 
Line 203 
         }, Content_Type => 'form-data');          }, Content_Type => 'form-data');
   
         if ($response->is_success) {          if ($response->is_success) {
                 #print $response->content;                  my ($result) = $response->content =~ /class="error"\>([^<]+)\</;
                 if ($response->content =~ /Torrent was removed successfully/) {  
                         print STDERR "Disabled $filename\n";                  if ($result eq 'Torrent was removed successfully.') {
                 } else {                          print STDERR "Removed $filename [$hash]\n";
                         print STDERR "An error occoured removing $filename\n";  
                 }                  }
         } else {                  elsif ($result) {
                 die $response->status_line;                          print STDERR "Error: $result (removing $filename [$hash])\n";
                   }
                   else {
                           print STDERR "An unknown error occurred removing $filename [$hash]\n";
                   }
           }
           else {
                   die $response->status_line . " removing $filename [$hash]\n";
         }          }
 }  }

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.26

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