| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::Moviepilot::Person; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
63
|
|
|
7
|
1
|
|
|
1
|
|
12
|
use JSON::Any; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
8
|
1
|
|
|
1
|
|
127
|
use URI; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
20
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use URI::Escape; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
61
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use WWW::Moviepilot::Movie; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
702
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
WWW::Moviepilot::Person - Handle moviepilot.de people |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $person = WWW::Moviepilot->new->(...)->person( 'paul-newman' ); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# all fields |
|
22
|
|
|
|
|
|
|
my @fields = $person->fields; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# direct access to fields |
|
25
|
|
|
|
|
|
|
print $person->date_of_death; # "2008-09-26" |
|
26
|
|
|
|
|
|
|
print $person->title; # field does not exist => undef |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 new |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Creates a blank WWW::Moviepilot::Person object. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $person = WWW::Moviepilot::Person->new; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new { |
|
39
|
0
|
|
|
0
|
1
|
|
my ($class, $args) = @_; |
|
40
|
0
|
|
|
|
|
|
my $self = bless { |
|
41
|
|
|
|
|
|
|
filmography => [], |
|
42
|
|
|
|
|
|
|
name => undef, |
|
43
|
|
|
|
|
|
|
m => $args->{m}, |
|
44
|
|
|
|
|
|
|
} => $class; |
|
45
|
0
|
|
|
|
|
|
return $self; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 populate( $args ) |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Populates an object with data, you should not use this directly. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub populate { |
|
55
|
0
|
|
|
0
|
1
|
|
my ($self, $args) = @_; |
|
56
|
0
|
|
|
|
|
|
$self->{data} = $args->{data}; |
|
57
|
0
|
0
|
|
|
|
|
if ( $self->restful_url ) { |
|
58
|
0
|
|
|
|
|
|
($self->{name}) = $self->restful_url =~ m{/([^/]+)$}; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 character |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
If used together with a movie search, you get the name of the character |
|
65
|
|
|
|
|
|
|
the person plays in the movie. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my @cast = $movie->cast; |
|
68
|
|
|
|
|
|
|
foreach my $person (@cast) { |
|
69
|
|
|
|
|
|
|
printf "%s plays %s\n", $person->last_name, $person->character; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub character { |
|
75
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
76
|
0
|
|
|
|
|
|
return $self->{data}{character}; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 name |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns the internal moviepilot name for the person. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my @people = WWW::Moviepilot->new(...)->search_person( 'paul-newman' ); |
|
84
|
|
|
|
|
|
|
foreach my $person (@people) { |
|
85
|
|
|
|
|
|
|
print $person->name; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub name { |
|
91
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
92
|
0
|
|
|
|
|
|
return $self->{name}; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 filmography |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Returns the filmography for the person. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $person = WWW::Moviepilot->new(...)->person(...); |
|
100
|
|
|
|
|
|
|
my @filmography = $person->cast; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returned is a list of L objects. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub filmography { |
|
107
|
0
|
|
|
0
|
1
|
|
my ($self, $name) = @_; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# we have already a filmography |
|
110
|
0
|
0
|
|
|
|
|
if ( @{ $self->{filmography} } ) { |
|
|
0
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
return @{ $self->{filmography} }; |
|
|
0
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
0
|
0
|
|
|
|
if ( !$name && !$self->name ) { |
|
115
|
0
|
|
|
|
|
|
croak "no name provided, can't fetch filmography"; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
0
|
|
0
|
|
|
|
$name ||= $self->name; |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
my $uri = URI->new( $self->{m}->host . '/people/' . uri_escape($name) . '/filmography.json' ); |
|
121
|
0
|
|
|
|
|
|
$uri->query_form( api_key => $self->{m}->api_key ); |
|
122
|
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
my $res = $self->{m}->ua->get( $uri->as_string ); |
|
124
|
0
|
0
|
|
|
|
|
if ( $res->is_error ) { |
|
125
|
0
|
|
|
|
|
|
croak $res->status_line; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my $o = JSON::Any->from_json( $res->decoded_content ); |
|
129
|
0
|
|
|
|
|
|
foreach my $entry ( @{ $o->{movies_people} } ) { |
|
|
0
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
my $movie = WWW::Moviepilot::Movie->new({ m => $self->{m} }); |
|
131
|
0
|
|
|
|
|
|
$movie->populate({ data => $entry }); |
|
132
|
0
|
|
|
|
|
|
push @{ $self->{filmography} }, $movie; |
|
|
0
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
return @{ $self->{filmography} }; |
|
|
0
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 fields |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Returns a list with all fields for this person. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
my @fields = $person->fields; |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# print all fields |
|
145
|
|
|
|
|
|
|
foreach my $field (@fields) { |
|
146
|
|
|
|
|
|
|
printf "%s: %s\n", $field. $person->$field; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
As of 2009-10-14, these fields are supported: |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=over 4 |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * date_of_birth |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * date_of_death |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * first_name |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * homepage |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * last_name |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item * long_description |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * pseudonyms |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item * restful_url |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * sex |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item * short_description |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=back |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub fields { |
|
178
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
179
|
0
|
|
|
|
|
|
return keys %{ $self->{data}{person} }; |
|
|
0
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
our $AUTOLOAD; |
|
183
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
184
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
185
|
0
|
|
|
|
|
|
my $field = $AUTOLOAD; |
|
186
|
0
|
|
|
|
|
|
$field =~ s/.*://; |
|
187
|
0
|
0
|
|
|
|
|
if ( !exists $self->{data}{person}{$field} ) { |
|
188
|
0
|
|
|
|
|
|
return; |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
return $self->{data}{person}{$field}; |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
1; |
|
195
|
|
|
|
|
|
|
__END__ |