changes to grapper wip
This commit is contained in:
1 parent
361e5ed3ed
commit
9214da8a15
9 files changed
+445
-201
No files matched your search
@@ -3,6 +3,7 @@
|
||||
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\Nuh;
|
||||
@@ -17,8 +18,11 @@ use Illuminate\Support\Carbon;
|
||||
class Sofascore
|
||||
{
|
||||
public static $auth_header = [];
|
||||
|
||||
public static $base_url = '';
|
||||
|
||||
public static $_days = [];
|
||||
|
||||
public static $sport = [1];
|
||||
|
||||
public static function switch()
|
||||
@@ -35,13 +39,14 @@ class Sofascore
|
||||
|
||||
if (Nuh::$options['t']) {
|
||||
self::$_days[] = Carbon::now()->format('Y-m-d');
|
||||
} else if (Nuh::$options['day']) {
|
||||
if (self::validateDate(Nuh::$options['day'])) {
|
||||
self::$_days[] = Nuh::$options['day'];
|
||||
} 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);
|
||||
Notice::note('date not valid '.Nuh::$options['day'], 'r', 1);
|
||||
}
|
||||
} else if (Nuh::$options['days']) {
|
||||
} elseif (Nuh::$options['days']) {
|
||||
$to = Carbon::now()->subDays(Nuh::$options['days']);
|
||||
$from = Carbon::now()->subDay();
|
||||
while ($from >= $to) {
|
||||
@@ -51,9 +56,9 @@ class Sofascore
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(Nuh::$options['sport'] . ' ' . Nuh::$options['name'], 'bb');
|
||||
Notice::note(Nuh::$options['sport'].' '.Nuh::$options['name'], 'bb');
|
||||
}
|
||||
|
||||
|
||||
switch (Nuh::$options['name']) {
|
||||
case 'TOURNAMENTS':
|
||||
Tournament::load();
|
||||
@@ -61,6 +66,9 @@ class Sofascore
|
||||
case 'EVENTS':
|
||||
Events::load();
|
||||
break;
|
||||
case 'EVENTSDB':
|
||||
EventsDatabase::load();
|
||||
break;
|
||||
case 'SPECIAL':
|
||||
Special::load();
|
||||
break;
|
||||
@@ -73,7 +81,13 @@ class Sofascore
|
||||
|
||||
public static function validateDate($date, $format = 'Y-m-d')
|
||||
{
|
||||
if (is_numeric($date)) {
|
||||
$date = date('Y').'-'.date('m').'-'.$date;
|
||||
}
|
||||
$d = DateTime::createFromFormat($format, $date);
|
||||
return $d && $d->format($format) == $date;
|
||||
|
||||
if ($d && $d->format($format) == $date) {
|
||||
return $d->format($format);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user