This commit is contained in:
salam committed 2026-07-18 16:46:33 +02:00
1 parent 11189ec3d6
commit 2be791d63b
14 files changed
+344 -195

No files matched your search

+24 -4
View File
@@ -2,15 +2,17 @@
namespace App\Console\Commands\Grapper;
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\Strings;
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\Models\SofaScoreTask;
use App\Utilities\Notice;
use App\Utilities\ZipFolder;
ini_set('magic_quotes_runtime', false);
@@ -22,31 +24,40 @@ class Sofascore
{
$function = Nuh::$options['fun'];
self::$storage = storage_path('sofascore_data');
switch ($function) {
case 1:
PlayerPerSeason::run();
break;
case 2:
SettingsToLocal::run();
break;
case 3:
TaskConfig::start();
break;
case 4:
DaysTournament::run();
break;
case 5:
self::setStorage();
Grapper::load();
break;
case 6:
TaskConfig::end();
break;
case 7:
CreateZip::run();
self::setStorage();
ZipFolder::create(self::$storage);
break;
case 8:
self::setStorage();
SendMail::run();
break;
@@ -54,4 +65,13 @@ class Sofascore
Notice::note('id not valid', 'br', 1);
}
}
public static function setStorage()
{
$task = Nuh::$options['task'];
self::$storage = storage_path('sofascore_data') . '/' . Strings::clean(SofaScoreTask::where('id', $task)->value('name'));
dd(self::$storage);
}
}
@@ -1,22 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Nuh;
use App\Utilities\Notice;
use App\Utilities\ZipFolder;
class CreateZip
{
public static function run()
{
$debug = Nuh::$options['d'] ?? 0;
ZipFolder::create(Sofascore::$storage);
if ($debug) {
Notice::note('zips created', 'bb');
}
}
}
@@ -15,6 +15,15 @@ use Illuminate\Support\Facades\Log;
class DaysTournament
{
/**
* a nuh --d --f 67 --fun=4 --task=1
*
* Ita Serie-A-Saison 23-08-2025 - 24-05-2026
* Ger Bundesliga 22-08-2025 – 16-05-2026
* Eng Premier league 15-08-2025 - 24-05-2026
* Spa La Liga 15-08-2025 - 24-05-2026
* Fra Liggue 15-08-2025 - 17-05-2026
*/
public static function run()
{
$debug = Nuh::$options['d'] ?? 0;
@@ -29,7 +38,7 @@ class DaysTournament
$day = $d['day'];
$slug = $d['slug'];
$has = SofaScoreDayTournament::where('day', $day)->first();
$has = SofaScoreDayTournament::where('day', $day)->where('sport_id', $sport_id)->first();
if ($has) {
if ($debug) {
@@ -154,6 +163,7 @@ class DaysTournament
*/
SofaScoreDayTournament::updateOrCreate([
'tournament_id' => (int) $tournament['id'],
'sport_id' => (int) $sport_id,
'day' => $day,
]);
}
@@ -35,9 +35,6 @@ class Grapper
$active_tournaments = SofaScoreTaskTournament::with('tournament')->where('sofa_score_task_id', $task_id)->where('disabled', false)->get();
// dd($active_tournaments->toArray());
/**
* empty grapping folder
* empty mailing text
@@ -83,10 +80,13 @@ class Grapper
foreach ($data['events'] as $event) {
$now = Carbon::now()->subHours(4);
$now = Carbon::now()->subHours(3);
$carbon_day = new Carbon($day);
$starttime = Carbon::createFromTimestamp($event['startTimestamp']);
if ($now->greaterThan($starttime)) {
if ($now->greaterThan($starttime) && $starttime->isSameDay($carbon_day)) {
Sleeper::rand(1);
@@ -0,0 +1,15 @@
<?php
namespace App\Console\Commands\Grapper\Sofascore\Helper;
class Strings
{
public static function clean(string $string)
{
$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
}
}