* @version $Id: add_recommended_movies.php,v 1.8 2014/02/25 21:22:00 kec2 Exp $
*/
// move out of contrib for includes
chdir('..');
require_once './core/functions.php';
require_once './engines/engines.php';
// since we don't need session functionality, use this as workaround
// for php bug #22526 session_start/popen hang
session_write_close();
?>
Find Movie Recommendations
error_reporting(E_ALL ^ E_NOTICE);
if ($submit)
{
// validate form data
$required_rating = (is_numeric($required_rating)) ? (float) $required_rating : '';
$required_year = (is_numeric($required_year)) ? (int) $required_year : '';
// get list of all videos
$SQL = 'SELECT * FROM '.TBL_DATA;
if (empty($wishlist)) $SQL .= ' WHERE mediatype != '.MEDIA_WISHLIST;
$result = runSQL($SQL);
foreach ($result as $video)
{
if (empty($video['imdbID'])) continue;
$engine = strtoupper(engineGetEngine($video['imdbID']));
echo "Fetching recommendations for {$video['title']} ($engine Id {$video['imdbID']})
";
$data = engineGetRecommendations($video['imdbID'], $required_rating, $required_year, 'imdb');
if (!empty($CLIENTERROR))
{
echo $CLIENTERROR."
";
continue;
}
if (empty($data))
{
// sometimes there are no recommendations for a movie. This is true for Underworld: imdbId 0320691
echo "No recommendations for {$video['title']}.
";
continue;
}
echo '';
echo " ";
echo " | Title | Year | Rating | Id | ";
echo "
";
foreach ($data as $recommended)
{
$available = (count(runSQL("SELECT * FROM ".TBL_DATA." WHERE imdbID like '%".$recommended['id']."'")) > 0);
if (!$available)
{
$recommended['title'] = ''.$recommended['title'].'
';
}
echo "";
echo "| {$recommended['title']} | ";
echo "{$recommended['year']} | ";
echo "{$recommended['rating']} | ";
echo "{$recommended['id']} | ";
echo "
";
if ($download && !$available) engineGetData($recommended['id']);
}
echo "
";
echo "
";
}
}
else
{
?>
}
?>