line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TMDB::Collection; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
####################### |
4
|
|
|
|
|
|
|
# LOAD CORE MODULES |
5
|
|
|
|
|
|
|
####################### |
6
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
8
|
1
|
|
|
1
|
|
4
|
use Carp qw(croak carp); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
####################### |
11
|
|
|
|
|
|
|
# LOAD CPAN MODULES |
12
|
|
|
|
|
|
|
####################### |
13
|
1
|
|
|
1
|
|
5
|
use Object::Tiny qw(id session); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
14
|
1
|
|
|
1
|
|
166
|
use Params::Validate qw(validate_with :types); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
158
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
####################### |
17
|
|
|
|
|
|
|
# LOAD DIST MODULES |
18
|
|
|
|
|
|
|
####################### |
19
|
1
|
|
|
1
|
|
5
|
use TMDB::Session; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
####################### |
22
|
|
|
|
|
|
|
# VERSION |
23
|
|
|
|
|
|
|
####################### |
24
|
|
|
|
|
|
|
our $VERSION = '1.2.0'; |
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
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(%opts); |
49
|
0
|
|
|
|
|
|
return $self; |
50
|
|
|
|
|
|
|
} ## end sub new |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
## ==================== |
53
|
|
|
|
|
|
|
## INFO |
54
|
|
|
|
|
|
|
## ==================== |
55
|
|
|
|
|
|
|
sub info { |
56
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
57
|
0
|
0
|
|
|
|
|
return $self->session->talk( |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
method => 'collection/' . $self->id(), |
60
|
|
|
|
|
|
|
params => { |
61
|
|
|
|
|
|
|
language => $self->session->lang |
62
|
|
|
|
|
|
|
? $self->session->lang |
63
|
|
|
|
|
|
|
: undef, |
64
|
|
|
|
|
|
|
}, |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
} ## end sub info |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
## ==================== |
70
|
|
|
|
|
|
|
## VERSION |
71
|
|
|
|
|
|
|
## ==================== |
72
|
|
|
|
|
|
|
sub version { |
73
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
74
|
0
|
0
|
|
|
|
|
my $response = $self->session->talk( |
75
|
|
|
|
|
|
|
{ |
76
|
|
|
|
|
|
|
method => 'collection/' . $self->id(), |
77
|
|
|
|
|
|
|
want_headers => 1, |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
) or return; |
80
|
0
|
|
0
|
|
|
|
my $version = $response->{etag} || q(); |
81
|
0
|
|
|
|
|
|
$version =~ s{"}{}gx; |
82
|
0
|
|
|
|
|
|
return $version; |
83
|
|
|
|
|
|
|
} ## end sub version |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
## ==================== |
86
|
|
|
|
|
|
|
## INFO HELPERS |
87
|
|
|
|
|
|
|
## ==================== |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# All titles |
90
|
0
|
|
|
0
|
0
|
|
sub titles { return shift->_parse_parts('title'); } |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# Title IDs |
93
|
0
|
|
|
0
|
0
|
|
sub ids { return shift->_parse_parts('id'); } |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
####################### |
96
|
|
|
|
|
|
|
# PRIVATE METHODS |
97
|
|
|
|
|
|
|
####################### |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _parse_parts { |
101
|
0
|
|
|
0
|
|
|
my $self = shift; |
102
|
0
|
|
|
|
|
|
my $key = shift; |
103
|
0
|
|
|
|
|
|
my $info = $self->info(); |
104
|
0
|
0
|
|
|
|
|
my $parts = $info ? $info->{parts} : []; |
105
|
0
|
|
|
|
|
|
my @stuff; |
106
|
0
|
|
|
|
|
|
foreach my $part (@$parts) { |
107
|
0
|
0
|
|
|
|
|
next unless $part->{$key}; |
108
|
0
|
|
|
|
|
|
push @stuff, $part->{$key}; |
109
|
|
|
|
|
|
|
} ## end foreach my $part (@$parts) |
110
|
0
|
0
|
|
|
|
|
return @stuff if wantarray; |
111
|
0
|
|
|
|
|
|
return \@stuff; |
112
|
|
|
|
|
|
|
} ## end sub _parse_parts |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
####################### |
115
|
|
|
|
|
|
|
1; |