1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package MediaLibParser::IMDb;
use strict;
use FindBin qw($RealBin);
use lib sprintf("%s", $RealBin);
use lib sprintf("%s/../lib", $RealBin);
use MediaLibParser;
our ( @ISA, @EXPORT, $VERSION );
require Exporter;
use vars qw(@ISA);
@ISA = qw( MediaLibParser Exporter);
$VERSION = "0.01";
sub new {
my ( $type, %params ) = @_;
my $class = ref $type || $type;
my $self = $class->SUPER::new();
bless $self, $class;
foreach my $key ( keys %params ) {
$self->$key($params{$key});
}
$self->url_main( 'http://www.imdb.com' );
$self->url_results( '/find' );
$self->url_actor( '/find' );
$self->method_result('post');
$self->method_media('get');
$self->method_actor('post');
$self->param_result(
{
's' => 'nm',
'q' => $self->lookup_result,,
}
);
$self->param_actor(
{
's' => 'nm',
'q' => $self->lookup_actor,
}
);
return $self;
}
sub lookup_actor { my ( $self, $new ) = @_; if (defined $new) { $new =~ s/^\s+|\s+$//g; $new =~ s/\s/\+/g; $self->{_search_actor} = $new; } return $self->{_search_actor}; }
sub actor_search_map {
my $self = shift;
my $map = {
'imgurl' => {
'look_down' => $self->regex_actor,
'method' => 'attr',
'method_params' => 'src',
},
'subpage' => {
'look_down' => $self->regex_actor,
'method' => 'attr',
'method_params' => 'href',
'post_proc' => sub {
$_[0] = $self->url_main. $_[0];
return $_[0];
},
}
};
}
1;
|