| 1 | package TMDB::Movie; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | ####################### | ||||||||||||||
| 4 | # LOAD CORE MODULES | ||||||||||||||
| 5 | ####################### | ||||||||||||||
| 6 | 3 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 3 | ▶ | use warnings FATAL => 'all'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 3 | ▶ | use Carp qw(croak carp); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | ####################### | ||||||||||||||
| 11 | # LOAD CPAN MODULES | ||||||||||||||
| 12 | ####################### | ||||||||||||||
| 13 | 3 | ▶ | use Object::Tiny qw(id session); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | 3 | ▶ | use Params::Validate qw(validate_with :types); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 15 | 3 | ▶ | use Locale::Codes::Country qw(all_country_codes); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 16 | |||||||||||||||
| 17 | ####################### | ||||||||||||||
| 18 | # LOAD DIST MODULES | ||||||||||||||
| 19 | ####################### | ||||||||||||||
| 20 | 3 | ▶ | use TMDB::Session; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 21 | |||||||||||||||
| 22 | ####################### | ||||||||||||||
| 23 | # VERSION | ||||||||||||||
| 24 | ####################### | ||||||||||||||
| 25 | 3 | our $VERSION = '1.3.0'; | |||||||||||||
| 26 | |||||||||||||||
| 27 | ####################### | ||||||||||||||
| 28 | # PUBLIC METHODS | ||||||||||||||
| 29 | ####################### | ||||||||||||||
| 30 | |||||||||||||||
| 31 | ## ==================== | ||||||||||||||
| 32 | ## Constructor | ||||||||||||||
| 33 | ## ==================== | ||||||||||||||
| 34 | 1 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 35 | 1 | my $class = shift; | |||||||||||||
| 36 | 1 | 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 | 1 | my $self = $class->SUPER::new(%opts); | |||||||||||||
| 50 | 1 | return $self; | |||||||||||||
| 51 | } ## end sub new | ||||||||||||||
| 52 | |||||||||||||||
| 53 | ## ==================== | ||||||||||||||
| 54 | ## INFO | ||||||||||||||
| 55 | ## ==================== | ||||||||||||||
| 56 | 13 | ▶ | sub info { | ||||||||||||
|
Subroutine
info: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||
| 57 | 13 | my $self = shift; | |||||||||||||
| 58 | 13 | my $params = {}; | |||||||||||||
| 59 | 13 | ▶ | $params->{language} = $self->session->lang if $self->session->lang; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 60 | 13 | my $info = $self->session->talk( | |||||||||||||
| 61 | { | ||||||||||||||
| 62 | method => 'movie/' . $self->id, | ||||||||||||||
| 63 | params => $params | ||||||||||||||
| 64 | } | ||||||||||||||
| 65 | ); | ||||||||||||||
| 66 | 13 | ▶ | return unless $info; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 67 | 13 | $self->{id} = $info->{id}; # Reset TMDB ID | |||||||||||||
| 68 | 13 | return $info; | |||||||||||||
| 69 | } ## end sub info | ||||||||||||||
| 70 | |||||||||||||||
| 71 | ## ==================== | ||||||||||||||
| 72 | ## ALTERNATIVE TITLES | ||||||||||||||
| 73 | ## ==================== | ||||||||||||||
| 74 | 0 | ▶ | sub alternative_titles { | ||||||||||||
|
Subroutine
alternative_titles: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||||
| 76 | 0 | my $country = shift; | |||||||||||||
| 77 | |||||||||||||||
| 78 | # Valid Country codes | ||||||||||||||
| 79 | 0 | ▶ | if ($country) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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
| |||||||||||||||
| 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
| |||||||||||||||
| 91 | |||||||||||||||
| 92 | 0 | my $response = $self->session->talk($args); | |||||||||||||
| 93 | 0 | ▶ | my $titles = $response->{titles} || []; | ||||||||||||
|
Condition0%0/2
$response->{'titles'} || []
MC/DC0%0/1
$response->{'titles'} || []
$response->{'titles'}
Truth table0%0/2
A
A= $response->{'titles'}
| |||||||||||||||
| 94 | |||||||||||||||
| 95 | 0 | ▶ | return @$titles if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 96 | 0 | return $titles; | |||||||||||||
| 97 | } ## end sub alternative_titles | ||||||||||||||
| 98 | |||||||||||||||
| 99 | ## ==================== | ||||||||||||||
| 100 | ## CAST | ||||||||||||||
| 101 | ## ==================== | ||||||||||||||
| 102 | 2 | ▶ | sub cast { | ||||||||||||
|
Subroutine
cast: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||
| 103 | 2 | my $self = shift; | |||||||||||||
| 104 | 2 | my $response = $self->_cast(); | |||||||||||||
| 105 | 2 | ▶ | my $cast = $response->{cast} || []; | ||||||||||||
|
Condition50%1/2
$response->{'cast'} || []
MC/DC0%0/1
$response->{'cast'} || []
$response->{'cast'}
Truth table50%1/2
A
A= $response->{'cast'}
| |||||||||||||||
| 106 | 2 | ▶ | return @$cast if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 107 | 1 | return $cast; | |||||||||||||
| 108 | } ## end sub cast | ||||||||||||||
| 109 | |||||||||||||||
| 110 | ## ==================== | ||||||||||||||
| 111 | ## CREW | ||||||||||||||
| 112 | ## ==================== | ||||||||||||||
| 113 | 6 | ▶ | sub crew { | ||||||||||||
|
Subroutine
crew: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||
| 114 | 6 | my $self = shift; | |||||||||||||
| 115 | 6 | my $response = $self->_cast(); | |||||||||||||
| 116 | 6 | ▶ | my $crew = $response->{crew} || []; | ||||||||||||
|
Condition50%1/2
$response->{'crew'} || []
MC/DC0%0/1
$response->{'crew'} || []
$response->{'crew'}
Truth table50%1/2
A
A= $response->{'crew'}
| |||||||||||||||
| 117 | 6 | ▶ | return @$crew if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 118 | 1 | return $crew; | |||||||||||||
| 119 | } ## end sub crew | ||||||||||||||
| 120 | |||||||||||||||
| 121 | ## ==================== | ||||||||||||||
| 122 | ## IMAGES | ||||||||||||||
| 123 | ## ==================== | ||||||||||||||
| 124 | 3 | ▶ | sub images { | ||||||||||||
|
Subroutine
images: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||
| 125 | 3 | my $self = shift; | |||||||||||||
| 126 | 3 | my $params = {}; | |||||||||||||
| 127 | 3 | ▶ | $params->{lang} = $self->session->lang if $self->session->lang; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 128 | 3 | 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 | 0 | ▶ | sub keywords { | ||||||||||||
|
Subroutine
keywords: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 140 | 0 | my $self = shift; | |||||||||||||
| 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'} || []
MC/DC0%0/1
$response->{'keywords'} || []
$response->{'keywords'}
Truth table0%0/2
A
A= $response->{'keywords'}
| |||||||||||||||
| 144 | 0 | my @keywords; | |||||||||||||
| 145 | 0 | foreach (@$keywords_dump) { push @keywords, $_->{name}; } | |||||||||||||
| 146 | 0 | ▶ | return @keywords if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 147 | 0 | return \@keywords; | |||||||||||||
| 148 | } ## end sub keywords | ||||||||||||||
| 149 | |||||||||||||||
| 150 | ## ==================== | ||||||||||||||
| 151 | ## RELEASES | ||||||||||||||
| 152 | ## ==================== | ||||||||||||||
| 153 | 0 | ▶ | sub releases { | ||||||||||||
|
Subroutine
releases: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||
| 154 | 0 | my $self = shift; | |||||||||||||
| 155 | 0 | my $response = $self->session->talk( | |||||||||||||
| 156 | { method => 'movie/' . $self->id() . '/releases' } ); | ||||||||||||||
| 157 | 0 | ▶ | my $countries = $response->{countries} || []; | ||||||||||||
|
Condition0%0/2
$response->{'countries'} || []
MC/DC0%0/1
$response->{'countries'} || []
$response->{'countries'}
Truth table0%0/2
A
A= $response->{'countries'}
| |||||||||||||||
| 158 | 0 | ▶ | return @$countries if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 159 | 0 | return $countries; | |||||||||||||
| 160 | } ## end sub releases | ||||||||||||||
| 161 | |||||||||||||||
| 162 | ## ==================== | ||||||||||||||
| 163 | ## TRAILERS | ||||||||||||||
| 164 | ## ==================== | ||||||||||||||
| 165 | 2 | ▶ | sub trailers { | ||||||||||||
|
Subroutine
trailers: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 166 | 2 | my $self = shift; | |||||||||||||
| 167 | 2 | return $self->session->talk( | |||||||||||||
| 168 | { method => 'movie/' . $self->id() . '/trailers' } ); | ||||||||||||||
| 169 | } ## end sub trailers | ||||||||||||||
| 170 | |||||||||||||||
| 171 | ## ==================== | ||||||||||||||
| 172 | ## TRANSLATIONS | ||||||||||||||
| 173 | ## ==================== | ||||||||||||||
| 174 | 0 | ▶ | sub translations { | ||||||||||||
|
Subroutine
translations: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||
| 175 | 0 | my $self = shift; | |||||||||||||
| 176 | 0 | my $response = $self->session->talk( | |||||||||||||
| 177 | { method => 'movie/' . $self->id() . '/translations' } ); | ||||||||||||||
| 178 | 0 | ▶ | my $translations = $response->{translations} || []; | ||||||||||||
|
Condition0%0/2
$response->{'translations'} || []
MC/DC0%0/1
$response->{'translations'} || []
$response->{'translations'}
Truth table0%0/2
A
A= $response->{'translations'}
| |||||||||||||||
| 179 | 0 | ▶ | return @$translations if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 180 | 0 | return $translations; | |||||||||||||
| 181 | } ## end sub translations | ||||||||||||||
| 182 | |||||||||||||||
| 183 | ## ==================== | ||||||||||||||
| 184 | ## SIMILAR MOVIES | ||||||||||||||
| 185 | ## ==================== | ||||||||||||||
| 186 | 1 | ▶ | sub similar { | ||||||||||||
|
Subroutine
similar: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||
| 187 | 1 | my ( $self, $max_pages ) = @_; | |||||||||||||
| 188 | 1 | ▶ | return $self->session->paginate_results( | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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 | 1 | ▶ | sub lists { | ||||||||||||
|
Subroutine
lists: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||
| 206 | 1 | my ( $self, $max_pages ) = @_; | |||||||||||||
| 207 | 1 | ▶ | return $self->session->paginate_results( | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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 | 1 | ▶ | sub reviews { | ||||||||||||
|
Subroutine
reviews: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||
| 224 | 1 | my ( $self, $max_pages ) = @_; | |||||||||||||
| 225 | 1 | ▶ | return $self->session->paginate_results( | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 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 | 0 | ▶ | sub changes { | ||||||||||||
|
Subroutine
changes: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||
| 242 | 0 | my ( $self, @args ) = @_; | |||||||||||||
| 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
| |||||||||||||||
| 270 | ), | ||||||||||||||
| 271 | }, | ||||||||||||||
| 272 | } | ||||||||||||||
| 273 | ); | ||||||||||||||
| 274 | |||||||||||||||
| 275 | 0 | ▶ | return unless defined $changes; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 276 | 0 | ▶ | return unless exists $changes->{changes}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 277 | 0 | ▶ | return @{ $changes->{changes} } if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 278 | 0 | return $changes->{changes}; | |||||||||||||
| 279 | } ## end sub changes | ||||||||||||||
| 280 | |||||||||||||||
| 281 | ## ==================== | ||||||||||||||
| 282 | ## VERSION | ||||||||||||||
| 283 | ## ==================== | ||||||||||||||
| 284 | 1 | ▶ | sub version { | ||||||||||||
|
Subroutine
version: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||
| 285 | 1 | my ($self) = @_; | |||||||||||||
| 286 | 1 | ▶ | my $response = $self->session->talk( | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 287 | { | ||||||||||||||
| 288 | method => 'movie/' . $self->id(), | ||||||||||||||
| 289 | want_headers => 1, | ||||||||||||||
| 290 | } | ||||||||||||||
| 291 | ) or return; | ||||||||||||||
| 292 | 1 | ▶ | my $version = $response->{etag} || q(); | ||||||||||||
|
Condition50%1/2
$response->{'etag'} || ''
MC/DC0%0/1
$response->{'etag'} || ''
$response->{'etag'}
Truth table50%1/2
A
A= $response->{'etag'}
| |||||||||||||||
| 293 | 1 | $version =~ s{"}{}gx; | |||||||||||||
| 294 | 1 | return $version; | |||||||||||||
| 295 | } ## end sub version | ||||||||||||||
| 296 | |||||||||||||||
| 297 | ## ==================== | ||||||||||||||
| 298 | ## INFO HELPERS | ||||||||||||||
| 299 | ## ==================== | ||||||||||||||
| 300 | |||||||||||||||
| 301 | # Title | ||||||||||||||
| 302 | 1 | ▶ | sub title { | ||||||||||||
|
Subroutine
title: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||
| 303 | 1 | my ($self) = @_; | |||||||||||||
| 304 | 1 | my $info = $self->info(); | |||||||||||||
| 305 | 1 | ▶ | return unless $info; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 306 | 1 | ▶ | return $info->{title} || q(); | ||||||||||||
|
Condition50%1/2
$info->{'title'} || ''
MC/DC0%0/1
$info->{'title'} || ''
$info->{'title'}
Truth table50%1/2
A
A= $info->{'title'}
| |||||||||||||||
| 307 | } ## end sub title | ||||||||||||||
| 308 | |||||||||||||||
| 309 | # Release Year | ||||||||||||||
| 310 | 1 | ▶ | sub year { | ||||||||||||
|
Subroutine
year: called CC=4 SCAR=15.9
Pod
undocumented
| |||||||||||||||
| 311 | 1 | my ($self) = @_; | |||||||||||||
| 312 | 1 | my $info = $self->info(); | |||||||||||||
| 313 | 1 | ▶ | return unless $info; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 314 | 1 | ▶ | my $full_date = $info->{release_date} || q(); | ||||||||||||
|
Condition50%1/2
$info->{'release_date'} || ''
MC/DC0%0/1
$info->{'release_date'} || ''
$info->{'release_date'}
Truth table50%1/2
A
A= $info->{'release_date'}
| |||||||||||||||
| 315 | 1 | ▶ | return unless $full_date; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 316 | 0 | my ($year) = split( /\-/, $full_date ); | |||||||||||||
| 317 | 0 | return $year; | |||||||||||||
| 318 | } ## end sub year | ||||||||||||||
| 319 | |||||||||||||||
| 320 | # Tagline | ||||||||||||||
| 321 | 1 | ▶ | sub tagline { | ||||||||||||
|
Subroutine
tagline: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||
| 322 | 1 | my ($self) = @_; | |||||||||||||
| 323 | 1 | my $info = $self->info(); | |||||||||||||
| 324 | 1 | ▶ | return unless $info; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 325 | 1 | ▶ | return $info->{tagline} || q(); | ||||||||||||
|
Condition50%1/2
$info->{'tagline'} || ''
MC/DC0%0/1
$info->{'tagline'} || ''
$info->{'tagline'}
Truth table50%1/2
A
A= $info->{'tagline'}
| |||||||||||||||
| 326 | } ## end sub tagline | ||||||||||||||
| 327 | |||||||||||||||
| 328 | # Overview | ||||||||||||||
| 329 | 2 | ▶ | sub overview { | ||||||||||||
|
Subroutine
overview: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||
| 330 | 2 | my ($self) = @_; | |||||||||||||
| 331 | 2 | my $info = $self->info(); | |||||||||||||
| 332 | 2 | ▶ | return unless $info; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 333 | 2 | ▶ | return $info->{overview} || q(); | ||||||||||||
|
Condition50%1/2
$info->{'overview'} || ''
MC/DC0%0/1
$info->{'overview'} || ''
$info->{'overview'}
Truth table50%1/2
A
A= $info->{'overview'}
| |||||||||||||||
| 334 | } ## end sub overview | ||||||||||||||
| 335 | |||||||||||||||
| 336 | # IMDB ID | ||||||||||||||
| 337 | 1 | ▶ | sub imdb_id { | ||||||||||||
|
Subroutine
imdb_id: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||
| 338 | 1 | my ($self) = @_; | |||||||||||||
| 339 | 1 | my $info = $self->info(); | |||||||||||||
| 340 | 1 | ▶ | return unless $info; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 341 | 1 | ▶ | return $info->{imdb_id} || q(); | ||||||||||||
|
Condition50%1/2
$info->{'imdb_id'} || ''
MC/DC0%0/1
$info->{'imdb_id'} || ''
$info->{'imdb_id'}
Truth table50%1/2
A
A= $info->{'imdb_id'}
| |||||||||||||||
| 342 | } ## end sub imdb_id | ||||||||||||||
| 343 | |||||||||||||||
| 344 | # Description | ||||||||||||||
| 345 | 1 | ▶ | sub description { return shift->overview(); } | ||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 346 | |||||||||||||||
| 347 | # Collection | ||||||||||||||
| 348 | 1 | ▶ | sub collection { | ||||||||||||
|
Subroutine
collection: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||
| 349 | 1 | my ($self) = @_; | |||||||||||||
| 350 | 1 | my $info = $self->info(); | |||||||||||||
| 351 | 1 | ▶ | return unless $info; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 352 | 1 | ▶ | return $info->{belongs_to_collection}->{id} || q(); | ||||||||||||
|
Condition50%1/2
$info->{'belongs_to_collection'}{'id'} || ''
MC/DC0%0/1
$info->{'belongs_to_collection'}{'id'} || ''
$info->{'belongs_to_collection'}{'id'}
Truth table50%1/2
A
A= $info->{'belongs_to_collection'}{'id'}
| |||||||||||||||
| 353 | } ## end sub collection | ||||||||||||||
| 354 | |||||||||||||||
| 355 | # Genres | ||||||||||||||
| 356 | 1 | ▶ | sub genres { | ||||||||||||
|
Subroutine
genres: called CC=5 SCAR=18.4
Pod
undocumented
| |||||||||||||||
| 357 | 1 | my $self = shift; | |||||||||||||
| 358 | 1 | my $info = $self->info(); | |||||||||||||
| 359 | 1 | ▶ | return unless $info; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 360 | 1 | my @genres; | |||||||||||||
| 361 | 1 | ▶ | if ( exists $info->{genres} ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 362 | 0 | foreach ( @{ $info->{genres} } ) { push @genres, $_->{name}; } | |||||||||||||
| 363 | } | ||||||||||||||
| 364 | |||||||||||||||
| 365 | 1 | ▶ | return @genres if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 366 | 1 | return \@genres; | |||||||||||||
| 367 | } ## end sub genres | ||||||||||||||
| 368 | |||||||||||||||
| 369 | # Homepage | ||||||||||||||
| 370 | 1 | ▶ | sub homepage { | ||||||||||||
|
Subroutine
homepage: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||
| 371 | 1 | my ($self) = @_; | |||||||||||||
| 372 | 1 | my $info = $self->info(); | |||||||||||||
| 373 | 1 | ▶ | return unless $info; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 374 | 1 | ▶ | return $info->{homepage} || q(); | ||||||||||||
|
Condition50%1/2
$info->{'homepage'} || ''
MC/DC0%0/1
$info->{'homepage'} || ''
$info->{'homepage'}
Truth table50%1/2
A
A= $info->{'homepage'}
| |||||||||||||||
| 375 | } ## end sub homepage | ||||||||||||||
| 376 | |||||||||||||||
| 377 | # Studios | ||||||||||||||
| 378 | 1 | ▶ | sub studios { | ||||||||||||
|
Subroutine
studios: called CC=5 SCAR=18.4
Pod
undocumented
| |||||||||||||||
| 379 | 1 | my $self = shift; | |||||||||||||
| 380 | 1 | my $info = $self->info(); | |||||||||||||
| 381 | 1 | ▶ | return unless $info; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 382 | 1 | my @studios; | |||||||||||||
| 383 | 1 | ▶ | if ( exists $info->{production_companies} ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 384 | 0 | foreach ( @{ $info->{production_companies} } ) { | |||||||||||||
| 385 | 0 | push @studios, $_->{name}; | |||||||||||||
| 386 | } | ||||||||||||||
| 387 | } ## end if ( exists $info->{production_companies...}) | ||||||||||||||
| 388 | |||||||||||||||
| 389 | 1 | ▶ | return @studios if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 390 | 1 | return \@studios; | |||||||||||||
| 391 | } ## end sub studios | ||||||||||||||
| 392 | |||||||||||||||
| 393 | ## ==================== | ||||||||||||||
| 394 | ## CAST/CREW HELPERS | ||||||||||||||
| 395 | ## ==================== | ||||||||||||||
| 396 | |||||||||||||||
| 397 | # Actor names | ||||||||||||||
| 398 | 1 | ▶ | sub actors { | ||||||||||||
|
Subroutine
actors: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||
| 399 | 1 | my $self = shift; | |||||||||||||
| 400 | 1 | my @cast = $self->cast(); | |||||||||||||
| 401 | 1 | my @names; | |||||||||||||
| 402 | 0 | foreach (@cast) { push @names, $_->{name}; } | |||||||||||||
| 403 | 1 | ▶ | return @names if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 404 | 1 | return \@names; | |||||||||||||
| 405 | } ## end sub actors | ||||||||||||||
| 406 | |||||||||||||||
| 407 | # Crew member names | ||||||||||||||
| 408 | 1 | ▶ | sub director { return shift->_crew_names('Director'); } | ||||||||||||
|
Subroutine
director: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 409 | 1 | ▶ | sub producer { return shift->_crew_names('Producer'); } | ||||||||||||
|
Subroutine
producer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 410 | 1 | ▶ | sub executive_producer { return shift->_crew_names('Executive Producer'); } | ||||||||||||
|
Subroutine
executive_producer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 411 | 1 | ▶ | sub writer { return shift->_crew_names('Screenplay|Writer|Author|Novel'); } | ||||||||||||
|
Subroutine
writer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 412 | |||||||||||||||
| 413 | ## ==================== | ||||||||||||||
| 414 | ## IMAGE HELPERS | ||||||||||||||
| 415 | ## ==================== | ||||||||||||||
| 416 | |||||||||||||||
| 417 | # Poster | ||||||||||||||
| 418 | 1 | ▶ | sub poster { | ||||||||||||
|
Subroutine
poster: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||
| 419 | 1 | my $self = shift; | |||||||||||||
| 420 | 1 | my $info = $self->info(); | |||||||||||||
| 421 | 1 | ▶ | return unless $info; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 422 | 1 | ▶ | return $info->{poster_path} || q(); | ||||||||||||
|
Condition50%1/2
$info->{'poster_path'} || ''
MC/DC0%0/1
$info->{'poster_path'} || ''
$info->{'poster_path'}
Truth table50%1/2
A
A= $info->{'poster_path'}
| |||||||||||||||
| 423 | } ## end sub poster | ||||||||||||||
| 424 | |||||||||||||||
| 425 | # Posters | ||||||||||||||
| 426 | 1 | ▶ | sub posters { | ||||||||||||
|
Subroutine
posters: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||
| 427 | 1 | my $self = shift; | |||||||||||||
| 428 | 1 | my $response = $self->images(); | |||||||||||||
| 429 | 1 | ▶ | return unless $response; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 430 | 1 | ▶ | my $posters = $response->{posters} || []; | ||||||||||||
|
Condition50%1/2
$response->{'posters'} || []
MC/DC0%0/1
$response->{'posters'} || []
$response->{'posters'}
Truth table50%1/2
A
A= $response->{'posters'}
| |||||||||||||||
| 431 | 1 | return $self->_image_urls($posters); | |||||||||||||
| 432 | } ## end sub posters | ||||||||||||||
| 433 | |||||||||||||||
| 434 | # Backdrop | ||||||||||||||
| 435 | 1 | ▶ | sub backdrop { | ||||||||||||
|
Subroutine
backdrop: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||
| 436 | 1 | my $self = shift; | |||||||||||||
| 437 | 1 | my $info = $self->info(); | |||||||||||||
| 438 | 1 | ▶ | return unless $info; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 439 | 1 | ▶ | return $info->{backdrop_path} || q(); | ||||||||||||
|
Condition50%1/2
$info->{'backdrop_path'} || ''
MC/DC0%0/1
$info->{'backdrop_path'} || ''
$info->{'backdrop_path'}
Truth table50%1/2
A
A= $info->{'backdrop_path'}
| |||||||||||||||
| 440 | } ## end sub backdrop | ||||||||||||||
| 441 | |||||||||||||||
| 442 | # Backdrops | ||||||||||||||
| 443 | 1 | ▶ | sub backdrops { | ||||||||||||
|
Subroutine
backdrops: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||
| 444 | 1 | my $self = shift; | |||||||||||||
| 445 | 1 | my $response = $self->images(); | |||||||||||||
| 446 | 1 | ▶ | return unless $response; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 447 | 1 | ▶ | my $backdrops = $response->{backdrops} || []; | ||||||||||||
|
Condition50%1/2
$response->{'backdrops'} || []
MC/DC0%0/1
$response->{'backdrops'} || []
$response->{'backdrops'}
Truth table50%1/2
A
A= $response->{'backdrops'}
| |||||||||||||||
| 448 | 1 | return $self->_image_urls($backdrops); | |||||||||||||
| 449 | } ## end sub backdrops | ||||||||||||||
| 450 | |||||||||||||||
| 451 | ## ==================== | ||||||||||||||
| 452 | ## TRAILER HELPERS | ||||||||||||||
| 453 | ## ==================== | ||||||||||||||
| 454 | 1 | ▶ | sub trailers_youtube { | ||||||||||||
|
Subroutine
trailers_youtube: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||
| 455 | 1 | my $self = shift; | |||||||||||||
| 456 | 1 | my $trailers = $self->trailers(); | |||||||||||||
| 457 | 1 | my @urls; | |||||||||||||
| 458 | 1 | ▶ | my $yt_tmp = $trailers->{youtube} || []; | ||||||||||||
|
Condition50%1/2
$trailers->{'youtube'} || []
MC/DC0%0/1
$trailers->{'youtube'} || []
$trailers->{'youtube'}
Truth table50%1/2
A
A= $trailers->{'youtube'}
| |||||||||||||||
| 459 | 1 | foreach (@$yt_tmp) { | |||||||||||||
| 460 | 0 | push @urls, 'http://youtu.be/' . $_->{source}; | |||||||||||||
| 461 | } | ||||||||||||||
| 462 | 1 | ▶ | return @urls if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 463 | 1 | return \@urls; | |||||||||||||
| 464 | } ## end sub trailers_youtube | ||||||||||||||
| 465 | |||||||||||||||
| 466 | ####################### | ||||||||||||||
| 467 | # PRIVATE METHODS | ||||||||||||||
| 468 | ####################### | ||||||||||||||
| 469 | |||||||||||||||
| 470 | ## ==================== | ||||||||||||||
| 471 | ## CAST | ||||||||||||||
| 472 | ## ==================== | ||||||||||||||
| 473 | 9 | ▶ | sub _cast { | ||||||||||||
|
Subroutine
_cast: called CC=1 SCAR=0.0
| |||||||||||||||
| 474 | 9 | my $self = shift; | |||||||||||||
| 475 | 9 | return $self->session->talk( | |||||||||||||
| 476 | { | ||||||||||||||
| 477 | method => 'movie/' . $self->id() . '/casts', | ||||||||||||||
| 478 | } | ||||||||||||||
| 479 | ); | ||||||||||||||
| 480 | } ## end sub _cast | ||||||||||||||
| 481 | |||||||||||||||
| 482 | ## ==================== | ||||||||||||||
| 483 | ## CREW NAMES | ||||||||||||||
| 484 | ## ==================== | ||||||||||||||
| 485 | 5 | ▶ | sub _crew_names { | ||||||||||||
|
Subroutine
_crew_names: called CC=4 SCAR=15.2
| |||||||||||||||
| 486 | 5 | my $self = shift; | |||||||||||||
| 487 | 5 | my $job = shift; | |||||||||||||
| 488 | |||||||||||||||
| 489 | 5 | my @names; | |||||||||||||
| 490 | 5 | my @crew = $self->crew(); | |||||||||||||
| 491 | 5 | foreach (@crew) { | |||||||||||||
| 492 | 0 | ▶ | push @names, $_->{name} if ( $_->{job} =~ m{$job}xi ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 493 | } | ||||||||||||||
| 494 | |||||||||||||||
| 495 | 5 | ▶ | return @names if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 496 | 5 | return \@names; | |||||||||||||
| 497 | } ## end sub _crew_names | ||||||||||||||
| 498 | |||||||||||||||
| 499 | ## ==================== | ||||||||||||||
| 500 | ## IMAGE URLS | ||||||||||||||
| 501 | ## ==================== | ||||||||||||||
| 502 | 2 | ▶ | sub _image_urls { | ||||||||||||
|
Subroutine
_image_urls: called CC=3 SCAR=11.3
| |||||||||||||||
| 503 | 2 | my $self = shift; | |||||||||||||
| 504 | 2 | my $images = shift; | |||||||||||||
| 505 | 2 | my @urls; | |||||||||||||
| 506 | 2 | foreach (@$images) { | |||||||||||||
| 507 | 0 | push @urls, $_->{file_path}; | |||||||||||||
| 508 | } | ||||||||||||||
| 509 | 2 | ▶ | return @urls if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 510 | 2 | return \@urls; | |||||||||||||
| 511 | } ## end sub _image_urls | ||||||||||||||
| 512 | |||||||||||||||
| 513 | ####################### | ||||||||||||||
| 514 | 3 | 1; | |||||||||||||