line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::RottenTomatoes; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
54937
|
use URI::Escape; |
|
1
|
|
|
|
|
1776
|
|
|
1
|
|
|
|
|
88
|
|
4
|
1
|
|
|
1
|
|
11
|
use Carp qw{croak}; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
55
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use base qw{REST::Client}; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
1122
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 0.03; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
0
|
|
|
0
|
1
|
|
my ( $class, %args ) = @_; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new( |
14
|
|
|
|
|
|
|
host => 'http://api.rottentomatoes.com/api/public/v1.0' |
15
|
|
|
|
|
|
|
); |
16
|
0
|
|
|
|
|
|
$self->getUseragent()->agent("perl-WWW-RottenTomatoes/$VERSION"); |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
bless $self, $class; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# pass params to object |
21
|
0
|
|
|
|
|
|
for my $key ( keys %args ) { |
22
|
0
|
|
|
|
|
|
$self->{$key} = $args{$key}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$self->{params} = '.json?apikey=' . $self->{api_key}; |
26
|
0
|
0
|
|
|
|
|
if ( $self->{pretty_print} eq 'true') { |
27
|
0
|
|
|
|
|
|
$self->{params} .= '&_prettyprint=' . $self->{pretty_print}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub movies_search { |
34
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if ( !$args{query} ) { |
37
|
0
|
|
|
|
|
|
croak 'movie_search method requires a "query" parameter'; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if ( $args{query} ) { |
41
|
0
|
|
|
|
|
|
$self->{params} .= '&q=' . uri_escape( $args{query} ); |
42
|
|
|
|
|
|
|
} |
43
|
0
|
0
|
|
|
|
|
if ( $args{page} ) { |
44
|
0
|
|
|
|
|
|
$self->{params} .= '&page=' . $args{page}; |
45
|
|
|
|
|
|
|
} |
46
|
0
|
0
|
|
|
|
|
if ( $args{page_limit} ) { |
47
|
0
|
|
|
|
|
|
$self->{params} .= '&page_limit=' . $args{page_limit}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$self->GET( '/movies' . $self->{params} ); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $self->responseContent; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub lists_directory { |
56
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$self->GET( '/lists' . $self->{params} ); |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return $self->responseContent; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub movie_lists_directory { |
64
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$self->GET( '/lists/movies' . $self->{params} ); |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return $self->responseContent; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub dvd_lists_directory { |
72
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$self->GET( '/lists/dvds' . $self->{params} ); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return $self->responseContent; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub opening_movies { |
80
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
if ( $args{limit} ) { |
83
|
0
|
|
|
|
|
|
$self->{params} .= '&limit=' . $args{limit}; |
84
|
|
|
|
|
|
|
} |
85
|
0
|
0
|
|
|
|
|
if ( $args{country} ) { |
86
|
0
|
|
|
|
|
|
$self->{params} .= '&country=' . $args{country}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$self->GET( '/lists/movies/opening' . $self->{params} ); |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
return $self->responseContent; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub upcoming_movies { |
95
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
if ( $args{country} ) { |
98
|
0
|
|
|
|
|
|
$self->{params} .= '&country=' . $args{country}; |
99
|
|
|
|
|
|
|
} |
100
|
0
|
0
|
|
|
|
|
if ( $args{page} ) { |
101
|
0
|
|
|
|
|
|
$self->{params} .= '&page=' . $args{page}; |
102
|
|
|
|
|
|
|
} |
103
|
0
|
0
|
|
|
|
|
if ( $args{page_limit} ) { |
104
|
0
|
|
|
|
|
|
$self->{params} .= '&page_limit=' . $args{page_limit}; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
$self->GET( '/lists/movies/upcoming' . $self->{params} ); |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
return $self->responseContent; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub new_release_dvds { |
113
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
114
|
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
|
if ( $args{country} ) { |
116
|
0
|
|
|
|
|
|
$self->{params} .= '&country=' . $args{country}; |
117
|
|
|
|
|
|
|
} |
118
|
0
|
0
|
|
|
|
|
if ( $args{page} ) { |
119
|
0
|
|
|
|
|
|
$self->{params} .= '&page=' . $args{page}; |
120
|
|
|
|
|
|
|
} |
121
|
0
|
0
|
|
|
|
|
if ( $args{page_limit} ) { |
122
|
0
|
|
|
|
|
|
$self->{params} .= '&page_limit=' . $args{page_limit}; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
$self->GET( '/lists/dvds/new_releases' . $self->{params} ); |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
return $self->responseContent; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub movie_info { |
131
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
132
|
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
|
if ( !$args{movie_id} ) { |
134
|
0
|
|
|
|
|
|
croak 'movie_info method requires a "movie_id" parameter'; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
$self->GET( "/movies/$args{movie_id}" . $self->{params} ); |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
return $self->responseContent; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub movie_cast { |
143
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
144
|
|
|
|
|
|
|
|
145
|
0
|
0
|
|
|
|
|
if ( !$args{movie_id} ) { |
146
|
0
|
|
|
|
|
|
croak 'movie_cast method requires a "movie_id" parameter' |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
$self->GET( |
150
|
0
|
|
|
|
|
|
"/movies/$args{movie_id}/cast" . $self->{params} ); |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
return $self->responseContent; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub movie_reviews { |
156
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
157
|
|
|
|
|
|
|
|
158
|
0
|
0
|
|
|
|
|
if ( !$args{movie_id} ) { |
159
|
0
|
|
|
|
|
|
croak 'movie_reviews method requires a "movie_id" parameter'; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
0
|
0
|
|
|
|
|
if ( $args{review_type} ) { |
163
|
0
|
|
|
|
|
|
$self->{params} .= '&review_type=' . $args{review_type}; |
164
|
|
|
|
|
|
|
} |
165
|
0
|
0
|
|
|
|
|
if ( $args{country} ) { |
166
|
0
|
|
|
|
|
|
$self->{params} .= '&country=' . $args{country}; |
167
|
|
|
|
|
|
|
} |
168
|
0
|
0
|
|
|
|
|
if ( $args{page} ) { |
169
|
0
|
|
|
|
|
|
$self->{params} .= '&page=' . $args{page}; |
170
|
|
|
|
|
|
|
} |
171
|
0
|
0
|
|
|
|
|
if ( $args{page_limit} ) { |
172
|
0
|
|
|
|
|
|
$self->{params} .= '&page_limit=' . $args{page_limit}; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
$self->GET( "/movies/$args{movie_id}/reviews" . $self->{params} ); |
176
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
return $self->responseContent; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub movie_similar { |
181
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
182
|
|
|
|
|
|
|
|
183
|
0
|
0
|
|
|
|
|
if ( !$args{movie_id} ) { |
184
|
0
|
|
|
|
|
|
croak 'movie_similar method requires a "movie_id" parameter'; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
0
|
0
|
|
|
|
|
if ( $args{limit} ) { |
188
|
0
|
|
|
|
|
|
$self->{params} .= '&limit=' . $args{limit}; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
$self->GET( "/movies/$args{movie_id}/similar" . $self->{params} ); |
192
|
|
|
|
|
|
|
|
193
|
0
|
|
|
|
|
|
return $self->responseContent; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub in_theatre_movies { |
197
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
198
|
|
|
|
|
|
|
|
199
|
0
|
0
|
|
|
|
|
if ( $args{country} ) { |
200
|
0
|
|
|
|
|
|
$self->{params} .= '&country=' . $args{country}; |
201
|
|
|
|
|
|
|
} |
202
|
0
|
0
|
|
|
|
|
if ( $args{page} ) { |
203
|
0
|
|
|
|
|
|
$self->{params} .= '&page=' . $args{page}; |
204
|
|
|
|
|
|
|
} |
205
|
0
|
0
|
|
|
|
|
if ( $args{page_limit} ) { |
206
|
0
|
|
|
|
|
|
$self->{params} .= '&page_limit=' . $args{page_limit}; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
$self->GET( '/lists/movies/in_theaters' . $self->{params} ); |
210
|
|
|
|
|
|
|
|
211
|
0
|
|
|
|
|
|
return $self->responseContent; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub callback { |
215
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
216
|
|
|
|
|
|
|
|
217
|
0
|
0
|
|
|
|
|
if ( !$args{callback_fn} ) { |
218
|
0
|
|
|
|
|
|
croak 'callback method requires a "callback_fn" parameter'; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
0
|
|
|
|
|
|
$self->{params} .= '&callback=' . $args{callback_fn}; |
222
|
|
|
|
|
|
|
|
223
|
0
|
|
|
|
|
|
$self->GET( $self->{params} ); |
224
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
return $self->responseContent; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
1; |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
__END__ |