use Storable;
use LWP::Simple;
-=for eprints-api
-
use EPrints;
-my $institution = 'Grafički fakultet';
my $ep = EPrints->new();
-my $repo = $ep->repository( 'grf' );
-$repo->{config}->{enable_file_imports} = 1;
-$repo->{config}->{enable_web_imports} = 1;
-
+my $repo = $ep->repository( 'snz' );
+#$repo->{config}->{enable_file_imports} = 1;
+#$repo->{config}->{enable_web_imports} = 1;
my $dataset = $repo->dataset( 'eprint' );
my $list = $dataset->search;
my $count = $list->count;
warn "# found [$count] eprints\n";
-my $eprint = $dataset->dataobj( 21 );
-warn dump( $eprint->get_value('institution'), $institution );
+warn ref( $list );
+
+#warn "# ids = ",dump( $list->ids );
+
+my $info = { count => 0 };
+$list->map( sub {
+ my( $session, $dataset, $eprint, $info ) = @_;
+
+ my $biblionumber = $eprint->get_value('biblionumber');
+
+ $info->{biblionumber}->{$biblionumber}++;
+ $info->{count}++;
+
+}, $info );
+warn dump( $info );
+
+=for update
+
+#my $eprint = $dataset->dataobj( 21 );
+#warn dump( $eprint->get_value('institution'), $institution );
warn dump( $eprint );
my @v = split(/\t/, $_, $#cols + 1);
my %row;
@row{@cols} = @v;
-warn "## row = ",dump( \%row );
+#warn "## row = ",dump( \%row );
my $offset = $row{offset} // die "no offset";
my $biblionumber = $row{biblionumber} || die "no biblionumber";
if ( delete $files->{$biblionumber} ) {
$stat->{file}++;
- seek $marc_fh, $last_offset, 0;
- read $marc_fh, my $marc, $offset - $last_offset;
- print $import_fh $marc;
- warn "# marc $biblionumber\n";
+ if ( $info->{biblionumber}->{$biblionumber} ) {
+ $stat->{existing}++;
+ warn "EXISTING $biblionumber found in eprints\n";
+ } else {
+
+ $stat->{new}++;
+
+ seek $marc_fh, $last_offset, 0;
+ read $marc_fh, my $marc, $offset - $last_offset;
+ print $import_fh $marc;
+ warn "# marc $biblionumber\n";
+ }
} else {
$stat->{missing}++;
warn "# files left ", dump($files);
foreach my $biblionumber ( keys %$files ) {
+
+ if ( $info->{biblionumber}->{$biblionumber} ) {
+ $stat->{existing}++;
+ warn "EXISTING $biblionumber found in eprints\n";
+ next;
+ }
+
if ( my $marc = get("https://koha.ffzg.hr/cgi-bin/koha/opac-export.pl?op=export&bib=$biblionumber&format=utf8") ) {
print $import_fh $marc;
warn "## marc $biblionumber from koha!";