wip
This commit is contained in:
1 parent
9e6f7e1c06
commit
88205b7aa1
8 files changed
+133
-168
No files matched your search
@@ -2,10 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands\Grapper;
|
namespace App\Console\Commands\Grapper;
|
||||||
|
|
||||||
use App\Console\Commands\Grapper\Sofascore\DaysTournament;
|
|
||||||
use App\Console\Commands\Grapper\Sofascore\Grapper;
|
use App\Console\Commands\Grapper\Sofascore\Grapper;
|
||||||
use App\Console\Commands\Grapper\Sofascore\Helper\Strings;
|
use App\Console\Commands\Grapper\Sofascore\Helper\Strings;
|
||||||
use App\Console\Commands\Grapper\Sofascore\Helper\TaskConfig;
|
|
||||||
use App\Console\Commands\Grapper\Sofascore\PlayerPerSeason;
|
use App\Console\Commands\Grapper\Sofascore\PlayerPerSeason;
|
||||||
use App\Console\Commands\Grapper\Sofascore\SendMail;
|
use App\Console\Commands\Grapper\Sofascore\SendMail;
|
||||||
use App\Console\Commands\Grapper\Sofascore\SettingsToLocal;
|
use App\Console\Commands\Grapper\Sofascore\SettingsToLocal;
|
||||||
@@ -35,20 +33,16 @@ class Sofascore
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
DaysTournament::run();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
self::setStorage();
|
self::setStorage();
|
||||||
Grapper::load();
|
Grapper::load();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 4:
|
||||||
self::setStorage();
|
self::setStorage();
|
||||||
ZipFolder::create(self::$storage);
|
ZipFolder::create(self::$storage);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 5:
|
||||||
self::setStorage();
|
self::setStorage();
|
||||||
SendMail::run();
|
SendMail::run();
|
||||||
break;
|
break;
|
||||||
@@ -63,7 +57,5 @@ class Sofascore
|
|||||||
$task = Nuh::$options['task'];
|
$task = Nuh::$options['task'];
|
||||||
|
|
||||||
self::$storage = storage_path('sofascore_data') . '/' . Strings::clean(SofaScoreTask::where('id', $task)->value('name'));
|
self::$storage = storage_path('sofascore_data') . '/' . Strings::clean(SofaScoreTask::where('id', $task)->value('name'));
|
||||||
|
|
||||||
dd(self::$storage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,153 +24,150 @@ class DaysTournament
|
|||||||
* Spa La Liga 15-08-2025 - 24-05-2026
|
* Spa La Liga 15-08-2025 - 24-05-2026
|
||||||
* Fra Liggue 15-08-2025 - 17-05-2026
|
* Fra Liggue 15-08-2025 - 17-05-2026
|
||||||
*/
|
*/
|
||||||
public static function run()
|
public static function get(array $d)
|
||||||
{
|
{
|
||||||
$debug = Nuh::$options['d'] ?? 0;
|
$debug = Nuh::$options['d'] ?? 0;
|
||||||
|
|
||||||
$days = LoadDays::load();
|
|
||||||
|
|
||||||
$tournaments_counter = 0;
|
$tournaments_counter = 0;
|
||||||
|
|
||||||
foreach ($days as $d) {
|
$sport_id = $d['sport_id'];
|
||||||
|
|
||||||
$sport_id = $d['sport_id'];
|
$day = $d['day'];
|
||||||
$day = $d['day'];
|
|
||||||
$slug = $d['slug'];
|
|
||||||
|
|
||||||
$has = SofaScoreDayTournament::where('day', $day)->where('sport_id', $sport_id)->first();
|
$slug = $d['slug'];
|
||||||
|
|
||||||
if ($has) {
|
$has = SofaScoreDayTournament::where('day', $day)->where('sport_id', $sport_id)->first();
|
||||||
if ($debug) {
|
|
||||||
Notice::note("All tournament for $day have been allready grapped", 'g');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if ($debug) {
|
if ($has) {
|
||||||
Notice::note("$day\ngrappig", 'g');
|
if ($debug) {
|
||||||
|
Notice::note("Tournaments $day for " . strtoupper($slug) . " allready grapped", 'bb');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if ($debug) {
|
||||||
|
Notice::note("$day\ngrappig", 'g');
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = 1;
|
||||||
|
|
||||||
|
while ($page) {
|
||||||
|
|
||||||
|
$url = Nuh::$options['base_url'] . "api/v1/sport/$slug/scheduled-tournaments/$day/page/$page";
|
||||||
|
|
||||||
|
Sleeper::rand();
|
||||||
|
|
||||||
|
$data = CurlSofa::load($url);
|
||||||
|
|
||||||
|
if ($data['hasNextPage']) {
|
||||||
|
$page++;
|
||||||
|
} else {
|
||||||
|
$page = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = 1;
|
foreach ($data['scheduled'] as $row) {
|
||||||
|
|
||||||
while ($page) {
|
if (isset($row['tournament']['uniqueTournament'])) {
|
||||||
|
$tournament = $row['tournament']['uniqueTournament'];
|
||||||
$url = Nuh::$options['base_url'] . "api/v1/sport/$slug/scheduled-tournaments/$day/page/$page";
|
|
||||||
|
|
||||||
Sleeper::rand();
|
|
||||||
|
|
||||||
$data = CurlSofa::load($url);
|
|
||||||
|
|
||||||
if ($data['hasNextPage']) {
|
|
||||||
$page++;
|
|
||||||
} else {
|
} else {
|
||||||
$page = false;
|
$tournament = $row['tournament'];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($data['scheduled'] as $row) {
|
$category = $tournament['category'];
|
||||||
|
|
||||||
if (isset($row['tournament']['uniqueTournament'])) {
|
if ($sport_id == 5) {
|
||||||
$tournament = $row['tournament']['uniqueTournament'];
|
$country_id = 470;
|
||||||
} else {
|
} else {
|
||||||
$tournament = $row['tournament'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$category = $tournament['category'];
|
|
||||||
|
|
||||||
if ($sport_id == 5) {
|
|
||||||
$country_id = 470;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CATEGORY
|
|
||||||
*/
|
|
||||||
$find = [
|
|
||||||
'Amateur',
|
|
||||||
'Bosnia & Herzegovina',
|
|
||||||
'Czechia',
|
|
||||||
'DR Congo',
|
|
||||||
'Netherlands',
|
|
||||||
'North & Central America',
|
|
||||||
'Bonaire',
|
|
||||||
'Sao Tome and Principe',
|
|
||||||
'Cape Verde',
|
|
||||||
'Macao',
|
|
||||||
'Saint Kitts and Nevis',
|
|
||||||
'Eswatini',
|
|
||||||
'Timor Leste',
|
|
||||||
'Laos',
|
|
||||||
'Congo Republic',
|
|
||||||
|
|
||||||
];
|
|
||||||
$replace = [
|
|
||||||
'',
|
|
||||||
'Bosnia Herzegovina',
|
|
||||||
'Czech Republic',
|
|
||||||
'Congo DR',
|
|
||||||
'Holland',
|
|
||||||
'North America',
|
|
||||||
'Bonaire, Sint Eustatius and Saba',
|
|
||||||
'Sao Tome e Principe',
|
|
||||||
'Cape Verde Islands',
|
|
||||||
'Macau',
|
|
||||||
'St. Kitts and Nevis',
|
|
||||||
'Swaziland',
|
|
||||||
'East Timor',
|
|
||||||
'Lao Peoples\'s Democratic Republic',
|
|
||||||
'Congo DR',
|
|
||||||
];
|
|
||||||
$country_id = Country::where('name', trim(str_replace($find, $replace, $category['name'])))->value('id');
|
|
||||||
}
|
|
||||||
|
|
||||||
// dd($category, $country_id);
|
|
||||||
|
|
||||||
if (! $country_id) {
|
|
||||||
// platzhalter fix later sofa_score_categories => txodds countries
|
|
||||||
// CATEGORY find <-> replace
|
|
||||||
Log::channel('sofascore')->info($tournament);
|
|
||||||
|
|
||||||
$sofa_score_categorie_id = 10000000;
|
|
||||||
} else {
|
|
||||||
$call = SofaScoreCategorie::updateOrCreate([
|
|
||||||
'id' => (int) $category['id'],
|
|
||||||
'country_id' => (int) $country_id,
|
|
||||||
'slug' => $category['slug'],
|
|
||||||
], [
|
|
||||||
'name' => $category['name'],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$sofa_score_categorie_id = $call->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TOURNAMENT
|
* CATEGORY
|
||||||
*/
|
*/
|
||||||
SofaScoreTournament::updateOrCreate([
|
$find = [
|
||||||
'sport_id' => (int) $sport_id,
|
'Amateur',
|
||||||
'tournament_id' => (int) $tournament['id'],
|
'Bosnia & Herzegovina',
|
||||||
'sofa_score_categorie_id' => (int) $sofa_score_categorie_id,
|
'Czechia',
|
||||||
|
'DR Congo',
|
||||||
|
'Netherlands',
|
||||||
|
'North & Central America',
|
||||||
|
'Bonaire',
|
||||||
|
'Sao Tome and Principe',
|
||||||
|
'Cape Verde',
|
||||||
|
'Macao',
|
||||||
|
'Saint Kitts and Nevis',
|
||||||
|
'Eswatini',
|
||||||
|
'Timor Leste',
|
||||||
|
'Laos',
|
||||||
|
'Congo Republic',
|
||||||
|
|
||||||
|
];
|
||||||
|
$replace = [
|
||||||
|
'',
|
||||||
|
'Bosnia Herzegovina',
|
||||||
|
'Czech Republic',
|
||||||
|
'Congo DR',
|
||||||
|
'Holland',
|
||||||
|
'North America',
|
||||||
|
'Bonaire, Sint Eustatius and Saba',
|
||||||
|
'Sao Tome e Principe',
|
||||||
|
'Cape Verde Islands',
|
||||||
|
'Macau',
|
||||||
|
'St. Kitts and Nevis',
|
||||||
|
'Swaziland',
|
||||||
|
'East Timor',
|
||||||
|
'Lao Peoples\'s Democratic Republic',
|
||||||
|
'Congo DR',
|
||||||
|
];
|
||||||
|
$country_id = Country::where('name', trim(str_replace($find, $replace, $category['name'])))->value('id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// dd($category, $country_id);
|
||||||
|
|
||||||
|
if (! $country_id) {
|
||||||
|
// platzhalter fix later sofa_score_categories => txodds countries
|
||||||
|
// CATEGORY find <-> replace
|
||||||
|
Log::channel('sofascore')->info($tournament);
|
||||||
|
|
||||||
|
$sofa_score_categorie_id = 10000000;
|
||||||
|
} else {
|
||||||
|
$call = SofaScoreCategorie::updateOrCreate([
|
||||||
|
'id' => (int) $category['id'],
|
||||||
|
'country_id' => (int) $country_id,
|
||||||
|
'slug' => $category['slug'],
|
||||||
], [
|
], [
|
||||||
'name' => $tournament['name'],
|
'name' => $category['name'],
|
||||||
'slug' => $tournament['slug'],
|
|
||||||
]);
|
]);
|
||||||
$tournaments_counter++;
|
|
||||||
|
$sofa_score_categorie_id = $call->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TOURNAMENT
|
||||||
|
*/
|
||||||
|
SofaScoreTournament::updateOrCreate([
|
||||||
|
'sport_id' => (int) $sport_id,
|
||||||
|
'tournament_id' => (int) $tournament['id'],
|
||||||
|
'sofa_score_categorie_id' => (int) $sofa_score_categorie_id,
|
||||||
|
], [
|
||||||
|
'name' => $tournament['name'],
|
||||||
|
'slug' => $tournament['slug'],
|
||||||
|
]);
|
||||||
|
$tournaments_counter++;
|
||||||
|
|
||||||
// if ($debug) {
|
// if ($debug) {
|
||||||
// Notice::note('tournament: ' . $tournament['name'], 'p');
|
// Notice::note('tournament: ' . $tournament['name'], 'p');
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DAY TOURNAMENT
|
* DAY TOURNAMENT
|
||||||
*/
|
*/
|
||||||
SofaScoreDayTournament::updateOrCreate([
|
SofaScoreDayTournament::updateOrCreate([
|
||||||
'tournament_id' => (int) $tournament['id'],
|
'tournament_id' => (int) $tournament['id'],
|
||||||
'sport_id' => (int) $sport_id,
|
'sport_id' => (int) $sport_id,
|
||||||
'day' => $day,
|
'day' => $day,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
Notice::note("tournaments: $tournaments_counter", 'p');
|
Notice::note("tournaments: $tournaments_counter", 'p');
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,19 +16,10 @@ use Illuminate\Support\Facades\File;
|
|||||||
|
|
||||||
class Grapper
|
class Grapper
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* last 3 days = task 1
|
|
||||||
*
|
|
||||||
* nuh --d --f 67 --fun=6 --task=1
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static function load()
|
public static function load()
|
||||||
{
|
{
|
||||||
$debug = Nuh::$options['d'] ?? 0;
|
$debug = Nuh::$options['d'] ?? 0;
|
||||||
|
|
||||||
$force = Nuh::$options['f'] ?? 0;
|
|
||||||
|
|
||||||
$task_id = Nuh::$options['task'] ?? 0;
|
$task_id = Nuh::$options['task'] ?? 0;
|
||||||
|
|
||||||
$days = LoadDays::load();
|
$days = LoadDays::load();
|
||||||
@@ -47,15 +38,18 @@ class Grapper
|
|||||||
if ($debug)
|
if ($debug)
|
||||||
Notice::note('Truncate SofaScoreEventGrapped', 'b');
|
Notice::note('Truncate SofaScoreEventGrapped', 'b');
|
||||||
|
|
||||||
SofaScoreEventGrapped::query()->truncate();
|
SofaScoreEventGrapped::where('grapper_id', $task_id)->delete();
|
||||||
|
|
||||||
foreach ($active_tournaments as $tournament) {
|
foreach ($days as $d) {
|
||||||
|
|
||||||
if ($debug) {
|
DaysTournament::get($d);
|
||||||
Notice::note($tournament->tournament->name, 'bg');
|
|
||||||
}
|
foreach ($active_tournaments as $tournament) {
|
||||||
|
|
||||||
|
if ($debug) {
|
||||||
|
Notice::note($tournament->tournament->name, 'bg');
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($days as $d) {
|
|
||||||
|
|
||||||
$day = $d['day'];
|
$day = $d['day'];
|
||||||
|
|
||||||
@@ -95,12 +89,12 @@ class Grapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
$grapped = SofaScoreEventGrapped::firstOrNew(['id' => $event['id']]);
|
$grapped = SofaScoreEventGrapped::firstOrNew(['id' => $event['id']]);
|
||||||
|
$grapped->grapper_id = $task_id;
|
||||||
$grapped->day = $day;
|
$grapped->day = $day;
|
||||||
$grapped->liga = $event['tournament']['name'];
|
$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->url = $url;
|
||||||
$grapped->starttime = $starttime->toDateTimeString();
|
$grapped->starttime = $starttime->toDateTimeString();
|
||||||
$grapped->in_current_grapper = true;
|
|
||||||
|
|
||||||
$folder = Sofascore::$storage . '/' . $day . '/' . $event['tournament']['slug'] . '/' . $event['slug'];
|
$folder = Sofascore::$storage . '/' . $day . '/' . $event['tournament']['slug'] . '/' . $event['slug'];
|
||||||
|
|
||||||
|
|||||||
@@ -37,18 +37,6 @@ class LoadDays
|
|||||||
'sport_id' => $task->sport_id,
|
'sport_id' => $task->sport_id,
|
||||||
'run_repeatedly' => $task->run_repeatedly,
|
'run_repeatedly' => $task->run_repeatedly,
|
||||||
];
|
];
|
||||||
// $dates[] = [
|
|
||||||
// 'day' => Carbon::now()->subDays(2)->format('Y-m-d'),
|
|
||||||
// 'slug' => $task->sport->ss_slug,
|
|
||||||
// 'sport_id' => $task->sport_id,
|
|
||||||
// 'run_repeatedly' => $task->run_repeatedly,
|
|
||||||
// ];
|
|
||||||
// $dates[] = [
|
|
||||||
// 'day' => Carbon::now()->subDays(3)->format('Y-m-d'),
|
|
||||||
// 'slug' => $task->sport->ss_slug,
|
|
||||||
// 'sport_id' => $task->sport_id,
|
|
||||||
// 'run_repeatedly' => $task->run_repeatedly,
|
|
||||||
// ];
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|||||||
-2
@@ -2,11 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Tables;
|
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Tables;
|
||||||
|
|
||||||
use App\Models\SofaScoreTask;
|
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
use Filament\Tables\Columns\IconColumn;
|
use Filament\Tables\Columns\IconColumn;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Columns\ToggleColumn;
|
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
class SofaScoreTasksTable
|
class SofaScoreTasksTable
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Utilities;
|
namespace App\Utilities;
|
||||||
|
|
||||||
use App\Console\Commands\Grapper\Sofascore;
|
|
||||||
use RecursiveDirectoryIterator;
|
use RecursiveDirectoryIterator;
|
||||||
use RecursiveIteratorIterator;
|
use RecursiveIteratorIterator;
|
||||||
use ZipArchive;
|
use ZipArchive;
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('sofa_score_event_grappeds', function (Blueprint $table) {
|
Schema::create('sofa_score_event_grappeds', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
|
$table->integer('grapper_id');
|
||||||
$table->date('day')->nullable();
|
$table->date('day')->nullable();
|
||||||
$table->string('liga')->nullable();
|
$table->string('liga')->nullable();
|
||||||
$table->string('name')->nullable();
|
$table->string('name')->nullable();
|
||||||
$table->dateTime('starttime')->nullable();
|
$table->dateTime('starttime')->nullable();
|
||||||
$table->string('url')->nullable();
|
$table->string('url')->nullable();
|
||||||
$table->boolean('in_current_grapper')->default(false);
|
|
||||||
$table->boolean('got_statistics')->default(false);
|
$table->boolean('got_statistics')->default(false);
|
||||||
$table->boolean('got_lineups')->default(false);
|
$table->boolean('got_lineups')->default(false);
|
||||||
$table->boolean('got_odds')->default(false);
|
$table->boolean('got_odds')->default(false);
|
||||||
|
|||||||
+3
-6
@@ -29,17 +29,14 @@ case "$1" in
|
|||||||
# echo "\n⚽ close vpn"
|
# echo "\n⚽ close vpn"
|
||||||
# killall ssh
|
# killall ssh
|
||||||
|
|
||||||
# echo "\n⚽ Days Tournament"
|
|
||||||
# php artisan nuh --d --f 67 --fun=3 --task=$1
|
|
||||||
|
|
||||||
# echo "\n⚽ Grapper"
|
# echo "\n⚽ Grapper"
|
||||||
# php artisan nuh --d --f 67 --fun=4 --task=$1
|
php artisan nuh --d --f 67 --fun=3 --task=$1
|
||||||
|
|
||||||
# echo "\n⚽ CreateZip"
|
# echo "\n⚽ CreateZip"
|
||||||
# php artisan nuh --d --f 67 --fun=5 --task=$1
|
# php artisan nuh --d --f 67 --fun=4 --task=$1
|
||||||
|
|
||||||
# echo "\n⚽ SendMail"
|
# echo "\n⚽ SendMail"
|
||||||
# php artisan nuh --d --f 67 --fun=6 --task=$1
|
# php artisan nuh --d --f 67 --fun=5 --task=$1
|
||||||
|
|
||||||
echo "\n😎 done :)"
|
echo "\n😎 done :)"
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in new issue
Block a user