Files
nuhodds_fi4/app/Console/Commands/Grap.php
T
2026-09-22 23:25:12 +02:00

146 lines
4.4 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Console\Commands\Grapper\Sofascore\Grapper;
use App\Console\Commands\Grapper\Sofascore\GrapperTest;
use App\Console\Commands\Grapper\Sofascore\Helper\ClearDir;
use App\Console\Commands\Grapper\Sofascore\Helper\RemoveDir;
use App\Console\Commands\Grapper\Sofascore\Helper\SetStorage;
use App\Console\Commands\Grapper\Sofascore\MakeExcel;
use App\Console\Commands\Grapper\Sofascore\Rose;
use App\Console\Commands\Grapper\Sofascore\SendMail;
use App\Console\Commands\Grapper\Sofascore\SettingsToLocal;
use App\Console\Commands\Grapper\Sofascore\SqlMover;
use App\Utilities\Notice;
use Illuminate\Console\Command;
class Grap extends Command
{
public static $options = [];
public static string $storage;
public static string $zipfile;
public static string $folder;
public static string $excel;
public static string $useragent = '4';
protected $signature = 'grp {id=0} {day=0} {--date=} {--folder=} {--d} {--g} {--r} {--c} {--m} {--f} {--F} {--R} {--S}';
public function handle()
{
self::$options = $this->options();
self::$options['id'] = (int) $this->argument('id');
self::$options['day'] = (int) $this->argument('day');
self::$options['base_url'] = 'https://www.sofascore.com/';
if (! self::$options['id']) {
$txt = 'PARAMETERS' . PHP_EOL;
$txt .= '--d debug' . PHP_EOL;
$txt .= '--r restart range' . PHP_EOL;
$txt .= '--f force Events' . PHP_EOL;
$txt .= '--F force DayTournament links' . PHP_EOL;
$txt .= '--c clear grap dir' . PHP_EOL;
$txt .= '--m mail only' . PHP_EOL;
$txt .= '--g grap & excel only' . PHP_EOL;
$txt .= '--R read file' . PHP_EOL;
$txt .= '--S save to file' . PHP_EOL;
$txt .= '--folder' . PHP_EOL;
$txt .= '-----------------------------------------------------------' . PHP_EOL;
$txt .= 'FUNCTION' . PHP_EOL;
$txt .= ' 1 grapper DAILY & subDays ( default 3)' . PHP_EOL;
$txt .= ' 2 grapper MORE DAYS' . PHP_EOL;
$txt .= ' 3 grapper RANGE' . PHP_EOL;
$txt .= ' 4 grapper ROSE' . PHP_EOL;
$txt .= ' 5 import to excel from folder' . PHP_EOL;
$txt .= ' 7 settings to local' . PHP_EOL;
$txt .= ' 11 move SQL' . PHP_EOL;
$txt .= ' 12 testing url for grapping' . PHP_EOL;
Notice::note($txt, 'b', 1);
}
Notice::note('Task Id ' . self::$options['id'], 'gb');
switch (self::$options['id']) {
case 1:
// DAILY
SetStorage::set(1);
RemoveDir::remove();
// with --m just resend mail
if (! self::$options['m']) {
Grapper::load(1);
MakeExcel::create();
}
// with --g just grap & excel
if (! self::$options['g']) {
SendMail::run(1);
}
break;
case 2:
// LAST 3 DAYS
self::$options['f'] = 1;
if (self::$options['c']) {
SetStorage::set(1);
ClearDir::clear();
}
self::$options['day'] = 1;
SetStorage::set(1);
Grapper::load(1);
MakeExcel::create('day');
self::$options['day'] = 5;
SetStorage::set(1);
Grapper::load(1);
MakeExcel::create('day');
SendMail::run(1);
break;
case 3:
// RANGE
SetStorage::set(3);
Grapper::load(3);
MakeExcel::create();
break;
case 4:
// ROSE
SetStorage::set(4);
Rose::run();
MakeExcel::create();
break;
case 5:
SetStorage::set(5);
MakeExcel::create();
break;
case 7:
SettingsToLocal::run();
break;
case '11':
SqlMover::run();
break;
case '12':
GrapperTest::load();
break;
default:
Notice::note('function not implemented yet', 'br', 1);
}
}
}