fix and cleanup database selection from link
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 23 Oct 2010 19:30:08 +0000 (21:30 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 23 Oct 2010 19:30:08 +0000 (21:30 +0200)
Aleph.pm

index 3ad6287..1696dc1 100644 (file)
--- a/Aleph.pm
+++ b/Aleph.pm
@@ -80,11 +80,13 @@ diag "advanced search";
 
        $mech->follow_link( url_regex => qr/find-c/ );
 
+       my $database = $self->{database};
+
        if ( $mech->content =~ m{Requested library is unavailable at the moment} ) {
-               warn "WARNING: default database not available";
+               warn "ERROR: default database not available, try to swith to $database\n";
                $self->save_content;
-               my $url = 'local_base=' . lc $self->{database};
-               $mech->follow_link( url_regex => qr/$url/ );
+               $mech->follow_link( url_regex => qr/local_base=$database/i );
+               diag "re-try advanced search";
                $mech->follow_link( url_regex => qr/find-c/ );
        }