Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: anotherschneider [...] googlemail.com
Cc:
AdminCc:

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



Subject: stars option for imdb::film.pm
Date: Thu, 15 Mar 2012 03:19:29 +0100
To: bug-IMDB-Film [...] rt.cpan.org
From: Christian Schneider <anotherschneider [...] googlemail.com>
Hi Stepanov, how about a "stars" option inside Film.pm? As I was interested in the main actors of the movie I got the following code working like a charm, based on the directors sub. Maybe you want to include it in some future version? Keep up the good work! Christian =item stars() Retrieve film stars list each element of which is hash reference - { id => <ID>, name => <Name> }: my @stars = @{ $film->stars() }; =cut sub stars { my CLASS_NAME $self = shift; my $forced = shift || 0; if($forced) { my ($parser) = $self->_parser(FORCED); my (@stars, $tag); while($tag = $parser->get_tag(MAIN_TAG)) { my $text = $parser->get_text; last if $text =~ /stars/i; } while ($tag = $parser->get_tag() ) { my $text = $parser->get_text(); last if $tag->[0] eq '/div'; if($tag->[0] eq 'a' && $tag->[1]{href} && $text !~ /(img|more)/i) { my($id) = $tag->[1]{href} =~ /(\d+)/; push @stars, {id => $id, name => $text}; } } $self->{_stars} = \@stars; } return $self->{_stars}; }
Hi Christian, There is a method cast() in the IMDB::Film which returns back a list of all casts: { id => <ID>, name => <Full Name>, role => <Role> } On Wed Mar 14 22:19:39 2012, anotherschneider@googlemail.com wrote: Show quoted text
> Hi Stepanov, > > how about a "stars" option inside Film.pm? > As I was interested in the main actors of the movie I got the following > code working like a charm, based on the directors sub. Maybe you want to > include it in some future version? > > Keep up the good work! > > > Christian > > > > > =item stars() > > Retrieve film stars list each element of which is hash reference - > { id => <ID>, name => <Name> }: > > my @stars = @{ $film->stars() }; > > =cut > > sub stars { > my CLASS_NAME $self = shift; > my $forced = shift || 0; > > if($forced) { > my ($parser) = $self->_parser(FORCED); > my (@stars, $tag); > > while($tag = $parser->get_tag(MAIN_TAG)) { > my $text = $parser->get_text; > last if $text =~ /stars/i; > } > > while ($tag = $parser->get_tag() ) { > my $text = $parser->get_text(); > > last if $tag->[0] eq '/div'; > > > if($tag->[0] eq 'a' && $tag->[1]{href} && $text !~ > /(img|more)/i) { > my($id) = $tag->[1]{href} =~ /(\d+)/; > push @stars, {id => $id, name => $text}; > } > } > > $self->{_stars} = \@stars; > } > > return $self->{_stars}; > }
-- Cheers, Michael