]> iEval git - app-imdbtop.git/commitdiff
Make patched_cast actually work
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 12 Nov 2016 16:38:03 +0000 (18:38 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 12 Nov 2016 16:38:03 +0000 (18:38 +0200)
lib/App/IMDBtop.pm

index 0eda7b275e6d706119fbd4781d2989e437e20bd5..340c6125cb44e952818bd4f7e97f5992ec359a81 100644 (file)
@@ -17,33 +17,28 @@ our ($nr, $min_count, $cache, $cache_root);
 
 sub patched_cast {
        my IMDB::Film $self = shift;
-       my ($forced) = shift || 0;
-
-       if($forced) {
-               my (@cast, $tag, $person, $id, $role);
-               my $parser = $self->_parser(1);
-
-               while($tag = $parser->get_tag('table')) {
-                       last if $tag->[1]->{class} && $tag->[1]->{class} =~ /^cast_list$/i;
-               }
-               while($tag = $parser->get_tag()) {
-                       last if $tag->[0] eq 'a' && $tag->[1]{href} && $tag->[1]{href} =~ /fullcredits/i;
-       #               if($tag->[0] eq 'td' && $tag->[1]{class} && $tag->[1]{class} eq 'name') {
-                               $tag = $parser->get_tag('a');
-                               if($tag->[1]{href} && $tag->[1]{href} =~ m#name/nm(\d+?)/#) {
-                                       $person = $parser->get_text;
-                                       $id = $1;
-                                       my $text = $parser->get_trimmed_text('/tr');
-                                       ($role) = $text =~ /\.\.\. (.*)$/;
-                                       push @cast, {id => $id, name => $person, role => $role} if $person;
-                               }
-       #               }
-               }
-
-               $self->{_cast} = \@cast;
+
+       my (@cast, $tag, $person, $id, $role);
+       my $parser = $self->_parser(1);
+
+       while($tag = $parser->get_tag('table')) {
+               last if $tag->[1]->{class} && $tag->[1]->{class} =~ /^cast_list$/i;
+       }
+       while($tag = $parser->get_tag()) {
+               last if $tag->[0] eq 'a' && $tag->[1]{href} && $tag->[1]{href} =~ /fullcredits/i;
+       #       if($tag->[0] eq 'td' && $tag->[1]{class} && $tag->[1]{class} eq 'name') {
+                       $tag = $parser->get_tag('a');
+                       if($tag->[1]{href} && $tag->[1]{href} =~ m#name/nm(\d+?)/#) {
+                               $person = $parser->get_text;
+                               $id = $1;
+                               my $text = $parser->get_trimmed_text('/tr');
+                               ($role) = $text =~ /\.\.\. (.*)$/;
+                               push @cast, {id => $id, name => $person, role => $role} if $person;
+                       }
+       #       }
        }
 
-       return $self->{_cast};
+       \@cast
 }
 
 sub add_film {
This page took 0.029379 seconds and 4 git commands to generate.