wip
This commit is contained in:
1 parent
cd91e3b708
commit
c30aaa15fe
32 files changed
+365
-10160
No files matched your search
@@ -2,80 +2,73 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore\Events;
|
||||
use App\Console\Commands\Grapper\Sofascore\EventsDatabase;
|
||||
use App\Console\Commands\Grapper\Sofascore\Special;
|
||||
use App\Console\Commands\Grapper\Sofascore\Tournament;
|
||||
use App\Console\Commands\Grapper\Sofascore\CreateZip;
|
||||
use App\Console\Commands\Grapper\Sofascore\DaysTournament;
|
||||
use App\Console\Commands\Grapper\Sofascore\Grapper;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\TaskConfig;
|
||||
use App\Console\Commands\Grapper\Sofascore\PlayerPerSeason;
|
||||
use App\Console\Commands\Grapper\Sofascore\SendMail;
|
||||
use App\Console\Commands\Grapper\Sofascore\SettingsToLocal;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Utilities\Notice;
|
||||
use DateTime;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
ini_set('magic_quotes_runtime', false);
|
||||
|
||||
class Sofascore
|
||||
{
|
||||
public static $auth_header = [];
|
||||
|
||||
public static $base_url = '';
|
||||
|
||||
public static $_days = [];
|
||||
|
||||
public static $sport = [1];
|
||||
public static string $source_path;
|
||||
|
||||
public static string $storage_path;
|
||||
|
||||
public static function switch()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
self::$source_path = app_path('/Console/Commands/Grapper/Sofascore/Grapped');
|
||||
|
||||
if (Nuh::$options['t']) {
|
||||
self::$_days[] = Carbon::now()->format('Y-m-d');
|
||||
} elseif (Nuh::$options['day']) {
|
||||
$day = self::validateDate(Nuh::$options['day']);
|
||||
if ($day) {
|
||||
self::$_days[] = $day;
|
||||
} else {
|
||||
Notice::note('date not valid '.Nuh::$options['day'], 'r', 1);
|
||||
}
|
||||
} elseif (Nuh::$options['days']) {
|
||||
$to = Carbon::now()->subDays(Nuh::$options['days']);
|
||||
$from = Carbon::now()->subDay();
|
||||
while ($from >= $to) {
|
||||
self::$_days[] = $from->format('Y-m-d');
|
||||
$from->subDay();
|
||||
}
|
||||
}
|
||||
self::$storage_path = storage_path('zip_sofascore_data');
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(Nuh::$options['sport'] ?? 'All'.' '.Nuh::$options['name'], 'bb');
|
||||
}
|
||||
$task = Nuh::$options['task'] ?? 0;
|
||||
|
||||
switch (Nuh::$options['name']) {
|
||||
case 'TOURNAMENTS':
|
||||
Tournament::load();
|
||||
break;
|
||||
case 'EVENTS':
|
||||
Events::load();
|
||||
break;
|
||||
case 'EVENTSDB':
|
||||
EventsDatabase::load();
|
||||
break;
|
||||
case 'SPECIAL':
|
||||
Special::load();
|
||||
break;
|
||||
$process = Nuh::$options['run'];
|
||||
|
||||
$days = LoadDays::load($task);
|
||||
|
||||
switch($process){
|
||||
case 1:
|
||||
PlayerPerSeason::run();
|
||||
break;
|
||||
case 2:
|
||||
SettingsToLocal::run();
|
||||
break;
|
||||
case 3:
|
||||
if($days){
|
||||
CreateZip::run($days);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if($days){
|
||||
SendMail::run($days);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if($days){
|
||||
DaysTournament::run($days);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if($days){
|
||||
Grapper::load($days);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if($days){
|
||||
TaskConfig::set($task);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static function validateDate($date, $format = 'Y-m-d')
|
||||
{
|
||||
if (is_numeric($date)) {
|
||||
$date = date('Y').'-'.date('m').'-'.$date;
|
||||
}
|
||||
$d = DateTime::createFromFormat($format, $date);
|
||||
|
||||
if ($d && $d->format($format) == $date) {
|
||||
return $d->format($format);
|
||||
Notice::note('id not valid', 'br', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user