mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 02:01:33 +00:00
Move colorcli class to helpers
This commit is contained in:
@@ -5,28 +5,28 @@
|
||||
require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php';
|
||||
|
||||
use App\Services\GamesService;
|
||||
use Blacklight\ColorCLI;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
$pdo = DB::connection()->getPdo();
|
||||
$game = new GamesService;
|
||||
$colorCli = new ColorCLI;
|
||||
|
||||
|
||||
$res = $pdo->query(
|
||||
sprintf('SELECT id, title FROM gamesinfo WHERE cover = 0 ORDER BY id DESC LIMIT 100')
|
||||
);
|
||||
$total = $res->rowCount();
|
||||
if ($total > 0) {
|
||||
$colorCli->header('Updating game covers for '.number_format($total).' releases.');
|
||||
cli()->header('Updating game covers for '.number_format($total).' releases.');
|
||||
|
||||
foreach ($res as $arr) {
|
||||
$starttime = now()->timestamp;
|
||||
$gameInfo = $game->parseTitle($arr['title']);
|
||||
if ($gameInfo !== false) {
|
||||
$colorCli->primary('Looking up: '.$gameInfo['release']);
|
||||
cli()->primary('Looking up: '.$gameInfo['release']);
|
||||
$gameData = $game->updateGamesInfo($gameInfo);
|
||||
if ($gameData === false) {
|
||||
$colorCli->primary($gameInfo['release'].' not found');
|
||||
cli()->primary($gameInfo['release'].' not found');
|
||||
} else {
|
||||
if (file_exists(storage_path('covers/games/').$gameData.'.jpg')) {
|
||||
$pdo->exec(sprintf('UPDATE gamesinfo SET cover = 1 WHERE id = %d', $arr['id']));
|
||||
@@ -37,7 +37,7 @@ if ($total > 0) {
|
||||
// Rate limiting - 1 per second
|
||||
$diff = floor((now()->timestamp - $starttime) * 1000000);
|
||||
if (1000000 - $diff > 0) {
|
||||
$colorCli->alternate('Sleeping');
|
||||
cli()->alternate('Sleeping');
|
||||
usleep(1000000 - $diff);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user