### download compressed version instead?
my %urls = (
- 'public' => 'http://core.freshmeat.net/backend/appindex.txt',
+ 'public' => 'http://www.freshmeat.net/backend/appindex.txt',
'private' => 'http://feed.freshmeat.net/appindex/appindex.txt',
);
}
if (!&showPackage($sstr)) { # no exact match.
- my $start_time = &main::gettimeofday();
+ my $start_time = &main::timeget();
my %hash;
# search by key/NAME first.
}
# show how long it took.
- my $delta_time = &main::gettimeofday() - $start_time;
+ my $delta_time = &main::timedelta($start_time);
&main::status(sprintf("freshmeat: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
for (@list) {
}
sub downloadIndex {
- my $start_time = &main::gettimeofday(); # set the start time.
- my $idx = "$main::bot_base_dir/Temp/fm_index.txt";
+ my $start_time = &main::timeget(); # set the start time.
+ my $idx = "$main::param{tempDir}/fm_index.txt";
&main::msg($main::who, "Updating freshmeat index... please wait");
return;
}
- open(IN, $idx);
+ if ($idx =~ /bz2$/) {
+ open(IN, "bzcat $idx |");
+ } elsif ($idx =~ /gz$/) {
+ open(IN, "gzcat $idx |");
+ } else {
+ open(IN, $idx);
+ }
# delete the table before we redo it.
&main::deleteTable("freshmeat");
&main::dbRaw("LOCK", "LOCK TABLES freshmeat WRITE");
my @data;
+ my @done;
while (my $line = <IN>) {
chop $line;
if ($line ne "%%") {
next;
}
- if ($i % 100 == 0 and $i != 0) {
+ if ($i % 200 == 0 and $i != 0) {
&main::DEBUG("FM: unlocking and locking.");
&main::dbRaw("UNLOCK", "UNLOCK TABLES");
### another lame hack to "prevent" errors.
&main::dbRaw("LOCK", "LOCK TABLES freshmeat WRITE");
}
+ if (grep /^\Q$data[0]\E$/, @done) {
+ &main::DEBUG("dupe? $data[0]");
+ @data = ();
+ next;
+ }
+
$i++;
pop @data;
$data[1] ||= "none";
$data[2] ||= "none";
&main::dbSetRow("freshmeat", @data);
+ push(@done,$data[0]);
@data = ();
}
close IN;
&main::DEBUG("FM: data ".scalar(@data) );
&main::dbRaw("UNLOCK", "UNLOCK TABLES");
- my $delta_time = &main::gettimeofday() - $start_time;
+ my $delta_time = &main::timedelta($start_time);
&main::status(sprintf("Freshmeat: %.02f sec to complete.", $delta_time)) if ($delta_time > 0);
my $count = &main::countKeys("freshmeat");
}
sub freshmeatAnnounce {
- my $file = "$main::bot_base_dir/Temp/fm_recent.txt";
+ my $file = "$main::param{tempDir}/fm_recent.txt";
my @old;
### if file exists, lets read it.