예제 #1
0
파일: getGames.php 프로젝트: Jay204/nZEDb
<?php

//This script will update all records in the gamesinfo table
require_once dirname(__FILE__) . '/../../../www/config.php';
$pdo = new nzedb\db\Settings();
$game = new Games(['Echo' => true, 'Settings' => $pdo]);
$res = $pdo->query(sprintf("SELECT searchname FROM releases WHERE gamesinfo_id IS NULL AND categoryid = 4050 ORDER BY id DESC LIMIT 100"));
$total = count($res);
if ($total > 0) {
    echo $pdo->log->header("Updating game info for " . number_format($total) . " releases.");
    foreach ($res as $arr) {
        $starttime = microtime(true);
        $gameInfo = $game->parseTitle($arr['searchname']);
        if ($gameInfo !== false) {
            $gameData = $game->updateGamesInfo($gameInfo);
            if ($gameData === false) {
                echo $pdo->log->primary($gameInfo['release'] . ' not found');
            }
        }
        // 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);
        }
    }
}
예제 #2
-7
파일: gamesorter.php 프로젝트: Jay204/nZEDb
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.'));
    }
}