projects
/
Biblio-Z3950.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
single field search mapping to fill text indexes
[Biblio-Z3950.git]
/
Aleph.pm
diff --git
a/Aleph.pm
b/Aleph.pm
index
474cd95
..
448beaa
100644
(file)
--- a/
Aleph.pm
+++ b/
Aleph.pm
@@
-15,9
+15,9
@@
sub diag {
# Koha Z39.50 query:
#
# Bib-1 @and @and @and @and @and @and @and @or
# Koha Z39.50 query:
#
# Bib-1 @and @and @and @and @and @and @and @or
-# @attr 1=8 isbn-issn
-# @attr 1=7 isbn-issn
# @attr 1=4 title
# @attr 1=4 title
+# @attr 1=7 isbn
+# @attr 1=8 issn
# @attr 1=1003 author
# @attr 1=16 dewey
# @attr 1=21 subject-holding
# @attr 1=1003 author
# @attr 1=16 dewey
# @attr 1=21 subject-holding
@@
-50,13
+50,15
@@
sub diag {
# WYR - Godina izdavanja
sub usemap {{
# WYR - Godina izdavanja
sub usemap {{
- 4 => 'WTI',
- 1003 => 'WTI',
- 16 => 'CU',
- 21 => 'SU',
-# 12 => '',
+ 4 => 'WTI=',
+ 7 => 'ISBN=',
+ 8 => 'ISSN=',
+ 1003 => 'AUT=',
+ 16 => 'DDC=',
+ 21 => 'SUB=',
+ 12 => 'LCN=',
# 1007 => '',
# 1007 => '',
-
# 1016 => '
',
+
1016 => 'WRD=
',
}};
our $session_id;
}};
our $session_id;
@@
-68,7
+70,7
@@
sub search {
$session_id ||= int rand(1000000000);
# FIXME allocate session just once
$session_id ||= int rand(1000000000);
# FIXME allocate session just once
- my $url = 'http://
161.53.240.197:8991
/F?RN=' . $session_id;
+ my $url = 'http://
katalog.nsk.hr
/F?RN=' . $session_id;
# fake JavaScript code on page which creates random session
diag "get $url";
# fake JavaScript code on page which creates random session
diag "get $url";
@@
-80,11
+82,13
@@
diag "advanced search";
$mech->follow_link( url_regex => qr/find-c/ );
$mech->follow_link( url_regex => qr/find-c/ );
+ my $database = $self->{database};
+
if ( $mech->content =~ m{Requested library is unavailable at the moment} ) {
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;
$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/ );
}
$mech->follow_link( url_regex => qr/find-c/ );
}
@@
-99,9
+103,11
@@
diag "submit search [$query] on ", $self->{database};
);
my $hits = 0;
);
my $hits = 0;
- if ( $mech->content =~ m{ukupno\s+(\d+).*do\s+(\d+)}
s ) {
+ if ( $mech->content =~ m{ukupno\s+(\d+).*do\s+(\d+)}
) { # FIXME Many results in Crotian
$hits = $1;
$hits = $2 if $2 && $2 < $1; # correct for max. results
$hits = $1;
$hits = $2 if $2 && $2 < $1; # correct for max. results
+ } elsif ( $mech->content =~ m{(\d+)\s+od\s+(\d+)} ) { # FIXME single result in Croatian
+ $hits = $2;
} else {
diag "get't find results in ", $mech->content;
return;
} else {
diag "get't find results in ", $mech->content;
return;
@@
-115,7
+121,7
@@
diag "in MARC format";
$mech->follow_link( url_regex => qr/format=001/ );
$mech->follow_link( url_regex => qr/format=001/ );
- return $hits;
+ return $
self->{hits} = $
hits;
}
}
@@
-137,6
+143,7
@@
sub next_marc {
warn "parse $nr";
$marc = MARC::Record->new;
warn "parse $nr";
$marc = MARC::Record->new;
+ $marc->encoding('utf-8');
$hash = {};
my $html = $mech->content;
$hash = {};
my $html = $mech->content;
@@
-144,6
+151,7
@@
warn "parse $nr";
sub field {
my ( $f, $v ) = @_;
$v =~ s/\Q \E/ /gs;
sub field {
my ( $f, $v ) = @_;
$v =~ s/\Q \E/ /gs;
+ $v =~ s/\s+$//gs;
warn "## $f\t$v\n";
$hash->{$f} = $v;
warn "## $f\t$v\n";
$hash->{$f} = $v;
@@
-165,6
+173,8
@@
warn "## ++ ", dump( $f, $v );
my ($i1,$i2) = (' ',' ');
($i1,$i2) = ($2,$3) if $f =~ s/^(...)(.)?(.)?/$1/;
my ($i1,$i2) = (' ',' ');
($i1,$i2) = ($2,$3) if $f =~ s/^(...)(.)?(.)?/$1/;
+ $i1 ||= ' ';
+ $i2 ||= ' ';
my @sf = split(/\|/, $v);
@sf = map { s/^(\w)\s+//; { $1 => $_ } } @sf;
#warn "## sf = ", dump(@sf);
my @sf = split(/\|/, $v);
@sf = map { s/^(\w)\s+//; { $1 => $_ } } @sf;
#warn "## sf = ", dump(@sf);
@@
-178,13
+188,15
@@
warn "## ++ ", dump( $f, $i1, $i2, @sf );
my $id = $hash->{SYS} || die "no SYS";
my $id = $hash->{SYS} || die "no SYS";
- $self->save_marc( $id, $marc->as_usmarc );
-
- $nr++;
+ $self->save_marc( "$id.marc", $marc->as_usmarc );
- $mech->follow_link( url_regex => qr/set_entry=0*$nr/ );
+ if ( $nr < $self->{hits} ) {
+ $nr++;
+ diag "follow link to next record $nr";
+ $mech->follow_link( url_regex => qr/set_entry=0*$nr/ );
+ }
- return $
marc->as_usmarc
;
+ return $
id
;
} else {
die "can't fetch COMARC format from ", $mech->content;
}
} else {
die "can't fetch COMARC format from ", $mech->content;
}