line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::OCLC::xID; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
2396
|
use LWP::Simple; |
|
5
|
|
|
|
|
283791
|
|
|
5
|
|
|
|
|
54
|
|
4
|
5
|
|
|
5
|
|
2020
|
use URI::Escape; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
346
|
|
5
|
5
|
|
|
5
|
|
647
|
use JSON; |
|
5
|
|
|
|
|
4281
|
|
|
5
|
|
|
|
|
42
|
|
6
|
5
|
|
|
5
|
|
1195
|
use Data::Dumper; |
|
5
|
|
|
|
|
5041
|
|
|
5
|
|
|
|
|
1164
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub query { |
9
|
13
|
|
|
13
|
0
|
9691
|
my $query = shift; |
10
|
13
|
|
|
|
|
42
|
my $type = shift; |
11
|
13
|
|
|
|
|
24
|
my $method = shift; |
12
|
|
|
|
|
|
|
|
13
|
13
|
50
|
33
|
|
|
158
|
die "usage: query(query,type,method)" unless defined $query && |
|
|
|
33
|
|
|
|
|
14
|
|
|
|
|
|
|
defined $type && |
15
|
|
|
|
|
|
|
defined $method; |
16
|
13
|
|
|
|
|
21
|
my $endpoint; |
17
|
|
|
|
|
|
|
|
18
|
13
|
100
|
|
|
|
60
|
if ($type eq 'xisbn') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
19
|
6
|
|
|
|
|
14
|
$endpoint = 'http://xisbn.worldcat.org/webservices/xid/isbn'; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
elsif ($type eq 'xissn') { |
22
|
4
|
|
|
|
|
8
|
$endpoint = 'http://xisbn.worldcat.org/webservices/xid/issn'; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
elsif ($type eq 'xstandardNumber') { |
25
|
3
|
|
|
|
|
5
|
$endpoint = 'http://xisbn.worldcat.org/webservices/xid/oclcnum'; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
0
|
|
|
|
|
0
|
$endpoint = 'http://xisbn.worldcat.org/webservices/xid/isbn'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
13
|
|
|
|
|
78
|
my $request = sprintf "%s/%s?method=%s&format=json&fl=*" |
32
|
|
|
|
|
|
|
, $endpoint |
33
|
|
|
|
|
|
|
, uri_escape($query) |
34
|
|
|
|
|
|
|
, $method; |
35
|
|
|
|
|
|
|
|
36
|
13
|
|
|
|
|
376
|
my $response = get($request); |
37
|
13
|
|
|
|
|
4321518
|
my $json = JSON->new->utf8(0); |
38
|
|
|
|
|
|
|
|
39
|
13
|
|
|
|
|
29
|
my $perl; |
40
|
13
|
|
|
|
|
31
|
eval { |
41
|
13
|
|
|
|
|
682
|
$perl = $json->decode($response); |
42
|
|
|
|
|
|
|
}; |
43
|
13
|
50
|
|
|
|
90
|
if ($@) { |
44
|
0
|
|
|
|
|
0
|
$perl = { error => $@ }; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
13
|
|
|
|
|
714
|
$perl; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |