line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::OCLC::VIAFAuthorityCluster; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
507
|
use REST::Client; |
|
1
|
|
|
|
|
6801
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
14
|
use URI::Escape; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
85
|
|
5
|
1
|
|
|
1
|
|
7
|
use JSON; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
6
|
1
|
|
|
1
|
|
176
|
use Catmandu; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
7
|
1
|
|
|
1
|
|
254
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
355
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $MARC_HEADER = qq||; |
10
|
|
|
|
|
|
|
our $MARC_FOOTER = qq||; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub read { |
13
|
1
|
|
|
1
|
0
|
1
|
my $identifier = shift; |
14
|
1
|
|
|
|
|
23
|
my $client = REST::Client->new(host => 'http://www.viaf.org'); |
15
|
1
|
|
|
|
|
1465
|
my $path = sprintf "/viaf/%s/marc21.xml", $identifier; |
16
|
1
|
|
|
|
|
34
|
my $res = $client->GET($path); |
17
|
|
|
|
|
|
|
|
18
|
1
|
50
|
|
|
|
1307146
|
return undef unless $res->responseCode eq '200'; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
29
|
my $content = $MARC_HEADER . $res->responseContent . $MARC_FOOTER; |
21
|
1
|
|
|
|
|
1338
|
$content =~ s{mx:}{marc:}g; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
4
|
my $fh; |
24
|
1
|
|
|
1
|
|
13
|
open($fh, '<', \$content); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
58
|
|
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
1141
|
my $importer = Catmandu->importer(MARC, type=>'XML' , fh => $fh); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $record = $importer->first; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
close($fh); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
delete $record->{_id}; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
return $record; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |