WWW::Yahoo::Movies - Perl extension to get Yahoo! Movies


WWW-Yahoo-Movies documentation  | view source Contained in the WWW-Yahoo-Movies distribution.

Index


NAME

Top

WWW::Yahoo::Movies - Perl extension to get Yahoo! Movies information.

SYNOPSIS

Top

  use WWW::Yahoo::Movies;

  my $movie = new WWW::Yahoo::Movies();

  print "TITLE: ".$movie->title." - ".$movie->year."\n";

DESCRIPTION

Top

WWW::Yahoo::Movies is Perl interface to the Yahoo! Movies (http://movies.yahoo.com/). Sometimes IMDB doesn't have full information about movie (plot summary, cover etc). In that case it's good idea to have another place to get movie info.

Also, there are many Perl extensions for Yahoo! in the CPAN. Hope WWW::Yahoo::Movies will be useful as well!

CONSTRUCTOR

new()

You should pass movie title or Yahoo! movie ID. In case movie ID it'll retrieve the movie information directly. If movie title was passed as constructor parameter it'll make a search, store matched results and return the first matched movie info:

	my $movie = new WWW::Yahoo::Movies(id => 1808444810);

or

	my $movie = new WWW::Yahoo::Movies(id => 'Troy');




PUBLIC OBJECT METHODS

id()

Yahoo! movie ID:

	my $id = $ym->id();

title()

Yahoo! movie title:

	my $title $ym->title();

cover()

A link on Yahoo! movie cover:

	use LWP::Simple qw(get);

	my $cover_img = get($ym->cover);

	 print "Content-type: image/jpeg\n\n";
	 print $cover_img;

year()

Year of release of Yahoo! movie:

	my $year = $ym->year();

mpaa_rating()

MPAA rating of Yahoo! movie. In scalar context it returns MPAA code, in array context it returns array contained MPAA code and description.

	my $mpaa_code = $ym->mpaa_rating();

or

	my($mpaa_code, $mpaa_descr) = $ym->mpaa_rating();

For more information about MPAA rating please visit that page http://www.mpaa.org/movieratings/

distributor()

Company name which distributes Yahoo! movie:

	my $distr_name = $ym->distributor();

release_date()

Release date of Yahoo! movie:

	my $date = $ym->release_date();

runtime()

Returns a duration of Yahoo! movie in minutes:

	my $runtime = $ym->runtime();

genres()

Genres of Yahoo! movie:

	my @genres = @{ $self->genres };

Note: that method returns a reference on array with genres.

plot_summary()

A short description of Yahoo! movie:

	my $plot = $ym->plot_summary();

matched()

List of mathed Yahoo! movies in case of search by movie's title. It returns an array reference with hashes in the form of id => title:

	map { print "ID: $_->{id}; title: $_->{title}\n" } @{ $ym->matched();

people()

Return a hash with following keys - director, producer and cast, which correspond on array with Yahoo Person ID and person full name:

	my $people = $ymovie->people();

	for(keys %$people) {
		print "Category $_ \n";
		for(@{$person->{$_}}) {
			print "$_->[0]: $_->[2] ...\n";
		}
	}

cast()

Return a list of movie cast like pair: Yahoo Person ID, person name:

	my $cast = $ymovie->cast;

	for(@$cast) {
		print "$_->[0]: $_->[1]\n";
	}

producers()

Return a list of movie producers like pair: Yahoo Person ID, person name:

	my $producers = $ymovie->producers;

	for(@$producer) {
		print "$_->[0]: $_->[1]\n";
	}

directors()

Return a list of movie directors like pair: Yahoo Person ID, person name:

	my $directors = $ymovie->directors;

	for(@$directors) {
		print "$_->[0]: $_->[1]\n";
	}




ERROR METHODS

error()

Indicates if some error happened during retrieving of movie information:

	if($ym->error) {
		print "[ERROR] [".$ym->error."] ".ym->error_msg."!\n";
		exit(0);
	}

error_msg()

Contains an error description:

	print "ERROR: ".$ym->error_msg."!\n";	

EXAMPLE

Top

	#!/usr/bin/perl -w

	use strict;
	use warnings;

	use WWW::Yahoo::Movies;

	my $title = shift || 'troy';

	my $matched = get_movie_info($title, 1);

	for(@$matched) {
		print "\nGet [$_->{title}] ...\n";
		get_movie_info($_->{id});
	}

	sub get_movie_info {
		my $title = shift;
		my $ret_match = shift || 0;

		my $ym = new WWW::Yahoo::Movies(id => $title);

		print "Get info about [$title] ...";

		print "\n\tID: ".$ym->id;
		print "\n\tTITLE: ".$ym->title;
		print "\n\tYEAR: ".$ym->year;
		print "\n\tMPAA: ".$ym->mpaa_rating;
		print "\n\tCOVER: ".$ym->cover_file;
		print "\n\tPLOT: ".substr($ym->plot_summary, 0, 90)." ...";
		print "\n\tDATE: ".$ym->release_date;
		print "\n\tDISTR: ".$ym->distributor;
		print "\n\tGENRES: ".join(", ", @{ $ym->genres }) if $ym->genres;

		return $ym->matched if $ret_match;
	}	

EXPORT

Top

None by default.

SEE ALSO

Top

IMDB::Film

AUTHOR

Top

Michael Stepanov, <stepanov.michael@gmail.com<gt>

COPYRIGHT AND LICENSE

Top


WWW-Yahoo-Movies documentation  | view source Contained in the WWW-Yahoo-Movies distribution.