blib/lib/TMDB/Movie.pm

filter: Statementstmt 11.1% 23 / 207 Branchbran 0.0% 0 / 88 Conditioncond 0.0% 0 / 38 MC/DCmcdc 0.0% 0 / 19 Subroutinesub 15.2% 7 / 46 Podpod 0.0% 0 / 36 totaltotal 6.9% 30 / 434 CC 71 SCAR 27.7
CC
71
Cov
7%
alternative_titles
42.0
changes
42.0
genres
30.0
CRAP 15.9
« blib/lib/TMDB/TV.pm ↑ Summary blib/lib/TMDB/Search.pm »
1 package TMDB::Movie;
2  
3 #######################
4 # LOAD CORE MODULES
5 #######################
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Carp qw(croak carp);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 #######################
11 # LOAD CPAN MODULES
12 #######################
13 1 ▶use Object::Tiny qw(id session);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Params::Validate qw(validate_with :types);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Locale::Codes::Country qw(all_country_codes);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 #######################
18 # LOAD DIST MODULES
19 #######################
20 1 ▶use TMDB::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 #######################
23 # VERSION
24 #######################
25 1 our $VERSION = '1.2.0';
26  
27 #######################
28 # PUBLIC METHODS
29 #######################
30  
31 ## ====================
32 ## Constructor
33 ## ====================
34 sub new {
35 0 ▶ my $class = shift;
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
36 0 my %opts = validate_with(
37 params => \@_,
38 spec => {
39 session => {
40 type => OBJECT,
41 isa => 'TMDB::Session',
42 },
43 id => {
44 type => SCALAR,
45 },
46 },
47 );
48  
49 0 my $self = $class->SUPER::new(%opts);
50 0 return $self;
51 } ## end sub new
52  
53 ## ====================
54 ## INFO
55 ## ====================
56 sub info {
57 0 ▶ my $self = shift;
Subroutine info: not called CC=3 SCAR=24.8
Pod undocumented
58 0 my $params = {};
59 0 ▶ $params->{language} = $self->session->lang if $self->session->lang;
Branch: 1 branch
BranchTrueFalseTotal
if $self->session->lang 0 0 0
60 0 my $info = $self->session->talk(
61 {
62 method => 'movie/' . $self->id,
63 params => $params
64 }
65 );
66 0 ▶ return unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 0 0
67 0 $self->{id} = $info->{id}; # Reset TMDB ID
68 0 return $info;
69 } ## end sub info
70  
71 ## ====================
72 ## ALTERNATIVE TITLES
73 ## ====================
74 sub alternative_titles {
75 0 ▶ my $self = shift;
Subroutine alternative_titles: not called CC=6 SCAR=37.4
Pod undocumented
76 0 my $country = shift;
77  
78 # Valid Country codes
79 0 ▶ if ($country) {
Branch: 1 branch
BranchTrueFalseTotal
if ($country) 0 0 0
80 my %valid_country_codes
81 0 = map { $_ => 1 } all_country_codes('alpha-2');
82 0 $country = uc $country;
83 0 ▶ return unless $valid_country_codes{$country};
Branch: 1 branch
BranchTrueFalseTotal
unless $valid_country_codes{$country} 0 0 0
84 } ## end if ($country)
85  
86 0 my $args = {
87 method => 'movie/' . $self->id() . '/alternative_titles',
88 params => {},
89 };
90 0 ▶ $args->{params}->{country} = $country if $country;
Branch: 1 branch
BranchTrueFalseTotal
if $country 0 0 0
91  
92 0 my $response = $self->session->talk($args);
93 0 ▶ my $titles = $response->{titles} || [];
Condition0%0/2
$response->{'titles'} || []
l!l
00
MC/DC0%0/1
$response->{'titles'} || []
$response->{'titles'}
Truth table0%0/2
A
A= $response->{'titles'}
Aresult
11
00
94  
95 0 ▶ return @$titles if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
96 0 return $titles;
97 } ## end sub alternative_titles
98  
99 ## ====================
100 ## CAST
101 ## ====================
102 sub cast {
103 0 ▶ my $self = shift;
Subroutine cast: not called CC=3 SCAR=24.8
Pod undocumented
104 0 my $response = $self->_cast();
105 0 ▶ my $cast = $response->{cast} || [];
Condition0%0/2
$response->{'cast'} || []
l!l
00
MC/DC0%0/1
$response->{'cast'} || []
$response->{'cast'}
Truth table0%0/2
A
A= $response->{'cast'}
Aresult
11
00
106 0 ▶ return @$cast if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
107 0 return $cast;
108 } ## end sub cast
109  
110 ## ====================
111 ## CREW
112 ## ====================
113 sub crew {
114 0 ▶ my $self = shift;
Subroutine crew: not called CC=3 SCAR=24.8
Pod undocumented
115 0 my $response = $self->_cast();
116 0 ▶ my $crew = $response->{crew} || [];
Condition0%0/2
$response->{'crew'} || []
l!l
00
MC/DC0%0/1
$response->{'crew'} || []
$response->{'crew'}
Truth table0%0/2
A
A= $response->{'crew'}
Aresult
11
00
117 0 ▶ return @$crew if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
118 0 return $crew;
119 } ## end sub crew
120  
121 ## ====================
122 ## IMAGES
123 ## ====================
124 sub images {
125 0 ▶ my $self = shift;
Subroutine images: not called CC=2 SCAR=17.9
Pod undocumented
126 0 my $params = {};
127 0 ▶ $params->{lang} = $self->session->lang if $self->session->lang;
Branch: 1 branch
BranchTrueFalseTotal
if $self->session->lang 0 0 0
128 0 return $self->session->talk(
129 {
130 method => 'movie/' . $self->id() . '/images',
131 params => $params
132 }
133 );
134 } ## end sub images
135  
136 ## ====================
137 ## KEYWORDS
138 ## ====================
139 sub keywords {
140 0 ▶ my $self = shift;
Subroutine keywords: not called CC=4 SCAR=30.0
Pod undocumented
141 0 my $response = $self->session->talk(
142 { method => 'movie/' . $self->id() . '/keywords' } );
143 0 ▶ my $keywords_dump = $response->{keywords} || [];
Condition0%0/2
$response->{'keywords'} || []
l!l
00
MC/DC0%0/1
$response->{'keywords'} || []
$response->{'keywords'}
Truth table0%0/2
A
A= $response->{'keywords'}
Aresult
11
00
144 0 my @keywords;
145 0 foreach (@$keywords_dump) { push @keywords, $_->{name}; }
146 0 ▶ return @keywords if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
147 0 return \@keywords;
148 } ## end sub keywords
149  
150 ## ====================
151 ## RELEASES
152 ## ====================
153 sub releases {
154 0 ▶ my $self = shift;
Subroutine releases: not called CC=3 SCAR=24.8
Pod undocumented
155 0 my $response = $self->session->talk(
156 { method => 'movie/' . $self->id() . '/releases' } );
157 0 ▶ my $countries = $response->{countries} || [];
Condition0%0/2
$response->{'countries'} || []
l!l
00
MC/DC0%0/1
$response->{'countries'} || []
$response->{'countries'}
Truth table0%0/2
A
A= $response->{'countries'}
Aresult
11
00
158 0 ▶ return @$countries if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
159 0 return $countries;
160 } ## end sub releases
161  
162 ## ====================
163 ## TRAILERS
164 ## ====================
165 sub trailers {
166 0 ▶ my $self = shift;
Subroutine trailers: not called CC=1 SCAR=6.9
Pod undocumented
167 0 return $self->session->talk(
168 { method => 'movie/' . $self->id() . '/trailers' } );
169 } ## end sub trailers
170  
171 ## ====================
172 ## TRANSLATIONS
173 ## ====================
174 sub translations {
175 0 ▶ my $self = shift;
Subroutine translations: not called CC=3 SCAR=24.8
Pod undocumented
176 0 my $response = $self->session->talk(
177 { method => 'movie/' . $self->id() . '/translations' } );
178 0 ▶ my $translations = $response->{translations} || [];
Condition0%0/2
$response->{'translations'} || []
l!l
00
MC/DC0%0/1
$response->{'translations'} || []
$response->{'translations'}
Truth table0%0/2
A
A= $response->{'translations'}
Aresult
11
00
179 0 ▶ return @$translations if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
180 0 return $translations;
181 } ## end sub translations
182  
183 ## ====================
184 ## SIMILAR MOVIES
185 ## ====================
186 sub similar {
187 0 ▶ my ( $self, $max_pages ) = @_;
Subroutine similar: not called CC=2 SCAR=17.9
Pod undocumented
188 0 ▶ return $self->session->paginate_results(
Branch: 1 branch
BranchTrueFalseTotal
$self->session->lang ? : 0 0 0
189 {
190 method => 'movie/' . $self->id() . '/similar_movies',
191 max_pages => $max_pages,
192 params => {
193 language => $self->session->lang
194 ? $self->session->lang
195 : undef,
196 },
197 }
198 );
199 } ## end sub similar
200 0 ▶sub similar_movies { return shift->similar(@_); }
Subroutine similar_movies: not called CC=1 SCAR=6.9
Pod undocumented
201  
202 ## ====================
203 ## LISTS
204 ## ====================
205 sub lists {
206 0 ▶ my ( $self, $max_pages ) = @_;
Subroutine lists: not called CC=2 SCAR=17.9
Pod undocumented
207 0 ▶ return $self->session->paginate_results(
Branch: 1 branch
BranchTrueFalseTotal
$self->session->lang ? : 0 0 0
208 {
209 method => 'movie/' . $self->id() . '/lists',
210 max_pages => $max_pages,
211 params => {
212 language => $self->session->lang
213 ? $self->session->lang
214 : undef,
215 },
216 }
217 );
218 } ## end sub lists
219  
220 ## ====================
221 ## REVIEWS
222 ## ====================
223 sub reviews {
224 0 ▶ my ( $self, $max_pages ) = @_;
Subroutine reviews: not called CC=2 SCAR=17.9
Pod undocumented
225 0 ▶ return $self->session->paginate_results(
Branch: 1 branch
BranchTrueFalseTotal
$self->session->lang ? : 0 0 0
226 {
227 method => 'movie/' . $self->id() . '/reviews',
228 max_pages => $max_pages,
229 params => {
230 language => $self->session->lang
231 ? $self->session->lang
232 : undef,
233 },
234 }
235 );
236 } ## end sub reviews
237  
238 ## ====================
239 ## CHANGES
240 ## ====================
241 sub changes {
242 0 ▶ my ( $self, @args ) = @_;
Subroutine changes: not called CC=6 SCAR=37.4
Pod undocumented
243 0 my %options = validate_with(
244 params => [@args],
245 spec => {
246 start_date => {
247 type => SCALAR,
248 optional => 1,
249 regex => qr/^\d{4}\-\d{2}\-\d{2}$/
250 },
251 end_date => {
252 type => SCALAR,
253 optional => 1,
254 regex => qr/^\d{4}\-\d{2}\-\d{2}$/
255 },
256 },
257 );
258  
259 my $changes = $self->session->talk(
260 {
261 method => 'movie/' . $self->id() . '/changes',
262 params => {
263 (
264 $options{start_date}
265 ? ( start_date => $options{start_date} )
266 : ()
267 ), (
268 $options{end_date} ? ( end_date => $options{end_date} )
269 0 ▶ : ()
Branch: 2 branches
BranchTrueFalseTotal
$options{'start_date'} ? : 0 0 0
$options{'end_date'} ? : 0 0 0
270 ),
271 },
272 }
273 );
274  
275 0 ▶ return unless defined $changes;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $changes 0 0 0
276 0 ▶ return unless exists $changes->{changes};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $changes->{"changes"} 0 0 0
277 0 ▶ return @{ $changes->{changes} } if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
278 0 return $changes->{changes};
279 } ## end sub changes
280  
281 ## ====================
282 ## VERSION
283 ## ====================
284 sub version {
285 0 ▶ my ($self) = @_;
Subroutine version: not called CC=3 SCAR=24.8
Pod undocumented
286 0 ▶ my $response = $self->session->talk(
Branch: 1 branch
BranchTrueFalseTotal
my $response = $self->session->talk({"method", 'movie/' . $self->id, "want_headers", 1}) or return 0 0 0
287 {
288 method => 'movie/' . $self->id(),
289 want_headers => 1,
290 }
291 ) or return;
292 0 ▶ my $version = $response->{etag} || q();
Condition0%0/2
$response->{'etag'} || ''
l!l
00
MC/DC0%0/1
$response->{'etag'} || ''
$response->{'etag'}
Truth table0%0/2
A
A= $response->{'etag'}
Aresult
11
00
293 0 $version =~ s{"}{}gx;
294 0 return $version;
295 } ## end sub version
296  
297 ## ====================
298 ## INFO HELPERS
299 ## ====================
300  
301 # Title
302 sub title {
303 0 ▶ my ($self) = @_;
Subroutine title: not called CC=3 SCAR=24.8
Pod undocumented
304 0 my $info = $self->info();
305 0 ▶ return unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 0 0
306 0 ▶ return $info->{title} || q();
Condition0%0/2
$info->{'title'} || ''
l!l
00
MC/DC0%0/1
$info->{'title'} || ''
$info->{'title'}
Truth table0%0/2
A
A= $info->{'title'}
Aresult
11
00
307 } ## end sub title
308  
309 # Release Year
310 sub year {
311 0 ▶ my ($self) = @_;
Subroutine year: not called CC=4 SCAR=30.0
Pod undocumented
312 0 my $info = $self->info();
313 0 ▶ return unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 0 0
314 0 ▶ my $full_date = $info->{release_date} || q();
Condition0%0/2
$info->{'release_date'} || ''
l!l
00
MC/DC0%0/1
$info->{'release_date'} || ''
$info->{'release_date'}
Truth table0%0/2
A
A= $info->{'release_date'}
Aresult
11
00
315 0 ▶ return unless $full_date;
Branch: 1 branch
BranchTrueFalseTotal
unless $full_date 0 0 0
316 0 my ($year) = split( /\-/, $full_date );
317 0 return $year;
318 } ## end sub year
319  
320 # Tagline
321 sub tagline {
322 0 ▶ my ($self) = @_;
Subroutine tagline: not called CC=3 SCAR=24.8
Pod undocumented
323 0 my $info = $self->info();
324 0 ▶ return unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 0 0
325 0 ▶ return $info->{tagline} || q();
Condition0%0/2
$info->{'tagline'} || ''
l!l
00
MC/DC0%0/1
$info->{'tagline'} || ''
$info->{'tagline'}
Truth table0%0/2
A
A= $info->{'tagline'}
Aresult
11
00
326 } ## end sub tagline
327  
328 # Overview
329 sub overview {
330 0 ▶ my ($self) = @_;
Subroutine overview: not called CC=3 SCAR=24.8
Pod undocumented
331 0 my $info = $self->info();
332 0 ▶ return unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 0 0
333 0 ▶ return $info->{overview} || q();
Condition0%0/2
$info->{'overview'} || ''
l!l
00
MC/DC0%0/1
$info->{'overview'} || ''
$info->{'overview'}
Truth table0%0/2
A
A= $info->{'overview'}
Aresult
11
00
334 } ## end sub overview
335  
336 # IMDB ID
337 sub imdb_id {
338 0 ▶ my ($self) = @_;
Subroutine imdb_id: not called CC=3 SCAR=24.8
Pod undocumented
339 0 my $info = $self->info();
340 0 ▶ return unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 0 0
341 0 ▶ return $info->{imdb_id} || q();
Condition0%0/2
$info->{'imdb_id'} || ''
l!l
00
MC/DC0%0/1
$info->{'imdb_id'} || ''
$info->{'imdb_id'}
Truth table0%0/2
A
A= $info->{'imdb_id'}
Aresult
11
00
342 } ## end sub imdb_id
343  
344 # Description
345 0 ▶sub description { return shift->overview(); }
Subroutine description: not called CC=1 SCAR=6.9
Pod undocumented
346  
347 # Collection
348 sub collection {
349 0 ▶ my ($self) = @_;
Subroutine collection: not called CC=3 SCAR=24.8
Pod undocumented
350 0 my $info = $self->info();
351 0 ▶ return unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 0 0
352 0 ▶ return $info->{belongs_to_collection}->{id} || q();
Condition0%0/2
$info->{'belongs_to_collection'}{'id'} || ''
l!l
00
MC/DC0%0/1
$info->{'belongs_to_collection'}{'id'} || ''
$info->{'belongs_to_collection'}{'id'}
Truth table0%0/2
A
A= $info->{'belongs_to_collection'}{'id'}
Aresult
11
00
353 } ## end sub collection
354  
355 # Genres
356 sub genres {
357 0 ▶ my $self = shift;
Subroutine genres: not called CC=5 SCAR=34.0
Pod undocumented
358 0 my $info = $self->info();
359 0 ▶ return unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 0 0
360 0 my @genres;
361 0 ▶ if ( exists $info->{genres} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"genres"}) 0 0 0
362 0 foreach ( @{ $info->{genres} } ) { push @genres, $_->{name}; }
363 }
364  
365 0 ▶ return @genres if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
366 0 return \@genres;
367 } ## end sub genres
368  
369 # Homepage
370 sub homepage {
371 0 ▶ my ($self) = @_;
Subroutine homepage: not called CC=3 SCAR=24.8
Pod undocumented
372 0 my $info = $self->info();
373 0 ▶ return unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 0 0
374 0 ▶ return $info->{homepage} || q();
Condition0%0/2
$info->{'homepage'} || ''
l!l
00
MC/DC0%0/1
$info->{'homepage'} || ''
$info->{'homepage'}
Truth table0%0/2
A
A= $info->{'homepage'}
Aresult
11
00
375 } ## end sub homepage
376  
377 # Studios
378 sub studios {
379 0 ▶ my $self = shift;
Subroutine studios: not called CC=5 SCAR=34.0
Pod undocumented
380 0 my $info = $self->info();
381 0 ▶ return unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 0 0
382 0 my @studios;
383 0 ▶ if ( exists $info->{production_companies} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $info->{"production_companies"}) 0 0 0
384 0 foreach ( @{ $info->{production_companies} } ) {
385 0 push @studios, $_->{name};
386 }
387 } ## end if ( exists $info->{production_companies...})
388  
389 0 ▶ return @studios if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
390 0 return \@studios;
391 } ## end sub studios
392  
393 ## ====================
394 ## CAST/CREW HELPERS
395 ## ====================
396  
397 # Actor names
398 sub actors {
399 0 ▶ my $self = shift;
Subroutine actors: not called CC=3 SCAR=24.8
Pod undocumented
400 0 my @cast = $self->cast();
401 0 my @names;
402 0 foreach (@cast) { push @names, $_->{name}; }
403 0 ▶ return @names if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
404 0 return \@names;
405 } ## end sub actors
406  
407 # Crew member names
408 0 ▶sub director { return shift->_crew_names('Director'); }
Subroutine director: not called CC=1 SCAR=6.9
Pod undocumented
409 0 ▶sub producer { return shift->_crew_names('Producer'); }
Subroutine producer: not called CC=1 SCAR=6.9
Pod undocumented
410 0 ▶sub executive_producer { return shift->_crew_names('Executive Producer'); }
Subroutine executive_producer: not called CC=1 SCAR=6.9
Pod undocumented
411 0 ▶sub writer { return shift->_crew_names('Screenplay|Writer|Author|Novel'); }
Subroutine writer: not called CC=1 SCAR=6.9
Pod undocumented
412  
413 ## ====================
414 ## IMAGE HELPERS
415 ## ====================
416  
417 # Poster
418 sub poster {
419 0 ▶ my $self = shift;
Subroutine poster: not called CC=3 SCAR=24.8
Pod undocumented
420 0 my $info = $self->info();
421 0 ▶ return unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 0 0
422 0 ▶ return $info->{poster_path} || q();
Condition0%0/2
$info->{'poster_path'} || ''
l!l
00
MC/DC0%0/1
$info->{'poster_path'} || ''
$info->{'poster_path'}
Truth table0%0/2
A
A= $info->{'poster_path'}
Aresult
11
00
423 } ## end sub poster
424  
425 # Posters
426 sub posters {
427 0 ▶ my $self = shift;
Subroutine posters: not called CC=3 SCAR=24.8
Pod undocumented
428 0 my $response = $self->images();
429 0 ▶ return unless $response;
Branch: 1 branch
BranchTrueFalseTotal
unless $response 0 0 0
430 0 ▶ my $posters = $response->{posters} || [];
Condition0%0/2
$response->{'posters'} || []
l!l
00
MC/DC0%0/1
$response->{'posters'} || []
$response->{'posters'}
Truth table0%0/2
A
A= $response->{'posters'}
Aresult
11
00
431 0 return $self->_image_urls($posters);
432 } ## end sub posters
433  
434 # Backdrop
435 sub backdrop {
436 0 ▶ my $self = shift;
Subroutine backdrop: not called CC=3 SCAR=24.8
Pod undocumented
437 0 my $info = $self->info();
438 0 ▶ return unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 0 0
439 0 ▶ return $info->{backdrop_path} || q();
Condition0%0/2
$info->{'backdrop_path'} || ''
l!l
00
MC/DC0%0/1
$info->{'backdrop_path'} || ''
$info->{'backdrop_path'}
Truth table0%0/2
A
A= $info->{'backdrop_path'}
Aresult
11
00
440 } ## end sub backdrop
441  
442 # Backdrops
443 sub backdrops {
444 0 ▶ my $self = shift;
Subroutine backdrops: not called CC=3 SCAR=24.8
Pod undocumented
445 0 my $response = $self->images();
446 0 ▶ return unless $response;
Branch: 1 branch
BranchTrueFalseTotal
unless $response 0 0 0
447 0 ▶ my $backdrops = $response->{backdrops} || [];
Condition0%0/2
$response->{'backdrops'} || []
l!l
00
MC/DC0%0/1
$response->{'backdrops'} || []
$response->{'backdrops'}
Truth table0%0/2
A
A= $response->{'backdrops'}
Aresult
11
00
448 0 return $self->_image_urls($backdrops);
449 } ## end sub backdrops
450  
451 ## ====================
452 ## TRAILER HELPERS
453 ## ====================
454 sub trailers_youtube {
455 0 ▶ my $self = shift;
Subroutine trailers_youtube: not called CC=4 SCAR=30.0
Pod undocumented
456 0 my $trailers = $self->trailers();
457 0 my @urls;
458 0 ▶ my $yt_tmp = $trailers->{youtube} || [];
Condition0%0/2
$trailers->{'youtube'} || []
l!l
00
MC/DC0%0/1
$trailers->{'youtube'} || []
$trailers->{'youtube'}
Truth table0%0/2
A
A= $trailers->{'youtube'}
Aresult
11
00
459 0 foreach (@$yt_tmp) {
460 0 push @urls, 'http://youtu.be/' . $_->{source};
461 }
462 0 ▶ return @urls if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
463 0 return \@urls;
464 } ## end sub trailers_youtube
465  
466 #######################
467 # PRIVATE METHODS
468 #######################
469  
470 ## ====================
471 ## CAST
472 ## ====================
473 sub _cast {
474 0 ▶ my $self = shift;
Subroutine _cast: not called CC=1 SCAR=6.9
475 0 return $self->session->talk(
476 {
477 method => 'movie/' . $self->id() . '/casts',
478 }
479 );
480 } ## end sub _cast
481  
482 ## ====================
483 ## CREW NAMES
484 ## ====================
485 sub _crew_names {
486 0 ▶ my $self = shift;
Subroutine _crew_names: not called CC=4 SCAR=30.0
487 0 my $job = shift;
488  
489 0 my @names;
490 0 my @crew = $self->crew();
491 0 foreach (@crew) {
492 0 ▶ push @names, $_->{name} if ( $_->{job} =~ m{$job}xi );
Branch: 1 branch
BranchTrueFalseTotal
if $_->{"job"} =~ /$job/xi 0 0 0
493 }
494  
495 0 ▶ return @names if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
496 0 return \@names;
497 } ## end sub _crew_names
498  
499 ## ====================
500 ## IMAGE URLS
501 ## ====================
502 sub _image_urls {
503 0 ▶ my $self = shift;
Subroutine _image_urls: not called CC=3 SCAR=24.8
504 0 my $images = shift;
505 0 my @urls;
506 0 foreach (@$images) {
507 0 push @urls, $_->{file_path};
508 }
509 0 ▶ return @urls if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
510 0 return \@urls;
511 } ## end sub _image_urls
512  
513 #######################
514 1 1;
« blib/lib/TMDB/TV.pm ↑ Summary blib/lib/TMDB/Search.pm »