NAME
WWW::Yahoo::Movies - Perl extension to get Yahoo! Movies information.
SYNOPSIS
use WWW::Yahoo::Movies;
my $movie = new WWW::Yahoo::Movies();
print "TITLE: ".$movie->title." - ".$movie->year."\n";
DESCRIPTION
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:
my $mpaa = $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()
-
Duration of Yahoo! movie:
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();
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
#!/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
None by default.
SEE ALSO
IMDB::Film
AUTHOR
Michael Stepanov, <stepanov.michael@gmail.com<gt>
COPYRIGHT AND LICENSE
Copyright (C) 2005 by Michael Stepanov
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.