line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TMDB::Genre; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
####################### |
4
|
|
|
|
|
|
|
# LOAD CORE MODULES |
5
|
|
|
|
|
|
|
####################### |
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
49
|
|
7
|
1
|
|
|
1
|
|
7
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
52
|
|
8
|
1
|
|
|
1
|
|
7
|
use Carp qw(croak carp); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
####################### |
11
|
|
|
|
|
|
|
# LOAD CPAN MODULES |
12
|
|
|
|
|
|
|
####################### |
13
|
1
|
|
|
1
|
|
7
|
use Object::Tiny qw(id session); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
14
|
1
|
|
|
1
|
|
951
|
use Params::Validate qw(validate_with :types); |
|
1
|
|
|
|
|
10794
|
|
|
1
|
|
|
|
|
266
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
####################### |
17
|
|
|
|
|
|
|
# LOAD DIST MODULES |
18
|
|
|
|
|
|
|
####################### |
19
|
1
|
|
|
1
|
|
543
|
use TMDB::Session; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
####################### |
22
|
|
|
|
|
|
|
# VERSION |
23
|
|
|
|
|
|
|
####################### |
24
|
|
|
|
|
|
|
our $VERSION = '1.1.2'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
####################### |
27
|
|
|
|
|
|
|
# PUBLIC METHODS |
28
|
|
|
|
|
|
|
####################### |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
## ==================== |
31
|
|
|
|
|
|
|
## Constructor |
32
|
|
|
|
|
|
|
## ==================== |
33
|
|
|
|
|
|
|
sub new { |
34
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
35
|
0
|
|
|
|
|
|
my %opts = validate_with( |
36
|
|
|
|
|
|
|
params => \@_, |
37
|
|
|
|
|
|
|
spec => { |
38
|
|
|
|
|
|
|
session => { |
39
|
|
|
|
|
|
|
type => OBJECT, |
40
|
|
|
|
|
|
|
isa => 'TMDB::Session', |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
id => { |
43
|
|
|
|
|
|
|
type => SCALAR, |
44
|
|
|
|
|
|
|
optional => 1, |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
}, |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(%opts); |
50
|
0
|
|
|
|
|
|
return $self; |
51
|
|
|
|
|
|
|
} ## end sub new |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
## ==================== |
54
|
|
|
|
|
|
|
## LIST |
55
|
|
|
|
|
|
|
## ==================== |
56
|
|
|
|
|
|
|
sub list { |
57
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
58
|
0
|
0
|
|
|
|
|
my $response = $self->session->talk( |
59
|
|
|
|
|
|
|
{ |
60
|
|
|
|
|
|
|
method => 'genre/list', |
61
|
|
|
|
|
|
|
params => { |
62
|
|
|
|
|
|
|
language => $self->session->lang |
63
|
|
|
|
|
|
|
? $self->session->lang |
64
|
|
|
|
|
|
|
: undef, |
65
|
|
|
|
|
|
|
}, |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
); |
68
|
0
|
0
|
|
|
|
|
return unless $response; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $genres; |
71
|
0
|
|
0
|
|
|
|
$genres = $response->{genres} || []; |
72
|
0
|
0
|
|
|
|
|
return @$genres if wantarray; |
73
|
0
|
|
|
|
|
|
return $genres; |
74
|
|
|
|
|
|
|
} ## end sub list |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
## ==================== |
77
|
|
|
|
|
|
|
## MOVIES |
78
|
|
|
|
|
|
|
## ==================== |
79
|
|
|
|
|
|
|
sub movies { |
80
|
0
|
|
|
0
|
0
|
|
my ( $self, $max_pages ) = @_; |
81
|
0
|
0
|
|
|
|
|
return unless $self->id(); |
82
|
0
|
0
|
|
|
|
|
return $self->session->paginate_results( |
83
|
|
|
|
|
|
|
{ |
84
|
|
|
|
|
|
|
method => 'genre/' . $self->id() . '/movies', |
85
|
|
|
|
|
|
|
max_pages => $max_pages, |
86
|
|
|
|
|
|
|
params => { |
87
|
|
|
|
|
|
|
language => $self->session->lang |
88
|
|
|
|
|
|
|
? $self->session->lang |
89
|
|
|
|
|
|
|
: undef, |
90
|
|
|
|
|
|
|
}, |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
} ## end sub movies |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
####################### |
96
|
|
|
|
|
|
|
1; |