Koha-Contrib-Tamil
view release on metacpan or search on metacpan
bin/koha-coce-url view on Meta::CPAN
#!/usr/bin/perl
# PODNAME: koha-coce-url
# ABSTRACT: Generate a JSON structure of Cover url via Coce
use Modern::Perl;
use utf8;
use Pod::Usage;
use Koha::Contrib::Tamil::Koha;
use C4::Context;
use C4::Biblio;
use MARC::Moose::Record;
use YAML;
use LWP;
use LWP::UserAgent;
use JSON;
use Business::ISBN;
use Koha::Biblios;
binmode(STDOUT, ":encoding(utf8)");
sub usage {
pod2usage( -verbose => 2 );
exit;
}
sub create_json_data {
my ($query, $coce) = @_;
#$size = "_SL" . $size . "_";
my @bibs =
map { $_->[0] }
@{C4::Context->dbh->selectall_arrayref($query)};
my $is_unimarc = C4::Context->preference('marcflavour') eq 'UNIMARC';
my $tag = {
isbn => $is_unimarc ? '010' : '020',
title => $is_unimarc ? '200' : '245',
};
my $koha = Koha::Contrib::Tamil::Koha->new();
my %record_per_isbn;
my @ret;
for my $biblionumber (@bibs) {
my $biblio = Koha::Biblios->find( $biblionumber );
if ($biblio->cover_images->count) {
# Image locale
push @ret, [
$biblionumber,
$biblio->title,
"/cgi-bin/koha/opac-image.pl?biblionumber=$biblionumber"
];
}
else {
# Chercher chez Amazon
my $record = MARC::Moose::Record::new_from($biblio->metadata->record(), 'Legacy');
my $field = $record->field($tag->{isbn});
next unless $field;
my $isbn = $field->subfield('a');
( run in 2.376 seconds using v1.01-cache-2.11-cpan-a49fcb8fa48 )