wip grapper

This commit is contained in:
salam committed 2026-07-04 07:05:05 +02:00
1 parent dc76eb35ae
commit db5ce95b30
14 files changed
+81 -109

No files matched your search

+2 -7
View File
@@ -5,7 +5,6 @@ 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\LoadDays;
use App\Console\Commands\Grapper\Sofascore\Helper\TaskConfig;
use App\Console\Commands\Grapper\Sofascore\PlayerPerSeason;
use App\Console\Commands\Grapper\Sofascore\SendMail;
@@ -18,15 +17,11 @@ ini_set('magic_quotes_runtime', false);
class Sofascore
{
public static string $source_path;
public static string $storage_path;
public static string $grapper_path;
public static function switch()
{
self::$source_path = app_path('/Console/Commands/Grapper/Sofascore/Grapped');
self::$storage_path = storage_path('zip_sofascore_data');
self::$grapper_path = app_path('/Console/Commands/Grapper/Sofascore/Grapped/');
$function = Nuh::$options['fun'];
@@ -13,9 +13,7 @@ class CreateZip
{
$debug = Nuh::$options['d'] ?? 0;
$task = Nuh::$options['task'] ?? 0;
$days = LoadDays::load($task);
$days = LoadDays::load();
foreach ($days as $d) {
@@ -18,13 +18,11 @@ class Grapper
{
$debug = Nuh::$options['d'] ?? 0;
$force = Nuh::$options['f'] ?? 0;
$task_id = Nuh::$options['task'] ?? 0;
$days = LoadDays::load();
$active_tournaments = SofaScoreTaskTournament::with('tournament')->where('id', $task_id)->get();
$active_tournaments = SofaScoreTaskTournament::with('tournament')->where('sofa_score_task_id', $task_id)->where('disabled', false)->get();
foreach ($active_tournaments as $tournament) {
@@ -47,7 +45,7 @@ class Grapper
$url = Nuh::$options['base_url']."api/v1/unique-tournament/$tournament->sofa_score_tournament_id/scheduled-events/$day";
Sleeper::rand($langsam);
Sleeper::rand(1);
$data = CurlSofa::load($url);
@@ -59,7 +57,7 @@ class Grapper
foreach ($data['events'] as $event) {
$folder = app_path().Sofascore::$storage_path.$day.'/'.$event['tournament']['slug'].'/'.$event['slug'];
$folder = Sofascore::$grapper_path.$day.'/'.$event['tournament']['slug'].'/'.$event['slug'];
File::makeDirectory($folder, 0775, true, true);
@@ -75,7 +73,7 @@ class Grapper
$event_id = $event['id'];
if(!File::exists($folder.'/statistics.json') || $force){
if(!File::exists($folder.'/statistics.json')){
$url = Nuh::$options['base_url']."api/v1/event/$event_id/statistics";
@@ -92,7 +90,7 @@ class Grapper
* EVENT lineups
*********************************/
if(!File::exists($folder.'/lineups.json') || $force){
if(!File::exists($folder.'/lineups.json')){
$url = Nuh::$options['base_url']."api/v1/event/$event_id/lineups";
@@ -109,7 +107,7 @@ class Grapper
* EVENT odds
*********************************/
if(!File::exists($folder.'/odds.json') || $force){
if(!File::exists($folder.'/odds.json')){
$url = Nuh::$options['base_url']."api/v1/event/$event_id/odds/1/all";
@@ -126,7 +124,7 @@ class Grapper
* EVENT incidents
*********************************/
if(!File::exists($folder.'/incidents.json') || $force){
if(!File::exists($folder.'/incidents.json')){
$url = Nuh::$options['base_url']."api/v1/event/$event_id/incidents";
@@ -139,10 +137,10 @@ class Grapper
File::put($folder.'/incidents.json', json_encode($data));
}
}
Notice::note('one day and one tournament done ', 'bb', 1);
}
}
}
Notice::note('tournament done', 'bb', 1);
}
}
}
@@ -16,7 +16,7 @@ class Sleeper
}
if ($langsam) {
$sleep = rand(500000, 50000000);
$sleep = rand(2000000, 60000000);
} else {
$sleep = rand(500000, 1000000);
}
@@ -2,38 +2,48 @@
namespace App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays;
use App\Console\Commands\Nuh;
use App\Utilities\Notice;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Mail;
class SendMail
{
public static function run()
{
$task = Nuh::$options['task'] ?? 0;
$debug = Nuh::$options['d'] ?? 0;
$days = LoadDays::load($task);
$days = LoadDays::load();
foreach ($days as $d) {
$day = $d['day'];
$zip_file = Sofascore::$storage_path.'/'.$day.'.zip';
$zip_file = storage_path('zip_sofascore_data').'/'.$day.'.zip';
Mail::send([], [], function ($message) use ($day, $zip_file) {
if(File::exists($zip_file)){
$message->to('hermann.telser@gmail.com', 'sofa archive '.$day)
->cc('ubaldo.perrucci@gmail.com', 'sofa archive '.$day)
->subject("sofa archive $day")
->attach($zip_file, [
'mime' => 'application/x-zip-compressed',
'as' => 'sofa archive '.$day.'.zip',
]);
});
if($debug){
Notice::note('Mail send' .$day);
}
Mail::send([], [], function ($message) use ($day, $zip_file) {
$message->to('hermann.telser@gmail.com', 'sofa archive '.$day)
->cc('ubaldo.perrucci@gmail.com', 'sofa archive '.$day)
->subject("sofa archive $day")
->attach($zip_file, [
'mime' => 'application/x-zip-compressed',
'as' => 'sofa archive '.$day.'.zip',
]);
});
}
}
Notice::note('Mail send', 'g');
if($debug){
Notice::note('Mail send', 'g');
}
}
}
+1 -1
View File
@@ -63,7 +63,7 @@ class Nuh extends Command
$txt .= '--b block update (reload all for txodds)' . PHP_EOL;
$txt .= '--d debug' . PHP_EOL;
$txt .= '--e echo client data' . PHP_EOL;
$txt .= '--f force (whatever in script)' . PHP_EOL;
$txt .= '--f force (what ever in script)' . PHP_EOL;
$txt .= '--g by minor groups (tx)' . PHP_EOL;
$txt .= '--t load today' . PHP_EOL;
$txt .= '--m mail it' . PHP_EOL;