| IMDB::Film(3pm) | User Contributed Perl Documentation | IMDB::Film(3pm) |
IMDB::Film - OO Perl interface to the movies database IMDB.
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;
}
IMDB::Film is an object-oriented interface to the IMDB. You can use that module to retrieve information about film: title, year, plot etc.
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>);
For more infomation about base methods refer to IMDB::BaseClass.
my $imdbObj = new IMDB::Film(crit => 'Jack', year => 2003);
print "Got #" . $imdbObj->code . " " . $imdbObj->title . "\n"; #0379836
proxy => 'http://proxy.myhost.com:80'
By default object tries to get proxy from environment
Example:
my $imdb = new IMDB::Film( crit => 'Troy',
user_agent => 'Opera/8.x',
timeout => 2,
debug => 1,
cache => 1,
cache_root => '/tmp/imdb_cache',
cache_exp => '1 d',
);
It'll create an object with critery 'Troy', user agent 'Opera', timeout 2 seconds, debug mode on, using cache with directory '/tmp/imdb_cache' and expiration time in 1 day.
0 - empty object; 1 - loaded from file; 2 - loaded from internet request; 3 - loaded from cache.
if($film->status) {
print "This is a " . $film->status_descr . " object!";
} else {
die "Cannot retrieve IMDB object!";
}
my $title = $film->title();
my $kind = $film->kind();
Possible values are: 'movie', 'tv series', 'tv mini series', 'video game', 'video movie', 'tv movie', 'episode'.
my $year = $film->year();
{
follows => [ { id => <id>, title => <name>, year => <year>, ..., } ],
followed_by => [ { id => <id>, title => <name>, year => <year>, ..., } ],
references => [ { id => <id>, title => <name>, year => <year>, ..., } ],
referenced_in => [ { id => <id>, title => <name>, year => <year>, ..., } ],
featured_in => [ { id => <id>, title => <name>, year => <year>, ..., } ],
spoofed_by => [ { id => <id>, title => <name>, year => <year>, ..., } ],
}
my %connections = %{ $film->connections() };
{
production => [ { name => <company name>, url => <imdb url>, extra => <specific task> } ],
distributors => [ { name => <company name>, url => <imdb url>, extra => <specific task> } ],
special_effects => [ { name => <company name>, url => <imdb url>, extra => <specific task> } ],
other => [ { name => <company name>, url => <imdb url>, extra => <specific task> } ],
}
my %full_companies = %{ $film->full_companies() };
my $company = $film->company();
or
my @companies = $film->company();
my @episodes = @{ $film->episodes() };
my @tvseries = @{ $film->episodeof() };
my $cover = $film->cover();
$recommendation_movies = $film->recommendation_movies();
For example, the list of recommended movies for Troy will be similar to that:
__DATA__
$VAR1 = {
'0416449' => '300',
'0167260' => 'The Lord of the Rings: The Return of the King',
'0442933' => 'Beowulf',
'0320661' => 'Kingdom of Heaven',
'0172495' => 'Gladiator'
};
my @directors = @{ $film->directors() };
my @writers = @{ $film->writers() };
<I>Note: this method returns Writing credits from movie main page. It maybe not contain a full list!</I>
my @genres = @{ $film->genres() };
my $tagline = $film->tagline();
my $plot = $film->plot;
my $storyline = $film->storyline();
my $rating = $film->rating();
or
my($rating, $vnum, $avards) = $film->rating();
print "RATING: $rating ($vnum votes)";
Note, that $avards is array reference where the first elemen is a TOP info if so, and the next element is other avards - Oscar, nominations and etc
my @cast = @{ $film->cast() };
<I> Note: this method retrieves a cast list first billed only! </I>
my $duration = $film->duration();
In array context it retrieves all movie's durations:
my @durations = $film->duration();
my $countries = $film->country();
my $languages = $film->language();
my $aka = $film->also_known_as();
print map { "$_\n" } @$aka;
my $trivia = $film->trivia();
my $goofs = $film->goofs();
my $awards = $film->awards();
my mpaa = $film->mpaa_info();
my $aspect_ratio = $film->aspect_ratio();
my $descr = $film->summary();
my @cert = $film->certifications();
my $full_plot = $film->full_plot();
my $sites = $film->official_sites();
for(@$sites) {
print "Site name - $_->{title}; url - $_->{url}\n";
}
my $sites = $film->release_dates();
for(@$sites) {
print "Country - $_->{country}; release date - $_->{date}; info - $_->{info}\n";
}
Option info contains additional information about release - DVD premiere, re-release, restored version etc
my $plot_keywords = $film->plot_keywords();
for my $keyword (@$plot_keywords) {
print "keyword: $keyword\n";
}
Nothing
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;
}
}
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
IMDB::Persons IMDB::BaseClass WWW::Yahoo::Movies IMDB::Movie HTML::TokeParser
http://videoguide.sf.net
Michael Stepanov AKA nite_man (stepanov.michael@gmail.com)
Copyright (c) 2004 - 2007, Michael Stepanov. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
Hey! The above document had some coding errors, which are explained below:
| 2021-01-07 | perl v5.32.0 |