This commit is contained in:
salam committed 2026-08-05 17:27:51 +02:00
1 parent bb6986d6e5
commit 78917241ad
13 files changed
+254 -128

No files matched your search

@@ -3,9 +3,8 @@
namespace App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grapper\Sofascore\Helper\CurlSofa;
use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays;
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
use App\Console\Commands\Nuh;
use App\Console\Commands\Grap;
use App\Models\Country;
use App\Models\SofaScoreCategory;
use App\Models\SofaScoreDayTournament;
@@ -16,7 +15,7 @@ use Illuminate\Support\Facades\Log;
class DaysTournament
{
/**
* a nuh --d --f 67 --fun=4 --task=1
* a Grap --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
@@ -26,7 +25,7 @@ class DaysTournament
*/
public static function get(array $d)
{
$debug = Nuh::$options['d'] ?? 0;
$debug = Grap::$options['d'] ?? 0;
$tournaments_counter = 0;
@@ -52,7 +51,7 @@ class DaysTournament
while ($page) {
$url = Nuh::$options['base_url'] . "api/v1/sport/$slug/scheduled-tournaments/$day/page/$page";
$url = Grap::$options['base_url'] . "api/v1/sport/$slug/scheduled-tournaments/$day/page/$page";
Sleeper::rand();
@@ -2,15 +2,14 @@
namespace App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grap;
use App\Utilities\Notice;
use App\Console\Commands\Nuh;
use Illuminate\Support\Carbon;
use App\Models\SofaScoreTaskDay;
use Illuminate\Support\Facades\File;
use App\Models\SofaScoreEventGrapped;
use App\Models\SofaScoreDayTournament;
use App\Models\SofaScoreTaskTournament;
use App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
use App\Console\Commands\Grapper\Sofascore\Helper\CurlSofa;
use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays;
@@ -23,13 +22,13 @@ class Grapper
* , JSON_PRETTY_PRINT
* to fromat json
*/
$debug = Nuh::$options['d'] ?? 0;
$debug = Grap::$options['d'] ?? 0;
$restart = Grap::$options['r'] ?? 0;
$force = Grap::$options['f'] ?? 0;
$task_id = Grap::$options['task'] ?? 0;
$force = Nuh::$options['ff'] ?? 0;
$task_id = Nuh::$options['task'] ?? 0;
$restart = Nuh::$options['restart'] ?? 0;
if (!$task_id)
Notice::note('task id missing', 'r', 1);
$days = LoadDays::load();
@@ -84,21 +83,17 @@ class Grapper
Notice::note($day, 'g');
}
$url = Nuh::$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";
Sleeper::rand(1);
$data = CurlSofa::load($url);
Nuh::$options['s'] = 0;
Nuh::$options['r'] = 0;
if (isset($data['events'])) {
foreach ($data['events'] as $event) {
Sofascore::$useragent = rand(1, 6);
Grap::$useragent = rand(1, 6);
if (!$force && SofaScoreEventGrapped::where('id', (int) $event['id'])->exists()) {
if ($debug) {
@@ -128,7 +123,7 @@ class Grapper
$grapped->url = $url;
$grapped->starttime = $starttime->toDateTimeString();
$folder = Sofascore::$storage . '/' . $day . '/' . $day . '-' . $event['tournament']['slug'] . '/' . $event['slug'];
$folder = Grap::$storage . '/' . $day . '/' . $day . '-' . $event['tournament']['slug'] . '/' . $event['slug'];
File::makeDirectory($folder, 0775, true, true);
@@ -144,9 +139,7 @@ class Grapper
$event_id = $event['id'];
// if (!$grapped['got_statistics'] && isset($event['hasEventPlayerStatistics']) && $event['hasEventPlayerStatistics'] == true) {
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/statistics";
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/statistics";
Sleeper::rand();
@@ -157,15 +150,12 @@ class Grapper
File::put($folder . '/statistics.json', json_encode($data));
$grapped->got_statistics = 1;
// }
/*********************************
* EVENT lineups
*********************************/
// if (!$grapped['got_lineups']) {
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/lineups";
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/lineups";
Sleeper::rand();
@@ -176,15 +166,12 @@ class Grapper
File::put($folder . '/lineups.json', json_encode($data));
$grapped->got_lineups = 1;
// }
/*********************************
* EVENT odds
*********************************/
// if (!$grapped['got_odds']) {
$url = Nuh::$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();
@@ -195,15 +182,12 @@ class Grapper
File::put($folder . '/odds.json', json_encode($data));
$grapped->got_odds = 1;
// }
/*********************************
* EVENT incidents
*********************************/
// if (!$grapped['got_incidents']) {
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/incidents";
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/incidents";
Sleeper::rand();
@@ -214,7 +198,6 @@ class Grapper
File::put($folder . '/incidents.json', json_encode($data));
$grapped->got_incidents = 1;
// }
$grapped->save();
}
@@ -2,37 +2,20 @@
namespace App\Console\Commands\Grapper\Sofascore\Helper;
use App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grap;
use App\Utilities\Notice;
use App\Console\Commands\Nuh;
class CurlSofa
{
public static $testfile = '/Console/Commands/Grapper/Sofascore/test/';
public static function load(string $url)
{
$debug = Nuh::$options['d'] ?? 0;
$save = Nuh::$options['s'] ?? 0;
$read = Nuh::$options['r'] ?? 0;
$debug = Grap::$options['d'] ?? 0;
if ($debug) {
Notice::note($url, 'b');
}
if ($read) {
if ($debug) {
Notice::note('data read localy', 'bb');
}
$filename = app_path() . self::$testfile . strtolower(str_replace(' ', '_', Nuh::$options['name'])) . '.json';
$data = file_get_contents($filename);
return json_decode($data, true);
}
$useragents = [];
$useragents[1] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15';
$useragents[2] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15';
@@ -41,12 +24,8 @@ class CurlSofa
$useragents[5] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0';
$useragents[6] = 'Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36';
// if ($debug) {
// Notice::note($useragents[Sofascore::$useragent], 'b');
// }
$headers = [
'User-Agent: ' . $useragents[Sofascore::$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',
@@ -74,14 +53,6 @@ class CurlSofa
$data = gzdecode($data);
if ($save) {
$filename = app_path() . self::$testfile . strtolower(str_replace(' ', '_', Nuh::$options['name'])) . '.json';
file_put_contents($filename, $data);
Notice::note('data saved localy', 'bp');
}
$data = json_decode($data, true);
return $data;
@@ -3,7 +3,7 @@
namespace App\Console\Commands\Grapper\Sofascore\Helper;
use App\Utilities\Notice;
use App\Console\Commands\Nuh;
use App\Console\Commands\Grap;
use App\Models\SofaScoreTask;
use Illuminate\Support\Carbon;
use App\Models\SofaScoreTaskDay;
@@ -12,13 +12,13 @@ class LoadDays
{
public static function load()
{
$debug = Nuh::$options['d'] ?? 0;
$debug = Grap::$options['d'] ?? 0;
$restart = Nuh::$options['restart'] ?? 0;
$restart = Grap::$options['restart'] ?? 0;
$task_id = Nuh::$options['task'] ?? 0;
$task_id = Grap::$options['task'] ?? 0;
$folder = Nuh::$options['folder'] ?? 0;
$folder = Grap::$options['folder'] ?? 0;
$dates = [];
@@ -0,0 +1,22 @@
<?php
namespace App\Console\Commands\Grapper\Sofascore\Helper;
class ReadDir
{
public static function get_tree(string $dir, &$results = array())
{
$files = scandir($dir);
foreach ($files as $value) {
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
if (!is_dir($path)) {
$results[] = $path;
} else if ($value != "." && $value != "..") {
self::get_tree($path, $results);
$results[] = $path;
}
}
return $results;
}
}
@@ -0,0 +1,55 @@
<?php
namespace App\Console\Commands\Grapper\Sofascore\Helper;
use App\Console\Commands\Grap;
use App\Models\SofaScoreTask;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
class SetStorage
{
public static function set()
{
$task = Grap::$options['task'] ?? 1;
$debug = Grap::$options['d'];
$folder = Grap::$options['folder'] ?? '';
$task = SofaScoreTask::where('id', $task)->first();
$sofascore_data = storage_path('sofascore_data') . '/';
if ($task) {
$storage_name = Strings::clean($task->name);
switch ($task->id) {
case 1:
Grap::$storage = $sofascore_data . $storage_name;
Grap::$folder = Carbon::now()->subDays(3)->format('Y-m-d');
break;
case 2:
Grap::$storage = $sofascore_data . $storage_name . '/' . $task->day_from;
Grap::$zipfile = $sofascore_data . $storage_name . '/' . $task->day_from . '.zip';
break;
case 3:
Grap::$storage = $sofascore_data . $storage_name . '-' . $task->day_from . '-' . $task->day_to;
Grap::$zipfile = $sofascore_data . $storage_name . '-' . $task->day_from . '-' . $task->day_to . '.zip';
break;
case 4:
Grap::$storage = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d');
Grap::$zipfile = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d') . '.zip';
break;
default:
Grap::$storage = $sofascore_data . $storage_name;
Grap::$zipfile = $sofascore_data . $storage_name . '/archive.zip';
break;
}
} else if ($folder) {
Grap::$storage = $sofascore_data;
Grap::$folder = $folder;
}
if ($debug) {
Notice::note("Task: $task->name\n" . 'Storage: ' . Grap::$storage . "\nFolder: " . Grap::$folder);
}
}
}
@@ -33,20 +33,4 @@ class ZipFolder
return response()->json(['error' => 'Failed to create ZIP archive'], 500);
}
}
public static function get_tree(string $dir, &$results = array())
{
$files = scandir($dir);
foreach ($files as $value) {
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
if (!is_dir($path)) {
$results[] = $path;
} else if ($value != "." && $value != "..") {
self::get_tree($path, $results);
$results[] = $path;
}
}
return $results;
}
}
@@ -2,12 +2,13 @@
namespace App\Console\Commands\Grapper\Sofascore;
use App\Utilities\Notice;
use App\Console\Commands\Grap;
use App\Console\Commands\Grapper\Grap\Helper\ZipFolder;
use App\Console\Commands\Grapper\Sofascore\Helper\ReadDir;
use App\Console\Commands\Nuh;
use App\Utilities\Notice;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grapper\Sofascore\Helper\ZipFolder;
class MakeExcel
{
@@ -22,7 +23,7 @@ class MakeExcel
$debug = Nuh::$options['d'] ?? 0;
if ($debug) {
Notice::note("Make Excel folder to import: " . Sofascore::$folder . "\nmaximum files in excel: " . self::$max, 'b');
Notice::note("Make Excel folder to import: " . Grap::$folder . "\nmaximum files in excel: " . self::$max, 'b');
}
$files = self::load_files();
@@ -46,7 +47,7 @@ class MakeExcel
$to = $key * self::$max + $has;
}
$filename = Sofascore::$folder . '-' . $from . '-' . $to . '.xlsx';
$filename = Grap::$folder . '-' . $from . '-' . $to . '.xlsx';
$spreadsheet = new Spreadsheet;
$spreadsheet->getProperties()->setTitle($filename);
$activeWorksheet = $spreadsheet->getActiveSheet();
@@ -68,16 +69,16 @@ class MakeExcel
$spreadsheet->setActiveSheetIndex(0);
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save(Sofascore::$storage . '/' . $filename);
$writer->save(Grap::$storage . '/' . $filename);
self::$filesToMail[] = Sofascore::$storage . '/' . $filename;
self::$filesToMail[] = Grap::$storage . '/' . $filename;
}
}
public static function load_files()
{
$files = ZipFolder::get_tree(Sofascore::$storage . '/' . Sofascore::$folder);
$files = ReadDir::get_tree(Grap::$storage . '/' . Grap::$folder);
$filtered = [];
foreach ($files as $file) {
@@ -0,0 +1,13 @@
<?php
namespace App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grapper\Sofascore;
class Player
{
public static function call()
{
// https://www.sofascore.com/api/v1/player/824509
}
}
@@ -2,7 +2,7 @@
namespace App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Nuh;
use App\Console\Commands\Grap;
use App\Models\SofaScorePlayerPerSeason;
use App\Models\StatistikoDetail;
use App\Models\StatistikoPlayer;
@@ -12,7 +12,7 @@ class PlayerPerSeason
{
public static function run()
{
$debug = Nuh::$options['d'] ?? 0;
$debug = Grap::$options['d'] ?? 0;
$res = StatistikoDetail::query()->select('ss_player_id', 'ss_team_id')->get();
@@ -2,8 +2,7 @@
namespace App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Nuh;
use App\Models\SofaScoreRosa;
use App\Console\Commands\Grap;
use App\Models\SofaScoreTask;
use App\Models\SofaScoreTaskTournament;
use App\Models\SofaScoreTournament;
@@ -14,11 +13,15 @@ class SettingsToLocal
{
public static function run()
{
$debug = Nuh::$options['d'] ?? 0;
$debug = Grap::$options['d'] ?? 0;
if ($debug) {
Notice::note('Settings To Local', 'bb');
}
Notice::note("⚽ close all vpn");
exec('killall ssh');
Notice::note("⚽ open vpn");
exec('ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190');
Notice::note("⚽ settings to local");
if ($debug) {
Notice::note('SofaScoreTask', 'g');
@@ -46,5 +49,8 @@ class SettingsToLocal
foreach ($rows as $row) {
SofaScoreTournament::insert((array) $row);
}
Notice::note("⚽ close all vpn");
exec('killall ssh');
}
}