| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::Kramerius::To::Images; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 2 |  |  | 2 |  | 81549 | use strict; | 
|  | 2 |  |  |  |  | 11 |  | 
|  | 2 |  |  |  |  | 60 |  | 
| 4 | 2 |  |  | 2 |  | 13 | use warnings; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 50 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 2 |  |  | 2 |  | 1160 | use App::Kramerius::V4; | 
|  | 2 |  |  |  |  | 194311 |  | 
|  | 2 |  |  |  |  | 78 |  | 
| 7 | 2 |  |  | 2 |  | 19 | use Class::Utils qw(set_params); | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 2 |  |  |  |  | 110 |  | 
| 8 | 2 |  |  | 2 |  | 11 | use Data::Kramerius; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 44 |  | 
| 9 | 2 |  |  | 2 |  | 10 | use English; | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 2 |  |  |  |  | 17 |  | 
| 10 | 2 |  |  | 2 |  | 1077 | use Error::Pure qw(err); | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 2 |  |  |  |  | 100 |  | 
| 11 | 2 |  |  | 2 |  | 14 | use Getopt::Std; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 101 |  | 
| 12 | 2 |  |  | 2 |  | 14 | use HTTP::Request; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 89 |  | 
| 13 | 2 |  |  | 2 |  | 17 | use IO::Barf qw(barf); | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 94 |  | 
| 14 | 2 |  |  | 2 |  | 12 | use JSON::XS; | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 2 |  |  |  |  | 133 |  | 
| 15 | 2 |  |  | 2 |  | 13 | use LWP::UserAgent; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 60 |  | 
| 16 | 2 |  |  | 2 |  | 1048 | use METS::Files; | 
|  | 2 |  |  |  |  | 23088 |  | 
|  | 2 |  |  |  |  | 70 |  | 
| 17 | 2 |  |  | 2 |  | 1026 | use Perl6::Slurp qw(slurp); | 
|  | 2 |  |  |  |  | 3125 |  | 
|  | 2 |  |  |  |  | 15 |  | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | our $VERSION = 0.02; | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | # Constructor. | 
| 22 |  |  |  |  |  |  | sub new { | 
| 23 | 0 |  |  | 0 | 1 |  | my ($class, @params) = @_; | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | # Create object. | 
| 26 | 0 |  |  |  |  |  | my $self = bless {}, $class; | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | # LWP::UserAgent object. | 
| 29 | 0 |  |  |  |  |  | $self->{'lwp_user_agent'} = undef; | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | # Process parameters. | 
| 32 | 0 |  |  |  |  |  | set_params($self, @params); | 
| 33 |  |  |  |  |  |  |  | 
| 34 | 0 |  |  |  |  |  | $self->{'_kramerius'} = Data::Kramerius->new; | 
| 35 |  |  |  |  |  |  |  | 
| 36 | 0 | 0 |  |  |  |  | if (defined $self->{'lwp_user_agent'}) { | 
| 37 | 0 | 0 |  |  |  |  | if (! $self->{'lwp_user_agent'}->isa('LWP::UserAgent')) { | 
| 38 | 0 |  |  |  |  |  | err "Parameter 'lwp_user_agent' must be a LWP::UserAgent object."; | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  | } else { | 
| 41 | 0 |  |  |  |  |  | $self->{'lwp_user_agent'} = LWP::UserAgent->new; | 
| 42 | 0 |  |  |  |  |  | $self->{'lwp_user_agent'}->agent('kramerius2images/'.$VERSION); | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | # Object. | 
| 46 | 0 |  |  |  |  |  | return $self; | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | # Run. | 
| 50 |  |  |  |  |  |  | sub run { | 
| 51 | 0 |  |  | 0 | 1 |  | my $self = shift; | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | # Process arguments. | 
| 54 | 0 |  |  |  |  |  | $self->{'_opts'} = { | 
| 55 |  |  |  |  |  |  | 'h' => 0, | 
| 56 |  |  |  |  |  |  | 'q' => 0, | 
| 57 |  |  |  |  |  |  | 'v' => 0, | 
| 58 |  |  |  |  |  |  | }; | 
| 59 | 0 | 0 | 0 |  |  |  | if (! getopts('hqv', $self->{'_opts'}) || (! -r 'ROOT' && @ARGV < 2) | 
|  |  |  | 0 |  |  |  |  | 
|  |  |  | 0 |  |  |  |  | 
| 60 |  |  |  |  |  |  | || $self->{'_opts'}->{'h'}) { | 
| 61 |  |  |  |  |  |  |  | 
| 62 | 0 |  |  |  |  |  | print STDERR "Usage: $0 [-h] [-q] [-v] [--version] [kramerius_id object_id]\n"; | 
| 63 | 0 |  |  |  |  |  | print STDERR "\t-h\t\tHelp.\n"; | 
| 64 | 0 |  |  |  |  |  | print STDERR "\t-q\t\tQuiet mode.\n"; | 
| 65 | 0 |  |  |  |  |  | print STDERR "\t-v\t\tVerbose mode.\n"; | 
| 66 | 0 |  |  |  |  |  | print STDERR "\t--version\tPrint version.\n"; | 
| 67 | 0 |  |  |  |  |  | print STDERR "\tkramerius_id\tKramerius system id. e.g. ". | 
| 68 |  |  |  |  |  |  | "mzk\n"; | 
| 69 | 0 |  |  |  |  |  | print STDERR "\tobject_id\tKramerius object id (could be ". | 
| 70 |  |  |  |  |  |  | "page, series or book edition).\n"; | 
| 71 | 0 |  |  |  |  |  | return 1; | 
| 72 |  |  |  |  |  |  | } | 
| 73 | 0 |  |  |  |  |  | my ($kramerius_id, $object_id); | 
| 74 | 0 | 0 |  |  |  |  | if (@ARGV > 1) { | 
|  |  | 0 |  |  |  |  |  | 
| 75 | 0 |  |  |  |  |  | $kramerius_id = shift @ARGV; | 
| 76 | 0 |  |  |  |  |  | $object_id = shift @ARGV; | 
| 77 |  |  |  |  |  |  | } elsif (-r 'ROOT') { | 
| 78 | 0 |  |  |  |  |  | ($kramerius_id, $object_id) = slurp('ROOT', { chomp => 1 }); | 
| 79 |  |  |  |  |  |  | } else { | 
| 80 | 0 |  |  |  |  |  | err 'Cannot read library id and work id.'; | 
| 81 |  |  |  |  |  |  | } | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 0 |  |  |  |  |  | $self->{'_kramerius_obj'} = $self->{'_kramerius'}->get($kramerius_id); | 
| 84 | 0 | 0 |  |  |  |  | if (! defined $self->{'_kramerius_obj'}) { | 
| 85 | 0 |  |  |  |  |  | err "Library with ID '$self->{'_kramerius_id'}' is unknown."; | 
| 86 |  |  |  |  |  |  | } | 
| 87 | 0 |  |  |  |  |  | barf('ROOT', <<"END"); | 
| 88 |  |  |  |  |  |  | $kramerius_id | 
| 89 |  |  |  |  |  |  | $object_id | 
| 90 |  |  |  |  |  |  | END | 
| 91 |  |  |  |  |  |  |  | 
| 92 | 0 |  |  |  |  |  | my $quiet = '-q '; | 
| 93 | 0 | 0 |  |  |  |  | if ($self->{'_opts'}->{'v'}) { | 
| 94 | 0 |  |  |  |  |  | $quiet = ''; | 
| 95 |  |  |  |  |  |  | } | 
| 96 |  |  |  |  |  |  |  | 
| 97 | 0 |  |  |  |  |  | my @pages; | 
| 98 | 0 | 0 |  |  |  |  | if ($self->{'_kramerius_obj'}->version == 3) { | 
|  |  | 0 |  |  |  |  |  | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | # URI for METS. | 
| 101 | 0 |  |  |  |  |  | my $mets_uri = $self->{'_kramerius_obj'}->url.'kramerius/mets/'.$kramerius_id. | 
| 102 |  |  |  |  |  |  | '/'.$object_id; | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | # Get METS. | 
| 105 | 0 | 0 |  |  |  |  | if ($self->{'_opts'}->{'v'}) { | 
| 106 | 0 |  |  |  |  |  | print "Downloads $mets_uri\n"; | 
| 107 |  |  |  |  |  |  | } | 
| 108 | 0 |  |  |  |  |  | my $req = HTTP::Request->new('GET' => $mets_uri); | 
| 109 | 0 |  |  |  |  |  | my $res = $self->{'lwp_user_agent'}->request($req); | 
| 110 | 0 |  |  |  |  |  | my $mets; | 
| 111 | 0 | 0 |  |  |  |  | if ($res->is_success) { | 
| 112 | 0 |  |  |  |  |  | $mets = $res->content; | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | # Get images from METS file. | 
| 115 | 0 |  |  |  |  |  | my $obj = METS::Files->new( | 
| 116 |  |  |  |  |  |  | 'mets_data' => $mets, | 
| 117 |  |  |  |  |  |  | ); | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | # Get 'img' files. | 
| 120 | 0 |  |  |  |  |  | my @page_uris = $obj->get_use_files('img'); | 
| 121 |  |  |  |  |  |  |  | 
| 122 | 0 | 0 |  |  |  |  | if (! @page_uris) { | 
| 123 | 0 |  |  |  |  |  | err 'No images to download.'; | 
| 124 |  |  |  |  |  |  | } | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | # Get images. | 
| 127 | 0 |  |  |  |  |  | foreach my $page (@page_uris) { | 
| 128 | 0 |  |  |  |  |  | my $uri = URI->new($page); | 
| 129 | 0 |  |  |  |  |  | my @path_segments = $uri->path_segments; | 
| 130 | 0 | 0 |  |  |  |  | if (! -r $path_segments[-1]) { | 
| 131 | 0 | 0 |  |  |  |  | if (! $self->{'_opts'}->{'q'}) { | 
| 132 | 0 |  |  |  |  |  | print "$page\n"; | 
| 133 |  |  |  |  |  |  | } | 
| 134 | 0 |  |  |  |  |  | $self->_download($page, $path_segments[-1]); | 
| 135 |  |  |  |  |  |  | } | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | # Strip URI part. | 
| 138 | 0 |  |  |  |  |  | push @pages, $path_segments[-1]; | 
| 139 |  |  |  |  |  |  | } | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | # Direct file. | 
| 142 |  |  |  |  |  |  | } else { | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | # TODO Stahnout primo soubor. Udelat na to skript. | 
| 145 | 0 |  |  |  |  |  | err "Cannot get '$mets_uri' URI.", | 
| 146 |  |  |  |  |  |  | 'HTTP code', $res->code, | 
| 147 |  |  |  |  |  |  | 'Message', $res->message; | 
| 148 |  |  |  |  |  |  | } | 
| 149 |  |  |  |  |  |  |  | 
| 150 |  |  |  |  |  |  | } elsif ($self->{'_kramerius_obj'}->version == 4) { | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  | # URI for children JSON. | 
| 153 | 0 |  |  |  |  |  | my $json_uri = $self->{'_kramerius_obj'}->url.'search/api/v5.0/item/uuid:'. | 
| 154 |  |  |  |  |  |  | $object_id.'/children'; | 
| 155 |  |  |  |  |  |  |  | 
| 156 |  |  |  |  |  |  | # Get JSON. | 
| 157 | 0 |  |  |  |  |  | my $req = HTTP::Request->new('GET' => $json_uri); | 
| 158 | 0 |  |  |  |  |  | my $res = $self->{'lwp_user_agent'}->request($req); | 
| 159 | 0 |  |  |  |  |  | my $json; | 
| 160 | 0 | 0 |  |  |  |  | if ($res->is_success) { | 
| 161 | 0 |  |  |  |  |  | $json = $res->content; | 
| 162 | 0 |  |  |  |  |  | barf($object_id.'.json', $json); | 
| 163 |  |  |  |  |  |  | } else { | 
| 164 | 0 |  |  |  |  |  | err "Cannot get '$json_uri' URI.", | 
| 165 |  |  |  |  |  |  | 'HTTP code', $res->code, | 
| 166 |  |  |  |  |  |  | 'message', $res->message; | 
| 167 |  |  |  |  |  |  | } | 
| 168 |  |  |  |  |  |  |  | 
| 169 |  |  |  |  |  |  | # Check JSON content type. | 
| 170 | 0 | 0 |  |  |  |  | if ($res->headers->content_type ne 'application/json') { | 
| 171 | 0 |  |  |  |  |  | err "Content type isn't 'application/json' for '$json_uri' URI.", | 
| 172 |  |  |  |  |  |  | 'Content-Type', $res->headers->content_type; | 
| 173 |  |  |  |  |  |  | } | 
| 174 |  |  |  |  |  |  |  | 
| 175 |  |  |  |  |  |  | # Get perl structure. | 
| 176 | 0 |  |  |  |  |  | my $json_ar = eval { | 
| 177 | 0 |  |  |  |  |  | JSON::XS->new->decode($json); | 
| 178 |  |  |  |  |  |  | }; | 
| 179 | 0 | 0 |  |  |  |  | if ($EVAL_ERROR) { | 
| 180 | 0 |  |  |  |  |  | err "Cannot parse JSON on '$json_uri' URI.", | 
| 181 |  |  |  |  |  |  | 'JSON decode error', $EVAL_ERROR; | 
| 182 |  |  |  |  |  |  | } | 
| 183 |  |  |  |  |  |  |  | 
| 184 |  |  |  |  |  |  | # Each page. | 
| 185 | 0 |  |  |  |  |  | my $images = 0; | 
| 186 | 0 |  |  |  |  |  | foreach my $page_hr (@{$json_ar}) { | 
|  | 0 |  |  |  |  |  |  | 
| 187 | 0 | 0 |  |  |  |  | if ($page_hr->{'model'} ne 'page') { | 
| 188 | 0 |  |  |  |  |  | next; | 
| 189 |  |  |  |  |  |  | } | 
| 190 | 0 |  |  |  |  |  | my $title = $self->_get_page_title($page_hr); | 
| 191 | 0 |  |  |  |  |  | my $pid = $page_hr->{'pid'}; | 
| 192 | 0 |  |  |  |  |  | $pid =~ s/^uuid://ms; | 
| 193 |  |  |  |  |  |  | # TODO Support for page number in $pid =~ uuid:__uuid__@__page_number__ (PDF and number of page in PDF) | 
| 194 | 0 | 0 |  |  |  |  | if (! $self->{'_opts'}->{'q'}) { | 
| 195 | 0 |  |  |  |  |  | print "$pid: $title\n"; | 
| 196 |  |  |  |  |  |  | } | 
| 197 |  |  |  |  |  |  | # XXX Support of jpg only | 
| 198 | 0 | 0 |  |  |  |  | if (! -r $pid.'.jpg') { | 
| 199 | 0 |  |  |  |  |  | $self->_do_command("kramerius4 $quiet $kramerius_id $pid"); | 
| 200 |  |  |  |  |  |  | } | 
| 201 | 0 |  |  |  |  |  | push @pages, $pid.'.jpg'; | 
| 202 | 0 |  |  |  |  |  | $images++; | 
| 203 |  |  |  |  |  |  | } | 
| 204 |  |  |  |  |  |  |  | 
| 205 |  |  |  |  |  |  | # One page. | 
| 206 | 0 | 0 |  |  |  |  | if ($images == 0) { | 
| 207 | 0 |  |  |  |  |  | my $pid = $object_id; | 
| 208 | 0 | 0 |  |  |  |  | if (! $self->{'_opts'}->{'q'}) { | 
| 209 | 0 |  |  |  |  |  | print "$pid: ?\n"; | 
| 210 |  |  |  |  |  |  | } | 
| 211 |  |  |  |  |  |  | # XXX Support of jpg only | 
| 212 | 0 |  |  |  |  |  | my $output_file = $pid.'.jpg'; | 
| 213 | 0 | 0 |  |  |  |  | if (! -r $output_file) { | 
| 214 | 0 |  |  |  |  |  | $self->_do_command("kramerius4 $quiet $kramerius_id $pid"); | 
| 215 |  |  |  |  |  |  | } | 
| 216 | 0 |  |  |  |  |  | push @pages, $output_file; | 
| 217 |  |  |  |  |  |  | } | 
| 218 |  |  |  |  |  |  | } else { | 
| 219 |  |  |  |  |  |  | err 'Bad version of Kramerius.', | 
| 220 | 0 |  |  |  |  |  | 'Kramerius version', $self->{'_kramerius_obj'}->version; | 
| 221 |  |  |  |  |  |  | } | 
| 222 | 0 |  |  |  |  |  | barf('LIST', join "\n", @pages); | 
| 223 |  |  |  |  |  |  |  | 
| 224 | 0 |  |  |  |  |  | return 0; | 
| 225 |  |  |  |  |  |  | } | 
| 226 |  |  |  |  |  |  |  | 
| 227 |  |  |  |  |  |  | sub _download { | 
| 228 | 0 |  |  | 0 |  |  | my ($self, $uri, $local_file) = @_; | 
| 229 |  |  |  |  |  |  |  | 
| 230 | 0 |  |  |  |  |  | $self->{'lwp_user_agent'}->get($uri, | 
| 231 |  |  |  |  |  |  | ':content_file' => $local_file, | 
| 232 |  |  |  |  |  |  | ); | 
| 233 |  |  |  |  |  |  |  | 
| 234 | 0 |  |  |  |  |  | return; | 
| 235 |  |  |  |  |  |  | } | 
| 236 |  |  |  |  |  |  |  | 
| 237 |  |  |  |  |  |  | # Get title from page. | 
| 238 |  |  |  |  |  |  | sub _get_page_title { | 
| 239 | 0 |  |  | 0 |  |  | my ($self, $page_hr) = @_; | 
| 240 |  |  |  |  |  |  |  | 
| 241 | 0 |  |  |  |  |  | my $title; | 
| 242 | 0 | 0 |  |  |  |  | if (ref $page_hr->{'title'} eq 'ARRAY') { | 
|  |  | 0 |  |  |  |  |  | 
| 243 | 0 |  |  |  |  |  | $title = $page_hr->{'title'}->[0]; | 
| 244 |  |  |  |  |  |  | } elsif (ref $page_hr->{'title'} eq '') { | 
| 245 | 0 |  |  |  |  |  | $title = $page_hr->{'title'}; | 
| 246 |  |  |  |  |  |  | } else { | 
| 247 | 0 |  |  |  |  |  | err "Cannot get title for page '$page_hr->{'pid'}.'."; | 
| 248 |  |  |  |  |  |  | } | 
| 249 | 0 |  |  |  |  |  | $title =~ s/\s+/_/msg; | 
| 250 |  |  |  |  |  |  |  | 
| 251 | 0 |  |  |  |  |  | return $title; | 
| 252 |  |  |  |  |  |  | } | 
| 253 |  |  |  |  |  |  |  | 
| 254 |  |  |  |  |  |  | sub _do_command { | 
| 255 | 0 |  |  | 0 |  |  | my ($self, $command) = @_; | 
| 256 |  |  |  |  |  |  |  | 
| 257 | 0 | 0 |  |  |  |  | if ($self->{'_opts'}->{'v'}) { | 
| 258 | 0 |  |  |  |  |  | print $command."\n"; | 
| 259 |  |  |  |  |  |  | } | 
| 260 |  |  |  |  |  |  |  | 
| 261 | 0 |  |  |  |  |  | system $command; | 
| 262 |  |  |  |  |  |  | } | 
| 263 |  |  |  |  |  |  |  | 
| 264 |  |  |  |  |  |  | 1; | 
| 265 |  |  |  |  |  |  |  | 
| 266 |  |  |  |  |  |  | =pod | 
| 267 |  |  |  |  |  |  |  | 
| 268 |  |  |  |  |  |  | =encoding utf8 | 
| 269 |  |  |  |  |  |  |  | 
| 270 |  |  |  |  |  |  | =head1 NAME | 
| 271 |  |  |  |  |  |  |  | 
| 272 |  |  |  |  |  |  | App::Kramerius::To::Images - Base class for kramerius2images script. | 
| 273 |  |  |  |  |  |  |  | 
| 274 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 275 |  |  |  |  |  |  |  | 
| 276 |  |  |  |  |  |  | use App::Kramerius::To::Images; | 
| 277 |  |  |  |  |  |  |  | 
| 278 |  |  |  |  |  |  | my $app = App::Kramerius::To::Images->new; | 
| 279 |  |  |  |  |  |  | my $exit_code = $app->run; | 
| 280 |  |  |  |  |  |  |  | 
| 281 |  |  |  |  |  |  | =head1 METHODS | 
| 282 |  |  |  |  |  |  |  | 
| 283 |  |  |  |  |  |  | =head2 C<new> | 
| 284 |  |  |  |  |  |  |  | 
| 285 |  |  |  |  |  |  | my $app = App::Kramerius::To::Images->new; | 
| 286 |  |  |  |  |  |  |  | 
| 287 |  |  |  |  |  |  | Constructor. | 
| 288 |  |  |  |  |  |  |  | 
| 289 |  |  |  |  |  |  | Returns instance of object. | 
| 290 |  |  |  |  |  |  |  | 
| 291 |  |  |  |  |  |  | =head2 C<run> | 
| 292 |  |  |  |  |  |  |  | 
| 293 |  |  |  |  |  |  | my $exit_code = $app->run; | 
| 294 |  |  |  |  |  |  |  | 
| 295 |  |  |  |  |  |  | Run. | 
| 296 |  |  |  |  |  |  |  | 
| 297 |  |  |  |  |  |  | Returns 1 for error, 0 for success. | 
| 298 |  |  |  |  |  |  |  | 
| 299 |  |  |  |  |  |  | =head1 ERRORS | 
| 300 |  |  |  |  |  |  |  | 
| 301 |  |  |  |  |  |  | new(): | 
| 302 |  |  |  |  |  |  | From Class::Utils::set_params(): | 
| 303 |  |  |  |  |  |  | Unknown parameter '%s'. | 
| 304 |  |  |  |  |  |  | Parameter 'lwp_user_agent' must be a LWP::UserAgent object. | 
| 305 |  |  |  |  |  |  |  | 
| 306 |  |  |  |  |  |  | run(): | 
| 307 |  |  |  |  |  |  | Bad version of Kramerius. | 
| 308 |  |  |  |  |  |  | Kramerius version: %s | 
| 309 |  |  |  |  |  |  | Cannot get title for page '%s'. | 
| 310 |  |  |  |  |  |  | Cannot get '%s' URI. | 
| 311 |  |  |  |  |  |  | HTTP code: %s | 
| 312 |  |  |  |  |  |  | message: %s | 
| 313 |  |  |  |  |  |  | Cannot parse JSON on '%s' URI. | 
| 314 |  |  |  |  |  |  | JSON decode error: %s | 
| 315 |  |  |  |  |  |  | Cannot read library id and work id. | 
| 316 |  |  |  |  |  |  | Content type isn't 'application/json' for '%s' URI. | 
| 317 |  |  |  |  |  |  | Content-Type: %s | 
| 318 |  |  |  |  |  |  | Library with ID '%s' is unknown. | 
| 319 |  |  |  |  |  |  | No images to download. | 
| 320 |  |  |  |  |  |  |  | 
| 321 |  |  |  |  |  |  | =head1 EXAMPLE | 
| 322 |  |  |  |  |  |  |  | 
| 323 |  |  |  |  |  |  | use strict; | 
| 324 |  |  |  |  |  |  | use warnings; | 
| 325 |  |  |  |  |  |  |  | 
| 326 |  |  |  |  |  |  | use App::Kramerius::To::Images; | 
| 327 |  |  |  |  |  |  |  | 
| 328 |  |  |  |  |  |  | # Arguments. | 
| 329 |  |  |  |  |  |  | @ARGV = ( | 
| 330 |  |  |  |  |  |  | '-h', | 
| 331 |  |  |  |  |  |  | ); | 
| 332 |  |  |  |  |  |  |  | 
| 333 |  |  |  |  |  |  | # Run. | 
| 334 |  |  |  |  |  |  | exit App::Kramerius::To::Images->new->run; | 
| 335 |  |  |  |  |  |  |  | 
| 336 |  |  |  |  |  |  | # Output like: | 
| 337 |  |  |  |  |  |  | # Usage: ./ex1.pl [-h] [-q] [-v] [--version] [kramerius_id object_id] | 
| 338 |  |  |  |  |  |  | #         -h              Help. | 
| 339 |  |  |  |  |  |  | #         -q              Quiet mode. | 
| 340 |  |  |  |  |  |  | #         -v              Verbose mode. | 
| 341 |  |  |  |  |  |  | #         --version       Print version. | 
| 342 |  |  |  |  |  |  | #         kramerius_id    Kramerius system id. e.g. mzk | 
| 343 |  |  |  |  |  |  | #         object_id       Kramerius object id (could be page, series or book edition). | 
| 344 |  |  |  |  |  |  |  | 
| 345 |  |  |  |  |  |  | =head1 DEPENDENCIES | 
| 346 |  |  |  |  |  |  |  | 
| 347 |  |  |  |  |  |  | L<App::Kramerius::V4>, | 
| 348 |  |  |  |  |  |  | L<Class::Utils>, | 
| 349 |  |  |  |  |  |  | L<Data::Kramerius>, | 
| 350 |  |  |  |  |  |  | L<English>, | 
| 351 |  |  |  |  |  |  | L<Error::Pure>, | 
| 352 |  |  |  |  |  |  | L<Getopt::Std>, | 
| 353 |  |  |  |  |  |  | L<HTTP::Request>, | 
| 354 |  |  |  |  |  |  | L<IO::Barf>, | 
| 355 |  |  |  |  |  |  | L<JSON::XS>, | 
| 356 |  |  |  |  |  |  | L<LWP::UserAgent>, | 
| 357 |  |  |  |  |  |  | L<METS::Files>, | 
| 358 |  |  |  |  |  |  | L<Perl6::Slurp>. | 
| 359 |  |  |  |  |  |  |  | 
| 360 |  |  |  |  |  |  | =head1 REPOSITORY | 
| 361 |  |  |  |  |  |  |  | 
| 362 |  |  |  |  |  |  | L<https://github.com/michal-josef-spacek/App-Kramerius-To-Images> | 
| 363 |  |  |  |  |  |  |  | 
| 364 |  |  |  |  |  |  | =head1 AUTHOR | 
| 365 |  |  |  |  |  |  |  | 
| 366 |  |  |  |  |  |  | Michal Josef Špaček L<mailto:skim@cpan.org> | 
| 367 |  |  |  |  |  |  |  | 
| 368 |  |  |  |  |  |  | L<http://skim.cz> | 
| 369 |  |  |  |  |  |  |  | 
| 370 |  |  |  |  |  |  | =head1 LICENSE AND COPYRIGHT | 
| 371 |  |  |  |  |  |  |  | 
| 372 |  |  |  |  |  |  | © 2021 Michal Josef Špaček | 
| 373 |  |  |  |  |  |  |  | 
| 374 |  |  |  |  |  |  | BSD 2-Clause License | 
| 375 |  |  |  |  |  |  |  | 
| 376 |  |  |  |  |  |  | =head1 VERSION | 
| 377 |  |  |  |  |  |  |  | 
| 378 |  |  |  |  |  |  | 0.02 | 
| 379 |  |  |  |  |  |  |  | 
| 380 |  |  |  |  |  |  | =cut |