function getOddGames() { global $pdo; $res = $pdo->query(' SELECT searchname, id, categoryid FROM releases WHERE nzbstatus = 1 AND gamesinfo_id = 0 AND categoryid BETWEEN 4010 AND 4020 ORDER BY postdate DESC LIMIT 150'); if ($res !== false) { $pdo->log->doEcho($pdo->log->header("Processing... 150 release(s).")); $gen = new Games(['Echo' => true, 'Settings' => $pdo]); //Match on 78% title $gen->matchPercentage = 78; foreach ($res as $arr) { $startTime = microtime(true); $usedgb = true; $gameInfo = $gen->parseTitle($arr['searchname']); if ($gameInfo !== false) { $pdo->log->doEcho($pdo->log->headerOver('Looking up: ') . $pdo->log->primary($gameInfo['title'])); // Check for existing games entry. $gameCheck = $gen->getGamesInfoByName($gameInfo['title']); if ($gameCheck === false) { $gameId = $gen->updateGamesInfo($gameInfo); $usedgb = true; if ($gameId === false) { $gameId = -2; //If result is empty then set gamesinfo_id back to 0 so we can parse it at a later time. if ($gen->maxHitRequest === true) { $gameId = 0; } } } else { $gameId = $gameCheck['id']; } if ($gameId != -2 && $gameId != 0) { $arr['categoryid'] = 4050; } $pdo->queryExec(sprintf('UPDATE releases SET gamesinfo_id = %d, categoryid = %d WHERE id = %d', $gameId, $arr['categoryid'], $arr['id'])); } else { // Could not parse release title. $pdo->queryExec(sprintf('UPDATE releases SET gamesinfo_id = %d WHERE id = %d', -2, $arr['id'])); echo '.'; } // Sleep so not to flood giantbomb. $diff = floor((microtime(true) - $startTime) * 1000000); if ($gen->sleepTime * 1000 - $diff > 0 && $usedgb === true) { usleep($gen->sleepTime * 1000 - $diff); } } } else { $pdo->log->doEcho($pdo->log->header('No games in 0day/ISO to process.')); } }
//This script will update all records in the gamesinfo table require_once dirname(__FILE__) . '/../../../www/config.php'; use nzedb\Games; use nzedb\db\Settings; $pdo = new Settings(); $game = new Games(['Echo' => true, 'Settings' => $pdo]); $res = $pdo->query(sprintf("SELECT id, title FROM gamesinfo WHERE cover = 0 ORDER BY id DESC LIMIT 100")); $total = count($res); if ($total > 0) { echo $pdo->log->header("Updating game covers for " . number_format($total) . " releases."); foreach ($res as $arr) { $starttime = microtime(true); $gameInfo = $game->parseTitle($arr['title']); if ($gameInfo !== false) { echo $pdo->log->primary('Looking up: ' . $gameInfo['release']); $gameData = $game->updateGamesInfo($gameInfo); if ($gameData === false) { echo $pdo->log->primary($gameInfo['release'] . ' not found'); } else { if (file_exists(nZEDb_COVERS . 'games' . DS . $gameData . '.jpg')) { $pdo->queryExec(sprintf('UPDATE gamesinfo SET cover = 1 WHERE id = %d', $arr['id'])); } } } // amazon limits are 1 per 1 sec $diff = floor((microtime(true) - $starttime) * 1000000); if (1000000 - $diff > 0) { echo $pdo->log->alternate("Sleeping"); usleep(1000000 - $diff); } }