stop on empty next_marc
[Biblio-Z3950.git] / server.pl
index ea711c5..b7029a3 100755 (executable)
--- a/server.pl
+++ b/server.pl
@@ -10,6 +10,7 @@ use Data::Dumper;
 use Aleph;
 use GoogleBooks;
 use vuFind;
+use DPLA;
 
 use Encode;
 
@@ -21,6 +22,7 @@ my $databases = {
        'ZAG01'  => 'Aleph',
        'GOOGLEBOOKS' => 'GoogleBooks',
        'HATHITRUST' => 'vuFind',
+       'DPLA'   => 'DPLA',
 };
 
 my $max_records = 3; # XXX configure this
@@ -147,7 +149,9 @@ sub FetchHandle {
        my $from = $rs->{from} || die "no from?";
        # fetch records up to offset
        while(  $#{ $rs->{results} } < $offset ) {
-               push @{ $rs->{results} }, $from->next_marc;
+               my $marc = $from->next_marc;
+               last if ! $marc; # abort results
+               push @{ $rs->{results} }, $marc;
                warn "# rs result ", $#{ $rs->{results} },"\n";
        }