wip
This commit is contained in:
1 parent
267b5b9583
commit
911b515021
15 files changed
+1048
-56
No files matched your search
@@ -47,9 +47,8 @@ class Grapper
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restart
|
||||
* Restart
|
||||
*/
|
||||
if ($restart) {
|
||||
|
||||
@@ -83,21 +82,21 @@ class Grapper
|
||||
Notice::note($tournament->sofa_score_tournament_id, 'bb');
|
||||
}
|
||||
|
||||
if (! $force)
|
||||
if (! $force) {
|
||||
Sleeper::rand(1);
|
||||
else
|
||||
} else {
|
||||
Sleeper::rand();
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note($day, 'br');
|
||||
}
|
||||
|
||||
$url = Grap::$options['base_url'] . "api/v1/unique-tournament/$tournament->sofa_score_tournament_id/scheduled-events/$day";
|
||||
$url = Grap::$options['base_url']."api/v1/unique-tournament/$tournament->sofa_score_tournament_id/scheduled-events/$day";
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
Notice::note($data, 'bb');
|
||||
|
||||
|
||||
if (isset($data['events'])) {
|
||||
|
||||
if ($debug) {
|
||||
@@ -110,7 +109,7 @@ class Grapper
|
||||
|
||||
if (! $force && SofaScoreEventGrapped::where('grapper_id', $task_id)->where('id', (int) $event['id'])->exists()) {
|
||||
if ($debug) {
|
||||
Notice::note('DB - Allready grapped at ' . $day . ' - ' . $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'], 'g');
|
||||
Notice::note('DB - Allready grapped at '.$day.' - '.$event['homeTeam']['name'].' vs '.$event['awayTeam']['name'], 'g');
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -124,17 +123,17 @@ class Grapper
|
||||
|
||||
// if ($now->greaterThan($starttime) && $starttime->isSameDay($carbon_day)) {
|
||||
|
||||
if (! $force)
|
||||
if (! $force) {
|
||||
Sleeper::rand(1);
|
||||
else
|
||||
} else {
|
||||
Sleeper::rand();
|
||||
|
||||
|
||||
if ($debug) {
|
||||
Notice::note($day . ' - ' . $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'], 'bg');
|
||||
}
|
||||
|
||||
$folder = strtolower(Grap::$storage . '/' . $day . '/' . $day . '-' . $event['tournament']['category']['slug'] . '-' . $event['tournament']['slug'] . '/' . $event['slug']);
|
||||
if ($debug) {
|
||||
Notice::note($day.' - '.$event['homeTeam']['name'].' vs '.$event['awayTeam']['name'], 'bg');
|
||||
}
|
||||
|
||||
$folder = strtolower(Grap::$storage.'/'.$day.'/'.$day.'-'.$event['tournament']['category']['slug'].'-'.$event['tournament']['slug'].'/'.$event['slug']);
|
||||
|
||||
File::makeDirectory($folder, 0775, true, true);
|
||||
|
||||
@@ -142,7 +141,7 @@ class Grapper
|
||||
* EVENT event
|
||||
*********************************/
|
||||
|
||||
File::put($folder . '/event.json', json_encode($event));
|
||||
File::put($folder.'/event.json', json_encode($event));
|
||||
|
||||
/*********************************
|
||||
* EVENT statistics
|
||||
@@ -150,7 +149,7 @@ class Grapper
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/statistics";
|
||||
$url = Grap::$options['base_url']."api/v1/event/$event_id/statistics";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
@@ -158,13 +157,13 @@ class Grapper
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder . '/statistics.json', json_encode($data));
|
||||
File::put($folder.'/statistics.json', json_encode($data));
|
||||
|
||||
/*********************************
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/lineups";
|
||||
$url = Grap::$options['base_url']."api/v1/event/$event_id/lineups";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
@@ -172,13 +171,13 @@ class Grapper
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder . '/lineups.json', json_encode($data));
|
||||
File::put($folder.'/lineups.json', json_encode($data));
|
||||
|
||||
/*********************************
|
||||
* EVENT odds
|
||||
*********************************/
|
||||
|
||||
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/odds/1/all";
|
||||
$url = Grap::$options['base_url']."api/v1/event/$event_id/odds/1/all";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
@@ -186,13 +185,13 @@ class Grapper
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder . '/odds.json', json_encode($data));
|
||||
File::put($folder.'/odds.json', json_encode($data));
|
||||
|
||||
/*********************************
|
||||
* EVENT incidents
|
||||
*********************************/
|
||||
|
||||
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/incidents";
|
||||
$url = Grap::$options['base_url']."api/v1/event/$event_id/incidents";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
@@ -200,13 +199,13 @@ class Grapper
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder . '/incidents.json', json_encode($data));
|
||||
File::put($folder.'/incidents.json', json_encode($data));
|
||||
|
||||
$grapped = SofaScoreEventGrapped::firstOrNew(['id' => $event['id']]);
|
||||
$grapped->grapper_id = $task_id;
|
||||
$grapped->day = $day;
|
||||
$grapped->liga = $event['tournament']['name'];
|
||||
$grapped->name = $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'];
|
||||
$grapped->name = $event['homeTeam']['name'].' vs '.$event['awayTeam']['name'];
|
||||
$grapped->url = $url;
|
||||
$grapped->starttime = $starttime->toDateTimeString();
|
||||
$grapped->save();
|
||||
@@ -230,10 +229,11 @@ class Grapper
|
||||
Notice::note("$count days done, sleep 10-20 sec", 'p');
|
||||
}
|
||||
|
||||
if (! $force)
|
||||
if (! $force) {
|
||||
Sleeper::rand(2);
|
||||
else
|
||||
} else {
|
||||
Sleeper::rand();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ namespace App\Console\Commands\Grapper\Sofascore\Helper;
|
||||
use App\Console\Commands\Grap;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
|
||||
class CurlSofa
|
||||
{
|
||||
public static function load(string $url)
|
||||
@@ -49,7 +48,7 @@ class CurlSofa
|
||||
// Cache-Control: no-cache
|
||||
// TE: trailers
|
||||
$headers = [
|
||||
'User-Agent: ' . $useragents[Grap::$useragent],
|
||||
'User-Agent: '.$useragents[Grap::$useragent],
|
||||
'Accept: */*',
|
||||
'Accept-Language: de,en-US;q=0.7,en;q=0.3',
|
||||
'Accept-Encoding: gzip, deflate, br, zstd',
|
||||
@@ -64,7 +63,7 @@ class CurlSofa
|
||||
'Priority: u=4',
|
||||
'Pragma: no-cache',
|
||||
'Cache-Control: no-cache',
|
||||
'TE: trailers'
|
||||
'TE: trailers',
|
||||
];
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
Reference in new issue
Block a user