diff options
Diffstat (limited to 'lib/MediaLibParser/IMDb.pm')
| -rw-r--r-- | lib/MediaLibParser/IMDb.pm | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/MediaLibParser/IMDb.pm b/lib/MediaLibParser/IMDb.pm new file mode 100644 index 0000000..fd1e43f --- /dev/null +++ b/lib/MediaLibParser/IMDb.pm @@ -0,0 +1,74 @@ +package MediaLibParser::IMDb;
+
+use strict;
+
+use FindBin qw($RealBin);
+use lib sprintf("%s", $RealBin);
+use lib sprintf("%s/../lib", $RealBin);
+
+use Data::Dumper;
+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;
\ No newline at end of file |
