function store_torrent($imdb_id, $hd = "", $full_hd = "") { global $conn, $table_name; if (get_torrent($imdb_id)) { $sql = "UPDATE " . $table_name . " SET imdb_id='{$imdb_id}', 720p='{$hd}', 1080p='{$full_hd}', last_check_unixtime='" . time() . "' WHERE imdb_id='{$imdb_id}'"; } else { $sql = "INSERT INTO " . $table_name . " (imdb_id, 720p, 1080p, last_check_unixtime) VALUES ('" . $imdb_id . "', '" . $hd . "', '" . $full_hd . "', '" . time() . "')"; } return mysqli_query($conn, $sql); }
require_once './database_helper.php'; if (!isset($_GET["list_id"])) { require_once './default.html'; die; } $list_id = $_GET["list_id"]; $quality = $_GET["quality"]; $list_title = ''; $API_CALL_INTERVAL = 86400; //in seconds, 86400 for 1 day $arr = imdbFeedToArray('http://rss.imdb.com/list/' . $list_id . '/'); $array = array(); foreach ($arr as $entry) { //First we check if we aready have this movie on db. $stored = get_torrent($entry['imdbID']); if ($stored) { //We do! :) $stored['pubDate'] = $entry['pubDate']; $stored['title'] = $entry['title']; if ($stored['720p'] && $stored['1080p'] || $stored['last_check_unixtime'] > time() - $API_CALL_INTERVAL) { array_push($array, $stored); continue; } } //If not: $entry_info = getYify($entry['imdbID']); if ((int) $entry_info['data']['movie_count'] < 1) { store_torrent($entry['imdbID']); //Store the id only, so we call to check the API again only after a period of time. continue;