line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Openaura; |
2
|
1
|
|
|
1
|
|
2346
|
use JSON::XS; |
|
1
|
|
|
|
|
7185
|
|
|
1
|
|
|
|
|
76
|
|
3
|
1
|
|
|
1
|
|
764
|
use Cache::LRU; |
|
1
|
|
|
|
|
770
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
931
|
use Net::DNS::Lite; |
|
1
|
|
|
|
|
19150
|
|
|
1
|
|
|
|
|
63
|
|
5
|
1
|
|
|
1
|
|
1058
|
use Furl; |
|
1
|
|
|
|
|
21578
|
|
|
1
|
|
|
|
|
34
|
|
6
|
1
|
|
|
1
|
|
928
|
use URI; |
|
1
|
|
|
|
|
5763
|
|
|
1
|
|
|
|
|
40
|
|
7
|
1
|
|
|
1
|
|
1058
|
use URI::QueryParam; |
|
1
|
|
|
|
|
778
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
98
|
|
9
|
1
|
|
|
1
|
|
908
|
use Moo; |
|
1
|
|
|
|
|
18347
|
|
|
1
|
|
|
|
|
8
|
|
10
|
1
|
|
|
1
|
|
2919
|
use namespace::clean; |
|
1
|
|
|
|
|
14917
|
|
|
1
|
|
|
|
|
7
|
|
11
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$Net::DNS::Lite::CACHE = Cache::LRU->new( size => 512 ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'api_key' => ( |
17
|
|
|
|
|
|
|
is => 'rw', |
18
|
|
|
|
|
|
|
isa => sub { $_[0] }, |
19
|
|
|
|
|
|
|
required => 1, |
20
|
|
|
|
|
|
|
default => sub { $ENV{OPENAURA_API_KEY} }, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'http' => ( |
24
|
|
|
|
|
|
|
is => 'rw', |
25
|
|
|
|
|
|
|
required => 1, |
26
|
|
|
|
|
|
|
default => sub { |
27
|
|
|
|
|
|
|
my $http = Furl::HTTP->new( |
28
|
|
|
|
|
|
|
inet_aton => \&Net::DNS::Lite::inet_aton, |
29
|
|
|
|
|
|
|
agent => 'WebService::Openaura/' . $VERSION, |
30
|
|
|
|
|
|
|
headers => [ 'Accept-Encoding' => 'gzip',], |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
return $http; |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub classic_artists { |
38
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $param) = @_; |
39
|
0
|
|
|
|
|
|
return $self->request("classic/artists/$id", $param); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub classic_version { |
43
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
44
|
0
|
|
|
|
|
|
return $self->request("classic/version"); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub info_artists { |
48
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $param) = @_; |
49
|
0
|
|
|
|
|
|
return $self->request("info/artists/$id", $param); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub info_artists_bio { |
53
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $param) = @_; |
54
|
0
|
|
|
|
|
|
return $self->request("info/artists/$id/bio", $param); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub info_artists_cover_photo { |
58
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $param) = @_; |
59
|
0
|
|
|
|
|
|
return $self->request("info/artists/$id/cover_photo", $param); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub info_artists_fact_card { |
63
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $param) = @_; |
64
|
0
|
|
|
|
|
|
return $self->request("info/artists/$id/fact_card", $param); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub info_artists_profile_photo { |
68
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $param) = @_; |
69
|
0
|
|
|
|
|
|
return $self->request("info/artists/$id/profile_photo", $param); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub info_artists_release_art { |
73
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $param) = @_; |
74
|
0
|
|
|
|
|
|
return $self->request("info/artists/$id/release_art", $param); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub info_artists_tags { |
78
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $param) = @_; |
79
|
0
|
|
|
|
|
|
return $self->request("info/artists/$id/tags", $param); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub info_version { |
83
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
84
|
0
|
|
|
|
|
|
return $self->request("info/version"); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub particles_artists { |
88
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $param) = @_; |
89
|
0
|
|
|
|
|
|
return $self->request("particles/artists/$id", $param); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub particles_particle { |
93
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $param) = @_; |
94
|
0
|
|
|
|
|
|
return $self->request("particles/particle/$id", $param); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub particles_sources { |
98
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $param) = @_; |
99
|
0
|
|
|
|
|
|
return $self->request("particles/sources/$id", $param); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub particles_version { |
103
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
104
|
0
|
|
|
|
|
|
return $self->request("particles/version"); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub search_artists { |
108
|
0
|
|
|
0
|
1
|
|
my ($self, $param) = @_; |
109
|
0
|
|
|
|
|
|
return $self->request("search/artists", $param); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub search_artists_all { |
113
|
0
|
|
|
0
|
1
|
|
my ($self, $param) = @_; |
114
|
0
|
|
|
|
|
|
return $self->request("search/artists_all", $param); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub search_version { |
118
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
119
|
0
|
|
|
|
|
|
return $self->request("search/version"); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub source_artists { |
123
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $param) = @_; |
124
|
0
|
|
|
|
|
|
return $self->request("source/artists/$id", $param); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub source_sources { |
128
|
0
|
|
|
0
|
1
|
|
my ($self, $id, $param) = @_; |
129
|
0
|
|
|
|
|
|
return $self->request("source/sources/$id", $param); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub source_version { |
133
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
134
|
0
|
|
|
|
|
|
return $self->request("source/version"); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub request { |
139
|
0
|
|
|
0
|
0
|
|
my ( $self, $path, $query_param ) = @_; |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
my $query = URI->new; |
142
|
0
|
|
|
|
|
|
$query->query_param( 'api_key', $self->api_key ); |
143
|
0
|
|
|
|
|
|
map { $query->query_param( $_, $query_param->{$_} ) } keys %$query_param; |
|
0
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
my ($minor_version, $code, $message, $headers, $content) = |
146
|
|
|
|
|
|
|
$self->http->request( |
147
|
|
|
|
|
|
|
scheme => 'http', |
148
|
|
|
|
|
|
|
host => 'api.openaura.com', |
149
|
|
|
|
|
|
|
path_query => "v1/$path$query", |
150
|
|
|
|
|
|
|
method => 'GET', |
151
|
|
|
|
|
|
|
); |
152
|
|
|
|
|
|
|
|
153
|
0
|
0
|
|
|
|
|
if ($path =~ m|search/artists(?:_all)*|) { |
154
|
0
|
|
|
|
|
|
$content =~ s/^(\[.+\])$/{ "artists": $1 }/; |
155
|
|
|
|
|
|
|
} |
156
|
0
|
|
|
|
|
|
my $data = decode_json( $content ); |
157
|
|
|
|
|
|
|
|
158
|
0
|
0
|
|
|
|
|
if ( defined $data->{results}{error} ) { |
159
|
0
|
|
|
|
|
|
my $type = $data->{results}{error}{type}; |
160
|
0
|
|
|
|
|
|
my $message = $data->{results}{error}{message}; |
161
|
0
|
|
|
|
|
|
confess "$type: $message"; |
162
|
|
|
|
|
|
|
} else { |
163
|
0
|
|
|
|
|
|
return $data; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
1; |
169
|
|
|
|
|
|
|
__END__ |