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

Diff for /openbsd/OpenBSDTorrents/ServerTorrents.pl between version 1.24 and 1.25

version 1.24, 2007/11/02 03:36:01 version 1.25, 2008/09/23 17:35:45
Line 1 
Line 1 
 #!/usr/bin/perl -T  #!/usr/bin/perl -T
 #$RedRiver: ServerTorrents.pl,v 1.23 2007/10/01 20:17:23 andrew Exp $  #$RedRiver: ServerTorrents.pl,v 1.24 2007/11/02 02:36:01 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                       $server_torrents{$torrent}{$hash} != 1
                 ) {                  ) {
                         Delete_Torrent($torrent, $hash);                          Delete_Torrent($torrent, $hash);
                 }                  }
Line 193 
Line 192 
         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 202 
         }, 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.24  
changed lines
  Added in v.1.25

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