| version 1.20, 2005/06/03 02:32:40 |
version 1.24, 2007/11/02 03:36:01 |
|
|
| #!/usr/bin/perl -T |
#!/usr/bin/perl -T |
| #$Id$ |
#$RedRiver: ServerTorrents.pl,v 1.23 2007/10/01 20:17:23 andrew Exp $ |
| use strict; |
use strict; |
| use warnings; |
use warnings; |
| use diagnostics; |
use diagnostics; |
| |
|
| use LWP::UserAgent; |
use LWP::UserAgent; |
| use Time::Local; |
use Time::Local; |
| |
use File::Basename; |
| |
#use YAML; |
| |
|
| use lib 'lib'; |
use lib 'lib'; |
| use OpenBSDTorrents; |
use OpenBSDTorrents; |
|
|
| |
|
| %ENV = (); |
%ENV = (); |
| |
|
| #use YAML; |
|
| |
|
| justme(); |
justme(); |
| |
|
| my @Sizes = ('', 'Ki', 'Mi', 'Gi', 'Ti'); |
my @Sizes = ('', 'Ki', 'Mi', 'Gi', 'Ti'); |
|
|
| die $response->status_line; |
die $response->status_line; |
| } |
} |
| |
|
| |
|
| my %files; |
my %files; |
| opendir DIR, $OBT->{DIR_TORRENT} or die "Couldn't opendir $OBT->{DIR_TORRENT}: $!"; |
opendir DIR, $OBT->{DIR_TORRENT} or die "Couldn't opendir $OBT->{DIR_TORRENT}: $!"; |
| foreach (readdir DIR) { |
foreach (readdir DIR) { |
|
|
| die "Invalid character in $_: $!"; |
die "Invalid character in $_: $!"; |
| } |
} |
| next unless /\.torrent$/; |
next unless /\.torrent$/; |
| my ($name, $year, $mon, $mday, $hour, $min) = |
|
| /^(.*)-(\d{4})-(\d{2})-(\d{2})-(\d{2})(\d{2})/; |
|
| |
|
| |
my $name = basename($_, '.torrent'); |
| |
|
| |
if (my ($base, $year, $mon, $mday, $hour, $min) = |
| |
/^(.*)-(\d{4})-(\d{2})-(\d{2})-(\d{2})(\d{2})/) { |
| |
$name = $base; |
| |
} |
| |
|
| my $t; |
my $t; |
| eval { |
eval { |
| $t = BT::MetaInfo::Cached->new( |
$t = BT::MetaInfo::Cached->new( |
| $OBT->{DIR_TORRENT} . '/' . $_, |
$OBT->{DIR_TORRENT} . '/' . $_, |
| { |
{ |
| cache_root => |
cache_root => '/tmp/OBTFileCache' |
| $OBT->{DIR_HOME} . '/FileCache' |
#$OBT->{DIR_HOME} . '/FileCache' |
| } |
} |
| ); |
); |
| }; |
}; |
|
|
| } |
} |
| closedir DIR; |
closedir DIR; |
| |
|
| #use Data::Dumper; |
#print Dump \%server_torrents; |
| #print Dumper \%server_torrents;#, \%files; |
#print Dump \%files; |
| #exit; |
#exit; |
| |
|
| my %torrents; |
my %torrents; |
|
|
| my $comment = $t->{comment}; |
my $comment = $t->{comment}; |
| $comment =~ s/\n.*$//s; |
$comment =~ s/\n.*$//s; |
| |
|
| my ($filename) = $comment =~ /Files from (.+)/; |
my $filename = |
| |
$comment =~ /($OBT->{BASENAME}.+)/ ? $1 |
| |
: $file; |
| $filename =~ s#/# #g; |
$filename =~ s#/# #g; |
| |
$filename =~ s/\.torrent\z//; |
| |
|
| $comment .= " [$size]"; |
$comment .= " [$size]"; |
| $filename .= " [$time]"; |
$filename .= " [$time]"; |