]>
iEval git - app-imdbtop.git/blob - lib/App/IMDBtop.pm
0eda7b275e6d706119fbd4781d2989e437e20bd5
11 our $VERSION = '0.001';
15 our (%cast_cache, %cast_count);
16 our ($nr, $min_count, $cache, $cache_root);
19 my IMDB
::Film
$self = shift;
20 my ($forced) = shift || 0;
23 my (@cast, $tag, $person, $id, $role);
24 my $parser = $self->_parser(1);
26 while($tag = $parser->get_tag('table')) {
27 last if $tag->[1]->{class} && $tag->[1]->{class} =~ /^cast_list$/i;
29 while($tag = $parser->get_tag()) {
30 last if $tag->[0] eq 'a' && $tag->[1]{href
} && $tag->[1]{href
} =~ /fullcredits/i;
31 # if($tag->[0] eq 'td' && $tag->[1]{class} && $tag->[1]{class} eq 'name') {
32 $tag = $parser->get_tag('a');
33 if($tag->[1]{href
} && $tag->[1]{href
} =~ m
#name/nm(\d+?)/#) {
34 $person = $parser->get_text;
36 my $text = $parser->get_trimmed_text('/tr');
37 ($role) = $text =~ /\.\.\. (.*)$/;
38 push @cast, {id
=> $id, name
=> $person, role
=> $role} if $person;
43 $self->{_cast
} = \
@cast;
46 return $self->{_cast
};
52 my @args = (crit
=> $crit);
53 push @args, cache
=> $cache if defined $cache;
54 push @args, cache_root
=> $cache_root if defined $cache_root;
55 my $film = IMDB
::Film
->new(@args);
56 my @cast = @
{ $film->cast() };
58 warn "Installed IMDB::Film is broken, using patched cast() method\n" unless $warned;
60 @cast = @
{ patched_cast
$film };
62 for my $cast (@cast) {
63 my ($id, $name) = ($cast->{id
}, $cast->{name
});
64 $cast_cache{$id} = $name;
73 $cast_count{$b} <=> $cast_count{$a}
74 or $cast_cache{$a} cmp $cast_cache{$b}
77 !$min_count || $cast_count{$_} > $min_count
79 last if $nr && $cnt++ >= $nr;
80 say $cast_count{$_} . ' ' . $cast_cache{$_}
87 'm|min-count=i' => \
$min_count,
88 'c|cache!' => \
$cache,
89 'cache-root=s' => \
$cache_root,
103 App::IMDBtop - list actors that are popular in your movie collection
112 This module solves a simple problem: you have a list of movies you've
113 watched (in the form of IMDB IDs), and you are looking for the actors
114 that have starred most often in these movies.
116 This module is the backend for the B<imdbtop> script.
120 L<http://imdb.com>, L<imdbtop>
124 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
126 =head1 COPYRIGHT AND LICENSE
128 Copyright (C) 2016 by Marius Gavrilescu
130 This library is free software; you can redistribute it and/or modify
131 it under the same terms as Perl itself, either Perl version 5.24.0 or,
132 at your option, any later version of Perl 5 you may have available.
This page took 0.047287 seconds and 4 git commands to generate.