This code should fetch Rating, Genres, Tagline and Poster.
Please help
function getMovieRating($imdb_website)
{
if (preg_match('/<b>([0-9]{1,2}\.[0-9]{1,2})\/10<\/b>/', $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 "a";
}
}
function getMovieTagline($imdb_website)
{
if (preg_match('#Tagline:</h5>(.*?)<#s', $imdb_website, $hit))
{
return $hit[1];
}
else
{
return FALSE;
}
}
function imdb2pic($imdb, $id, $poster = 1)
{
if(strpos($imdb, "imdb.com"))
{
$imdb = trim($imdb);
$nisse = True;
$tmpfile = "weee.txt";
shell_exec("wget -O $tmpfile $imdb");
$fp = fopen($tmpfile, "rt");
while(!feof($fp))
{
$buffer = fgets($fp);
$buf .= $buffer;
}
$hej = $buf;
@unlink($tmpfile);
$pos1 = strpos($hej, '<a name="poster"');
$hej = substr($hej,$pos1);
$pos1 = strpos($hej, 'src="');
$hej = substr($hej, $pos1+5);
$pos1 = strpos($hej, '"');
$hej = substr($hej,0, $pos1);
foreach(getMovieGenres($buf) as $value)
{
$kk = gen2bok($value);
if($kk != $genrelist[0])
$genrelist .= $kk;
}
$tagg = getMovieTagline($buf);
//echo $genrelist;
$tagg = str_replace("<br>","", $tagg);
$tagg = str_replace("\n","", $tagg);
$tagg = sqlesc($tagg);
//echo getMovieRating($buf);
$query = "UPDATE torrents set imdburl = '".$imdb."', genres = '".$genrelist."', tagline = ".$tagg.", imdbrating = '".getMovieRating($buf)."' WHERE id = $id";
//echo $query;
mysql_query($query);
if(substr($hej,0, 10) == "http://ser" || $hej == "" || strpos($hej, "48.jpg") > 0 || substr($hej,- == "logo.gif")
{
return 0;
}
if($poster){
@unlink("imdbpics/".$id.".jpg");
shell_exec("wget -O imdbpics/".$id.".jpg $hej");
if(filesize("imdbpics/".$id.".jpg") == 4728)
return 0;
}
return 1;
}
return 0;
}
// G?r om h?mtade genres fr?n imdb till tecken.
function gen2bok($value)
{
switch($value)
{
case "Action":
return "a";
case "Comedy":
return "b";
case "Family":
return "c";
case "History":
return "d";
case "Mystery":
return "e";
case "Sci-Fi":
return "f";
case "Thriller":
return "g";
case "Adventure":
return "h";
case "Crime":
return "i";
case "Fantasy":
return "j";
case "Horror":
return "k";
case "News":
return "l";
case "Short":
return "m";
case "War":
return "n";
case "Animation":
return "o";
case "Documentary":
return "p";
case "Film-Noir":
return "q";
case "Music":
return "r";
case "Reality-TV":
return "s";
case "Sport":
return "t";
case "Western":
return "u";
case "Biography":
return "v";
case "Drama":
return "w";
case "Game-Show":
return "x";
case "Musical":
return "y";
case "Romance":
return "z";
case "Talk-Show":
return "1";
case "Adult":
return "2";
default:
return "";
}
}
// G?r om tecken fr?n mysql-taballen till IMDB Genres.
function bok2gen($value)
{
switch($value)
{
case "a":
return "Action";
case "b":
return "Comedy";
case "c":
return "Family";
case "d":
return "History";
case "e":
return "Mystery";
case "f":
return "Sci-Fi";
case "g":
return "Thriller";
case "h":
return "Adventure";
case "i":
return "Crime";
case "j":
return "Fantasy";
case "k":
return "Horror";
case "l":
return "News";
case "m":
return "Short";
case "n":
return "War";
case "o":
return "Animation";
case "p":
return "Documentary";
case "q":
return "Film-Noir";
case "r":
return "Music";
case "s":
return "Reality-TV";
case "t":
return "Sport";
case "u":
return "Western";
case "v":
return "Biography";
case "w":
return "Drama";
case "x":
return "Game-Show";
case "y":
return "Musical";
case "z":
return "Romance";
case "1":
return "Talk-Show";
case "2":
return "Adult";
default:
return "";
}
}