version 1.7, 2005/05/02 22:47:48 |
version 1.11, 2007/02/07 23:09:05 |
|
|
#!/usr/bin/perl -T |
#!/usr/bin/perl -T |
#$Id$ |
#$RedRiver: NewTorrents.pl,v 1.10 2006/07/24 18:03:53 andrew Exp $ |
use strict; |
use strict; |
use warnings; |
use warnings; |
use diagnostics; |
use diagnostics; |
|
|
|
|
%ENV = (); |
%ENV = (); |
|
|
use YAML; |
|
|
|
# *** This requires --log-format="%t [%p] %o %f %l" on the rsync command |
|
|
|
my $last_dir = ''; |
my $last_dir = ''; |
while (<>) { |
while (<>) { |
|
print; |
chomp; |
chomp; |
if (my ($year, $mon, $mday, $time, $pid, $oper, $file, $size) = |
if (my ($message, $file, $xfer, $size) = |
m#^(\d{4})/(\d{2})/(\d{2}) (\d{2}:\d{2}:\d{2}) \[(\d+)\] (\S+) (.+) (\d+)$# ) { |
m#(.*)\s+\`([^']+)'\s+(\d+)\s+(\d+)#) { |
#print "($year, $mon, $mday, $time, $pid, $oper, $file, $size)\n"; |
next if $message eq 'Making directory'; |
my ($dir, $file) = $file =~ m#^(.*)/([^/]+)#; |
next unless $xfer; |
#print "$dir - $file\n"; |
|
|
my $dir = ''; |
|
if ($file =~ m#^(.*)/([^/]+)#) { |
|
($dir, $file) = ($1, $2); |
|
} |
|
#print "$message - $dir - $file\n"; |
if ($last_dir && $last_dir ne $dir) { |
if ($last_dir && $last_dir ne $dir) { |
StartTorrent($last_dir); |
StartTorrent($last_dir); |
} |
} |
$last_dir = $dir; |
$last_dir = $dir; |
} else { |
|
#print $_; |
|
} |
} |
} |
} |
|
|
|
|
my $should_fork = 1; |
my $should_fork = 1; |
|
|
if ($dir eq 'skip') { |
if ($dir eq 'skip') { |
$dir = ''; |
#$dir = ''; |
%Need_Update = (); |
%Need_Update = (); |
$should_fork = 0; |
$should_fork = 0; |
} else { |
} else { |
|
|
|
|
} |
} |
|
|
chdir $OBT->{DIR_HOME} or die "Can't chdir to $OBT->{DIR_HOME}: $!"; |
|
|
|
if (@now_update) { |
if (@now_update) { |
print "Making torrents for ", join(" ", @now_update), "\n"; |
print "Making torrents for ", join(" ", @now_update), "\n"; |
} else { |
} else { |
print "Remaking all torrents\n"; |
print "Remaking all torrents\n"; |
|
push @now_update, $dir; |
} |
} |
exec($OBT->{DIR_HOME} . '/regen.sh', @now_update); |
exec($OBT->{DIR_HOME} . '/regen.sh', @now_update); |
} |
} |