Skip Menu |
 

This queue is for tickets about the IMDB-Film CPAN distribution.

Report information
The Basics
Id: 60595
Status: open
Priority: 0/
Queue: IMDB-Film

People
Owner: STEPANOV [...] cpan.org
Requestors: perl [...] tcbmi.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Patch: fix cover() problem with foreign movies
Download (untitled) / with headers
text/plain 386b
The existing cover() routine assumes that the alt text of the cover image matches the display title of the file. This is not always the case with foreign films, where the alt text will be the original title name. This patch adds a original_title() method that returns the original title of the film (if any). The cover() method is also patched to support matching the original_title.
Subject: support_original_title.patch
--- Film.pm 2009-12-14 07:55:15.000000000 -0500 +++ Film.pm.new 2010-08-21 16:44:25.000000000 -0400 @@ -62,6 +62,7 @@ _cast _directors _writers + _original_title _cover _language _country @@ -663,6 +664,33 @@ return $self->{_episodeof}; } +=item original_title() + +Retrieve film's original (untranslated) title: + + my $original_title = $film->original_title(); + +=cut + +sub original_title { + my CLASS_NAME $self = shift; + my $forced = shift || 0; + + if($forced) { + my $parser = $self->_parser(FORCED); + my $original_title; + while(my $tag = $parser->get_tag('span')) { + if ($tag->[1]->{class} && $tag->[1]->{class} =~ /title-extra/i) + { + $original_title = $parser->get_trimmed_text(); + last; + } + } + $self->{_original_title} = $original_title; + } + return $self->{_original_title}; +} + =item cover() Retrieve url of film cover: @@ -680,12 +708,17 @@ my $cover; my $title = quotemeta($self->title); + my $original_title = quotemeta($self->original_title); while(my $img_tag = $parser->get_tag('img')) { $img_tag->[1]{alt} ||= ''; last if $img_tag->[1]{alt} =~ /^poster not submitted/i; - if($img_tag->[1]{alt} =~ /^$title$/i) { + if ( + $img_tag->[1]{alt} =~ /^$title$/i || + ( defined $original_title && $original_title ne '' && ($img_tag->[1]{alt} =~ /^$original_title$/i) ) + ) + { $cover = $img_tag->[1]{src}; last; }
From: 2ge [...] 2ge.us
Download (untitled) / with headers
text/plain 618b
I confirm, this bug exists in latest Film.pm. However, after applying patch, I get: update_imdb.pl: Use of uninitialized value in quotemeta at /opt/local/lib/perl5/site_perl/5.8.9/IMDB/Film.pm line 711. This needs to be fixed, good example of such movie is "http://www.imdb.com/title/tt0100263/" Also I saw, they are adding link to poster in meta: <link rel="image_src" href="http://ia.media-imdb.com/images/M/MV5BMjU5NjMxNDM1Ml5BMl5BanBnXkFtZTYwODAwNzk5._V1._SX98_SY140_.jpg"><meta property="og:image" content="http://ia.media-imdb.com/images/M/MV5BMjU5NjMxNDM1Ml5BMl5BanBnXkFtZTYwODAwNzk5._V1._SX98_SY140_.jpg">
From: 2ge [...] 2ge.us
I am not a perl programmer, but this patch seems to work.
Subject: Film.pm.patch
Download Film.pm.patch
text/x-diff 1.7k
--- Film.pm 2010-03-19 21:50:22.000000000 +0700 +++ Film.pm.patched 2010-09-08 18:21:46.000000000 +0700 @@ -62,6 +62,7 @@ _cast _directors _writers + _original_title _cover _language _country @@ -663,6 +664,33 @@ return $self->{_episodeof}; } +=item original_title() + +Retrieve film's original (untranslated) title: + + my $original_title = $film->original_title(); + +=cut + +sub original_title { + my CLASS_NAME $self = shift; + my $forced = shift || 0; + + if($forced) { + my $parser = $self->_parser(FORCED); + my $original_title; + while(my $tag = $parser->get_tag('span')) { + if ($tag->[1]->{class} && $tag->[1]->{class} =~ /title-extra/i) + { + $original_title = $parser->get_trimmed_text(); + last; + } + } + $self->{_original_title} = $original_title; + } + return $self->{_original_title}; +} + =item cover() Retrieve url of film cover: @@ -675,17 +703,32 @@ my CLASS_NAME $self = shift; my $forced = shift || 0; + #print Dumper($self); + #die; + if($forced) { my $parser = $self->_parser(FORCED); my $cover; + my $title = quotemeta($self->title); + my $original_title; + if($self->original_title) { + $original_title = quotemeta($self->original_title); + } else { + $original_title = quotemeta($self->original_title(FORCED)); + } + while(my $img_tag = $parser->get_tag('img')) { $img_tag->[1]{alt} ||= ''; last if $img_tag->[1]{alt} =~ /^poster not submitted/i; - if($img_tag->[1]{alt} =~ /^$title$/i) { + if ( + $img_tag->[1]{alt} =~ /^$title$/i || + ( defined $original_title && $original_title ne '' && ($img_tag->[1]{alt} =~ /^$original_title$/i) ) + ) + { $cover = $img_tag->[1]{src}; last; }
Download (untitled) / with headers
text/plain 171b
Thanks, guys, for the bug report and patch. I'll review it and apply to the next release of IMDB::Film which is planned at 10/09/2010. -- Best Regards, Michael Stepanov


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.