<?php
include 'config.php';
require ("imdb.class.php");
// This script uses IMDB info classes, available separately on Sourceforge. The only edit made was commenting lines 108-110 in the main class, which were giving a lot of errors in the php.log
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Match movie files to IMDB entries</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
if (isset($_POST['Submit']))
{
$searchagain = 0;
$sql_ids = '';
$moviename = '';
for ($i = 0; $i < $_POST[max_i]; $i++)
{
if ($_POST[actions.$i] == "usematch")
{
// use match
$sql = "insert into movie_name_imdb (movie_scanresults_id,movie_title,imdb_ref) values (".$_POST[scanid.$i].",'".$_POST[imdb_title.$i]."','".$_POST[imdbid.$i]."')";
mysql_query($sql);
}
elseif ($_POST[actions.$i] == "search")
{
// search using new value
$searchagain = 1;
$sql_ids .= $_POST[scanid.$i].",";
$moviename .= $_POST[moviename.$i]."||";
}
elseif ($_POST[actions.$i] == "skip")
{
$sql = "insert into movie_name_imdb (movie_scanresults_id,imdb_ref) values (".$_POST[scanid.$i].",'xxxxxxxx')";
mysql_query($sql);
}
else
{
// do nothing
};
};
};
if ($searchagain == 1)
{
echo "<h1>Retry list</h1>";
$sql_ids = rtrim ($sql_ids,',');
$sql = "select id,filename from movie_scanresults where id in (".$sql_ids.")";
$retry_names = explode("||", $moviename);
}
else
{
$sql = "select id,filename from movie_scanresults where id not in (select movie_scanresults_id from movie_name_imdb) and id not in (select child_id from movie_matches) order by filename limit 0,5";
};
// we're selecting movies that are not already done and that are not children of other movies (such as CD2s etc.,)
$results = mysql_query($sql);
$i = 0;
echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"POST\">";
while($row = mysql_fetch_assoc($results))
{
echo "<div class=\"movie_link\">";
if ($searchagain ==1)
{
$onlyname = $retry_names[$i];
}
else
{
$onlyname = RemoveExtension($row[filename]);
};
echo "<p>".$onlyname."</p>";
$search = new imdbsearch ();
$search->setsearchname ($onlyname);
$imdb_results = $search->results ();
echo "
<input type=\"hidden\" name=\"scanid".$i."\" value=\"".$row[id]."\" />
Movie name:
<input type=\"text\" name=\"moviename".$i."\" value=\"".$onlyname."\" size=\"50\" />
<br />
IMDB matches:
<br />";
$j = 0;
foreach ($imdb_results as $res) {
echo "<input type=\"radio\" name=\"imdbid".$i."\" value=\"";
echo $res->imdbid();
echo "\"";
if ($j ==0)
{
echo " checked='checked' ";
};
echo " />";
echo "<a target='_blank' href='http://www.imdb.com/title/tt".$res->imdbid()."/'>".$res->title()." (".$res->year().")</a> --> click link to check (opens in new window)<br />
<input type=\"hidden\" name=\"imdb_title".$i."\" value=\"".$res->title()."\" />
";
if ($j==4)
{
break;
};
$j++;
};
echo "Action:
<input type=\"radio\" name=\"actions".$i."\" value=\"usematch\" checked='checked' /> Use selected IMDB match
<input type=\"radio\" name=\"actions".$i."\" value=\"search\" /> Search again
<input type=\"radio\" name=\"actions".$i."\" value=\"skip\" /> Skip
<br />
</div>
";
$i++;
};
echo "<input type=\"hidden\" name=\"max_i\" value=\"".$i."\" />
<input type=\"submit\" value=\"Go\" name=\"Submit\" /></form>";
?>