wip
This commit is contained in:
1 parent
8c235ef82c
commit
acf74c5e82
8 files changed
+593
-90
No files matched your search
@@ -11,6 +11,7 @@ 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\Console\Commands\Grapper\Sofascore\TournamentTeams;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\SofaScoreTask;
|
||||
use App\Utilities\Notice;
|
||||
@@ -26,7 +27,7 @@ class Sofascore
|
||||
|
||||
public static string $excel_name;
|
||||
|
||||
public static string $useragent;
|
||||
public static string $useragent = '4';
|
||||
|
||||
public static function switch()
|
||||
{
|
||||
@@ -44,25 +45,21 @@ class Sofascore
|
||||
|
||||
case 3:
|
||||
self::setStorage();
|
||||
|
||||
Grapper::load();
|
||||
break;
|
||||
|
||||
case 4:
|
||||
self::setStorage();
|
||||
|
||||
ZipFolder::create();
|
||||
break;
|
||||
|
||||
case 5:
|
||||
self::setStorage();
|
||||
|
||||
SendMail::run();
|
||||
break;
|
||||
|
||||
case 6:
|
||||
self::setStorage();
|
||||
|
||||
Rose::run();
|
||||
break;
|
||||
|
||||
@@ -72,10 +69,13 @@ class Sofascore
|
||||
|
||||
case 8:
|
||||
self::setStorage();
|
||||
|
||||
MakeExcel::create();
|
||||
break;
|
||||
|
||||
case 9:
|
||||
TournamentTeams::get();
|
||||
break;
|
||||
|
||||
default:
|
||||
Notice::note('id not valid', 'br', 1);
|
||||
}
|
||||
@@ -87,7 +87,6 @@ class Sofascore
|
||||
|
||||
self::$storage = storage_path('sofascore_data') . '/';
|
||||
// for grapper to start with
|
||||
self::$useragent = 4;
|
||||
|
||||
$storage_name = Strings::clean(SofaScoreTask::where('id', $task)->value('name')) . '/';
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\CurlSofa;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\SofaScoreRosa;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class TournamentTeams
|
||||
{
|
||||
public static function get()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$tournaments_counter = 0;
|
||||
|
||||
$teams_counter = 0;
|
||||
|
||||
$tournaments = SofaScoreTournament::with('sofascore_category')->where('enabled', 1)->get();
|
||||
|
||||
SofaScoreRosa::query()->update(['grapped' => 0]);
|
||||
|
||||
foreach ($tournaments as $tournament) {
|
||||
|
||||
$tournaments_counter++;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Tournament: $tournament->name", 'bb');
|
||||
}
|
||||
|
||||
$url = Nuh::$options['base_url'] . "api/v1/unique-tournament/$tournament->tournament_id/seasons";
|
||||
|
||||
Sleeper::rand(1);
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
$season_id = $data['seasons'][0]['id'];
|
||||
|
||||
$url = Nuh::$options['base_url'] . "api/v1/unique-tournament/$tournament->tournament_id/season/$season_id/standings/total";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
foreach ($data['standings'][0]['rows'] as $row) {
|
||||
$teams_counter++;
|
||||
|
||||
$ssteam_id = $row['team']['id'];
|
||||
$name = $row['team']['name'];
|
||||
$country_id = $tournament->sofascore_category->country_id;
|
||||
|
||||
SofaScoreRosa::updateOrCreate([
|
||||
'sport_id' => $tournament->sport_id,
|
||||
'ssteam_id' => (int) $ssteam_id,
|
||||
], [
|
||||
'ss_tournament_id' => (int) $tournament->tournament_id,
|
||||
'country_id' => (int) $country_id,
|
||||
'ssteam_name' => $name,
|
||||
'grapped' => 1,
|
||||
'disabled' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("summe tournaments: $tournaments_counter", 'p');
|
||||
Notice::note("summe teams: $teams_counter", 'p');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user