line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Base.pm 7373 2012-04-09 18:00:33Z chris $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package WebService::Flixster::Base; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
138
|
|
6
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
76
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
15
|
use base qw(Class::Accessor); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
178
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
11
|
use Cache::FileCache; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
92
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
168
|
|
15
|
|
|
|
|
|
|
our @CARP_NOT = qw(WebService::Flixster WebService::Flixster::Title); |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
1932
|
use HTTP::Request::Common; |
|
2
|
|
|
|
|
5490
|
|
|
2
|
|
|
|
|
1368
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw( |
20
|
|
|
|
|
|
|
_ws |
21
|
|
|
|
|
|
|
_q |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__id |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
__content |
26
|
|
|
|
|
|
|
)); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _new { |
30
|
0
|
|
|
0
|
|
|
my $class = shift; |
31
|
0
|
|
|
|
|
|
my $ws = shift; |
32
|
0
|
|
|
|
|
|
my $q = shift; |
33
|
0
|
|
|
|
|
|
my %opts = @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $self = {}; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
bless $self, $class; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$self->_ws($ws); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$self->_q($q); |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
if (!$opts{'_defer_fetch'}) { |
44
|
0
|
|
|
|
|
|
$self->_id(); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $self; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
################################ |
52
|
|
|
|
|
|
|
# |
53
|
|
|
|
|
|
|
# Primary properties |
54
|
|
|
|
|
|
|
# |
55
|
|
|
|
|
|
|
################################ |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub type { |
58
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
59
|
0
|
0
|
|
|
|
|
if ($self->isa("WebService::Flixster::Movie")) { |
60
|
0
|
|
|
|
|
|
return "Movie"; |
61
|
|
|
|
|
|
|
} else { |
62
|
0
|
|
|
|
|
|
die "Unknown type"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _domain { |
68
|
0
|
|
|
0
|
|
|
my $self = shift; |
69
|
0
|
|
|
|
|
|
return $self->_ws()->_domain(); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _url { |
73
|
0
|
|
|
0
|
|
|
die "Not implemented"; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _request { |
77
|
0
|
|
|
0
|
|
|
my $self = shift; |
78
|
0
|
|
|
|
|
|
my $page = shift; |
79
|
0
|
|
|
|
|
|
return GET $self->_url($page); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
################################ |
84
|
|
|
|
|
|
|
# |
85
|
|
|
|
|
|
|
# Caching accessors |
86
|
|
|
|
|
|
|
# |
87
|
|
|
|
|
|
|
################################ |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _flush { |
90
|
0
|
|
|
0
|
|
|
my $self = shift; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
$self->__ids(undef); |
93
|
0
|
|
|
|
|
|
$self->__content(undef); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _id { |
97
|
0
|
|
|
0
|
|
|
my $self = shift; |
98
|
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
|
if (!defined $self->__id) { |
100
|
0
|
|
|
|
|
|
$self->__id($self->_get_id()); |
101
|
|
|
|
|
|
|
} |
102
|
0
|
|
|
|
|
|
return $self->__id(); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub _content { |
106
|
0
|
|
|
0
|
|
|
my $self = shift; |
107
|
0
|
|
|
|
|
|
my $page = shift; |
108
|
|
|
|
|
|
|
|
109
|
0
|
0
|
|
|
|
|
if (!defined $self->__content()) { $self->__content({}); } |
|
0
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $content = $self->__content()->{$page}; |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
|
|
|
|
if (! defined $content) { |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$content = $self->_ws()->_response_decoded_json($self->_request($page)); |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
$self->__content()->{$page} = $content; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
return $content; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
################################ |
126
|
|
|
|
|
|
|
# |
127
|
|
|
|
|
|
|
# Parsing methods |
128
|
|
|
|
|
|
|
# |
129
|
|
|
|
|
|
|
################################ |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |