<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* class.imdb_parser.php (php4)
* Parse information of any film - need a fetched imdb.com video-detail-site
* @author Bernd Essl <hide@address.com>
* @copyright Bernd Essl <hide@address.com>
* @license license http://gnu.org/copyleft/gpl.html GNU GPL
* @version SVN: 4
* @link http://ak-47.at/
*/
class IMDB_Parser
{
function getMovieActors($imdb_website)
{
if (preg_match('/<b class="blackcatheader">Cast overview, first billed only:(.+)<a href="fullcredits">\(more\)<\/a>/', $imdb_website, $hit))
{
if (preg_match_all('/<a href="\/name\/nm\d{1,8}\/">([^<]+)<\/a>/',$hit[0],$results, PREG_PATTERN_ORDER))
{
return $results[1];
}
else
{
return FALSE;
}
}
else
{
return FALSE;
}
}
function getMovieDirectedBy($imdb_website)
{
if (preg_match( '/<b class="blackcatheader">Directed by<\/b><br>.?<a href="\/name\/[a-z0-9]+\/">(.+)<\/a><br>/sU', $imdb_website, $hit))
{
return $hit[1];
}
else
{
return FALSE;
}
}
function getMovieColor($imdb_website)
{
if (preg_match('/<a href="\/List\?color-info=.+">(.+)<\/a>/', $imdb_website, $hit))
{
return $hit[1];
}
else
{
return FALSE;
}
}
function getMovieCountry($imdb_website)
{
if (preg_match_all('/<a href="\/Sections\/Countries\/([a-z]+)\/">/i',$imdb_website,$results, PREG_PATTERN_ORDER))
{
return $results[1];
}
else
{
return FALSE;
}
}
function getMovieLanguage($imdb_website)
{
if (preg_match_all('/<a href="\/Sections\/Languages\/([a-z]+)\/">/i',$imdb_website,$results, PREG_PATTERN_ORDER))
{
return $results[1];
}
else
{
return FALSE;
}
}
function getMovieRating($imdb_website)
{
if (preg_match('/<b>([0-9]{1,2}\.[0-9]{1,2})\/10<\/b> \(.+ votes\)/', $imdb_website, $hit))
{
return $hit[1];
}
else
{
return FALSE;
}
}
function getMovieGenres($imdb_website)
{
if (preg_match_all('/\/Sections\/Genres\/(.+?)\//', $imdb_website, $hit, PREG_PATTERN_ORDER))
{
return $hit[1];
}
else
{
return FALSE;
}
}
function getMoviePlot($imdb_website)
{
//sometimes "Plot Outline" or "Plot Summary"
if (preg_match('/\<b class="ch"\>(Plot Outline|Plot Summary):\<\/b\> ([^"]*)\<a href=/', $imdb_website, $hit))
{
return $hit['2'];
}
else
{
return FALSE;
}
}
function getMovieTagline($imdb_website)
{
if (preg_match('/\<b class="ch"\>Tagline:\<\/b\> ([^"]*)\<a href=/', $imdb_website, $hit))
{
return $hit[1];
}
else
{
return FALSE;
}
}
function getMovieTitle($imdb_website)
{
if (preg_match('/\<title\>([^"]*)\<\/title\>/', $imdb_website, $hit))
{
return $hit[1];
}
else
{
return FALSE;
}
}
function getMoviePictureHtml($imdb_website)
{
if (preg_match('/<a name="poster".+title=".+">(.+)<\/a>/', $imdb_website, $hit))
{
return $hit[1];
}
else
{
return FALSE;
}
}
function getMoviePicture($imdb_website)
{
if (preg_match('/ src="([^"]*)/', $this->getMoviePictureHtml($imdb_website), $hit))
{
return $hit[1];
}
else
{
return FALSE;
}
}
}
?>