Subject: | Bug in Film.pm package |
Date: | Sat, 7 Jan 2012 22:48:20 +0100 |
To: | bug-IMDB-Film [...] rt.cpan.org |
From: | Vincent Sercu <vincent.sercu [...] gmail.com> |
Hi,
I've found a small bug in the rating of films and series; I was able to
locate and fix it.
IMDB must've probably changed their website so the parsing of the following
item did not work anymore:
Film.pm, starting at line 925 in version 0.51
sub rating {
my CLASS_NAME $self = shift;
my ($forced) = shift || 0;
if($forced) {
my $parser = $self->_parser(FORCED);
while(my $tag = $parser->get_tag('div')) {
* last if $tag->[1]{class} && $tag->[1]{class} eq
'star-box-details';*
}
my $text = $parser->get_trimmed_text('/a');
my($rating, $val) = $text =~ m!(\d+\.?\d*)/10.*?(\d+,?\d*)!;
$val =~ s/\,// if $val;
$self->{_rating} = [$rating, $val, $self->top_info];
unless($self->{_plot}) {
my $tag = $parser->get_tag('p');
my $text = $parser->get_trimmed_text('/p');
$self->{_plot} = $text;
}
}
if you change the line in bold to
last if $tag->[1]{class} && $tag->[1]{class} eq '*star-bar-user-rate*';
It works smoothly again :)
Keep up the good work!
Cheers,
Vincent Sercu
Belgium