=================================================================== RCS file: /cvs/openbsd/OpenBSDTorrents/ServerTorrents.pl,v retrieving revision 1.9 retrieving revision 1.14 diff -u -r1.9 -r1.14 --- openbsd/OpenBSDTorrents/ServerTorrents.pl 2005/04/04 03:14:17 1.9 +++ openbsd/OpenBSDTorrents/ServerTorrents.pl 2005/05/05 21:33:42 1.14 @@ -1,15 +1,15 @@ #!/usr/bin/perl -T -#$Id: ServerTorrents.pl,v 1.9 2005/04/04 02:14:17 andrew Exp $ +#$Id: ServerTorrents.pl,v 1.14 2005/05/05 20:33:42 andrew Exp $ use strict; use warnings; use diagnostics; -use BT::MetaInfo; use LWP::UserAgent; use Time::Local; use lib 'lib'; use OpenBSDTorrents; +use BT::MetaInfo::Cached; %ENV = (); @@ -17,18 +17,10 @@ justme(); -my $url_torrents = 'http://openbsd.somedomain.net/dumptorrents.php'; -my $url_upload = 'http://openbsd.somedomain.net/newtorrents.php'; -my $url_delete = 'http://openbsd.somedomain.net/deltorrents.php'; -my $url_sanity = 'http://openbsd.somedomain.net/sanity.php'; - -my $user = 'torrentup'; -my $pass = 'ssapword'; - my @Sizes = ('', 'Ki', 'Mi', 'Gi', 'Ti'); my $ua = LWP::UserAgent->new; -my $response = $ua->get($url_torrents); +my $response = $ua->get($OBT->{URL_TORRENTS}); my %server_torrents; if ($response->is_success) { @@ -53,7 +45,7 @@ my %files; -opendir DIR, $TorrentDir or die "Couldn't opendir $TorrentDir: $!"; +opendir DIR, $OBT->{DIR_TORRENT} or die "Couldn't opendir $OBT->{DIR_TORRENT}: $!"; foreach (readdir DIR) { chomp; if (/^([^\/]+)$/) { @@ -115,7 +107,7 @@ } } -$ua->get($url_sanity); +$ua->get($OBT->{URL_SANITY}); sub Upload_Torrent { @@ -125,7 +117,7 @@ print "Uploading $file\n"; my $t; - eval { $t = BT::MetaInfo->new("$TorrentDir/$file"); }; + eval { $t = BT::MetaInfo::Cached->new("$OBT->{DIR_TORRENT}/$file"); }; if ($@) { warn "Error reading torrent $file\n"; return undef; @@ -133,7 +125,7 @@ my $size = $t->total_size; - my $i; + my $i = 0; while ($size > 1024) { $size /= 1024; $i++; @@ -150,10 +142,10 @@ $comment .= " [$size]"; $filename .= " [$time]"; - my $response = $ua->post($url_upload, { - username => $user, - password => $pass, - torrent => [ "$TorrentDir/$file" ], + my $response = $ua->post($OBT->{URL_UPLOAD}, { + username => $OBT->{UPLOAD_USER}, + password => $OBT->{UPLOAD_PASS}, + torrent => [ $OBT->{DIR_TORRENT} . "/$file" ], url => "/torrents/$file", filename => $filename, filedate => $time,