From: Dobrica Pavlinusic Date: Mon, 16 Apr 2012 23:18:13 +0000 (+0200) Subject: import cover images from filesystem and create biblio and items X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=commitdiff_plain;h=e36260357f2705c10a360ede9710dcce7ae7a6bb;p=koha_gimpoz import cover images from filesystem and create biblio and items --- diff --git a/misc/gimpoz/import-images.pl b/misc/gimpoz/import-images.pl new file mode 100755 index 0000000000..2c72569e75 --- /dev/null +++ b/misc/gimpoz/import-images.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl +use warnings; +use strict; +use autodie; +use Data::Dump qw(dump); + +use MARC::Record; + +$|=1; +use lib '/srv/koha_gimpoz/'; + +BEGIN { + $ENV{KOHA_CONF} = '/etc/koha/sites/gimpoz/koha-conf.xml'; +} +use C4::Images; +use C4::Biblio; +use C4::Items; + +my $source_dir = '/data/gimpoz/dvd1'; +my $replace = 1; +my $frameworkcode = ''; + +sub marc { + my $marc = {@_}; + print "MARC ",dump($marc),$/; +} + +my $biblionumber; + +open(my $find, '-|', qq{find $source_dir -iname "*.jpg" | sort}); +while(<$find>) { + chomp; + my $path = $_; + warn "# path $path\n"; + s{^\Q$source_dir\E/*}{}; + my $student = $1 if s{^(.+?)/}{}; + $student =~ s/^(\d+).*/$1/; + my $lokacija = $1 if s{^(.+?)/}{}; + + my $inventarni_broj = $_; + $inventarni_broj =~ s/\.jpg$//i; + + if ( $inventarni_broj =~ m/\s*-\s*([a-k])\s*$/i ) { + warn "# $biblionumber dio $1\n"; + } else { + my $record = MARC::Record->new; + $record->add_fields( + [ 245, " ", " ", a => $inventarni_broj ], + [ 952, " ", " ", t => $inventarni_broj ], + ); + + my $biblioitemnumber; + ($biblionumber,$biblioitemnumber) = AddBiblio($record,$frameworkcode); + warn "# AddBiblio $biblionumber $biblioitemnumber [$inventarni_broj]\n"; + + my ($biblionumber, $biblioitemnumber, $itemnumber) + = AddItemFromMarc($record, $biblionumber); + + warn "# AddItemFromMarc $biblionumber $biblioitemnumber $itemnumber\n"; + + } + + my $image = GD::Image->new($path); + PutImage($biblionumber, $image, $replace); + + print dump( $biblionumber, $student, $lokacija, $inventarni_broj ),$/; +} +