Subject: | $film->plot() returning invalid results |
Hiya,
Simple one to show:
my ($film, $year) = ('Freaky Friday', 1995);
print "Test '$film' ($year)\n";
my $imdb = new IMDB::Film(crit => $film,
year => $year,
cache => 1);
$plot = $imdb->plot();
$fullplot= $imdb->full_plot();
print "PLOT:\n";
print " $plot\n";
print "FULLPLOT:\n";
print " $fullplot\n";
Writes the 'PLOT' as the value of the keywords - "Remake | Child As
Adult | Role Reversal | Mother Daughter Relationship | Sports Team".
My fix is to change the code so that the while in sub plot reads:
while(my $tag = $parser->get_tag(MAIN_TAG)) {
last if $parser->get_text =~ /^plot(?! keywords)/i;
}
(?!...) is a zero-width negative look-ahead assertion. Might be easier
to say eq 'Plot:', but I felt this was more in keeping with how the
code was used.
However, the change that was made in 0.41->0.42 to support references
to other links means that we also have other values. Apply the above
change and change the film initialisation line to:
my ($film, $year) = ('Freaky Friday', 2003);
and we now get:
PLOT:
An overworked mother and her daughter do not get along. When they
switch bodies, each is forced to adapt to the others life for one
freaky Friday. full summary | add synopsis
... because the full summary and bits appear as links on the end of the
text. If the line in sub plot is changed to:
$plot =~ s/\s+full summary \| (full|add) synopsis//;
then this appears to strip them quite happily.