NAME

IMDB::Film - OO Perl interface to the movies database IMDB.

VERSION

IMDB::Film 0.18

SYNOPSIS

use IMDB::Film;

#
# Retrieve a movie information by its IMDB code
#
my $imdbObj = new IMDB::Film(crit => 227445);

or

#
# Retrieve a movie information by its title
#
my $imdbObj = new IMDB::Film(crit => 'Troy');

or

#
# Parse already stored HTML page from IMDB
#
my $imdbObj = new IMDB::Film(crit => 'troy.html');

if($imdbObj->status) {
	print "Title: ".$imdbObj->title()."\n";
	print "Year: ".$imdbObj->year()."\n";
	print "Plot Symmary: ".$imdbObj->plot()."\n";
} else {
	print "Something wrong: ".$imdbObj->error;
}

DESCRIPTION

Overview

IMDB::Film is an object-oriented interface to the IMDB. You can use that module to retrieve information about film: title, year, plot etc.

Constructor and initialization

new()

Object's constructor. You should pass as parameter movie title or IMDB code.

my $imdb = new IMDB::Film(crit => <some code>);

or

my $imdb = new IMDB::Film(crit => <some title>);

or my $imdb = new IMDB::Film(crit => <HTML file>);

Also, you can specify following optional parameters:

- proxy - define proxy server name and port; - debug - switch on debug mode. Can be 0 or 1 (0 by default); - cache - cache or not of content retrieved pages. Can be 0 or 1 (0 by default); - timeout - timeout for HTTP connection in seconds (10 sec by default); - user_agent - specify an user agent ('Mozilla/5.0' by default).

my $imdb = new IMDB::Film(	crit		=> 'Troy',
							user_agent	=> 'Opera/8.x',
							timeout		=> 2,
							debug		=> 1,
							cache		=> 1
						);
						

For more infomation about base methods refer to IMDB::BaseClass.

_init()

Initialize object.

full_plot_url()

Define a full plot movie url.

Object Private Methods

_search_film()

Implemets functionality to search film by name.

_get_simple_prop()

Retrieve a simple movie property which surrownded by <B>.

Object Public Methods

title()

Retrieve film title from film page. If was got search page instead of film page this method calls method _search_film to get list matched films and continue to process first one:

my $title = $film->title();
year()

Get film year:

my $year = $film->year();
cover()

Retrieve url of film cover:

my $cover = $film->cover();
directors()

Retrieve film directors list each element of which is hash reference - { id => <ID>, name => <Name> }:

my @directors = @{ $film->directors() };
writers()

Retrieve film writers list each element of which is hash reference - { id => <ID>, name => <Name> }:

my @writers = @{ $film->writers() };

<I>Note: this method returns Writing credits from movie main page. It maybe not contain a full list!</I>

genres()

Retrieve film genres list:

my @genres = @{ $film->genres() };
tagline()

Retrieve film tagline:

my $tagline = $film->tagline();
plot()

Retrieve film plot summary:

my $plot = $film->plot();
rating()

In scalar context returns film user rating, in array context returns film rating and number of votes:

my $rating = $film->rating();

or

my($rating, $vnum) = $film->rating();
print "RATING: $rating ($vnum votes )";
cast()

Retrieve film cast list each element of which is hash reference - { id => <ID>, name => <Full Name>, role => <Role> }:

my @cast = @{ $film->cast() };

<I> Note: this method retrieves a cast list first billed only! </I>

duration()

Retrieve film duration in minutes:

my $duration = $film->duration();
country()

Retrieve film produced countries list:

my @countries = $film->country();
language()

Retrieve film languages list:

my @languages = $film->language();
also_known_as()

Retrieve AKA information as array, each element of which is string:

my $aka = $film->also_known_as();

print map { "$_\n" } @$aka;
trivia()

Retrieve a movie trivia:

my $trivia = $film->trivia();
goofs()

Retrieve a movie goofs:

my $goofs = $film->goofs();
awards()

Retrieve a general information about movie awards like 1 win & 1 nomination:

my $awards = $film->awards();
summary()

Retrieve film user summary:

my $descr = $film->summary();
certifications()

Retrieve list of film certifications each element of which is hash reference - { country => certificate }:

my @cert = $film->certifications();
full_plot

Return full movie plot.

my $full_plot = $film->full_plot();

Class Variables

%FIELDS

Contains list all object's properties. See description of pragma fields.

@FILM_CERT

Matches USA film certification notation and age.

EXPORTS

Nothing

HOWTO CACTH EXCEPTIONS

If it's needed to get information from IMDB for a list of movies in some case it can be returned critical error:

[CRITICAL] Cannot retrieve page: 500 Can't read entity body ...

To catch an exception can be used eval:

	for my $search_crit ("search_crit1", "search_crit2", ..., "search_critN") {
    	my $ret;
    	eval {
        	$ret = new IMDB::Film(crit => "$search_crit") || print "UNKNOWN ERROR\n";
    	};

    	if($@) {
        	# Opsssss! We got an exception!
        	print "EXCEPTION: $@!";
        	next;
    	}
	}

BUGS

Please, send me any found bugs by email: stepanov.michael@gmail.com or create a bug report: http://rt.cpan.org/NoAuth/Bugs.html?Dist=IMDB-Film

SEE ALSO

IMDB::Persons IMDB::BaseClass WWW::Yahoo::Movies IMDB::Movie HTML::TokeParser

AUTHOR

Michael Stepanov (stepanov.michael@gmail.com)

COPYRIGHT

Copyright (c) 2004 - 2005, Michael Stepanov. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.