grapper wip
This commit is contained in:
1 parent
3117a8dcbd
commit
7aa3c90344
3 files changed
+135
-56
No files matched your search
@@ -11,32 +11,84 @@ use Illuminate\Support\Facades\File;
|
|||||||
|
|
||||||
class Events
|
class Events
|
||||||
{
|
{
|
||||||
public static $max_days = 30;
|
|
||||||
public static Carbon $days_back;
|
|
||||||
|
|
||||||
public static $storage_path = '/Console/Commands/Grapper/Sofascore/grapped/';
|
public static $storage_path = '/Console/Commands/Grapper/Sofascore/grapped/';
|
||||||
|
|
||||||
public static function load()
|
public static function load()
|
||||||
{
|
{
|
||||||
self::$days_back = Carbon::now()->subDays(self::$max_days);
|
|
||||||
|
|
||||||
$debug = Nuh::$options['d'] ?? 0;
|
$debug = Nuh::$options['d'] ?? 0;
|
||||||
|
|
||||||
|
$dback = Nuh::$options['days'] ?? 1;
|
||||||
|
|
||||||
|
$singleday = Nuh::$options['day'] ?? 0;
|
||||||
|
if($singleday){
|
||||||
|
$dback = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$force = Nuh::$options['f'] ?? 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* world cup => 16
|
||||||
|
* finland veikkaus => 41
|
||||||
|
*/
|
||||||
|
$tornaments = explode(',', Nuh::$options['groups']) ?? 0;
|
||||||
|
|
||||||
$sport_id = Nuh::$options['sport_id'];
|
$sport_id = Nuh::$options['sport_id'];
|
||||||
|
|
||||||
foreach (Sofascore::$_days as $day) {
|
// for ($i = 1; $i <= $dback; $i++) {
|
||||||
|
// // remove one day to start yesterday
|
||||||
|
// $day = Carbon::now()->subDays($i)->format('Y-m-d');
|
||||||
|
// if ($debug) {
|
||||||
|
// Notice::note($day, 'p');
|
||||||
|
// }
|
||||||
|
// $ss_days = SofaScoreDayTournament::with('tournament')
|
||||||
|
// ->when($tornaments, function ($query) use ($tornaments) {
|
||||||
|
// return $query->whereIn('tournament_id', $tornaments);
|
||||||
|
// })
|
||||||
|
// ->whereHas('tournament', function ($query) use ($sport_id) {
|
||||||
|
// $query->where('sport_id', $sport_id);
|
||||||
|
// })
|
||||||
|
// ->where('day', $day)->get();
|
||||||
|
// foreach ($ss_days as $ss_day) {
|
||||||
|
// $sofa_score_categorie_id = $ss_day->tournament->sofa_score_categorie_id;
|
||||||
|
// // https://www.sofascore.com/api/v1/unique-tournament/16/scheduled-events/2026-06-19
|
||||||
|
// $url = Nuh::$options['base_url'] . "api/v1/category/$sofa_score_categorie_id/scheduled-events/$day";
|
||||||
|
// Notice::note($url, 'p');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// exit;
|
||||||
|
|
||||||
|
for ($i = 1; $i <= $dback; $i++) {
|
||||||
|
|
||||||
|
// remove one day to start yesterday
|
||||||
|
$day = Carbon::now()->subDays($i)->format('Y-m-d');
|
||||||
|
|
||||||
|
// call for spezific day
|
||||||
|
if($singleday){
|
||||||
|
$dback = 1;
|
||||||
|
$day = $singleday;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($debug) {
|
||||||
|
Notice::note($day, 'p');
|
||||||
|
}
|
||||||
|
|
||||||
$ss_days = SofaScoreDayTournament::with('tournament')
|
$ss_days = SofaScoreDayTournament::with('tournament')
|
||||||
|
->when($tornaments, function ($query) use ($tornaments) {
|
||||||
|
return $query->whereIn('tournament_id', $tornaments);
|
||||||
|
})
|
||||||
->whereHas('tournament', function ($query) use ($sport_id) {
|
->whereHas('tournament', function ($query) use ($sport_id) {
|
||||||
$query->where('sport_id', $sport_id);
|
$query->where('sport_id', $sport_id);
|
||||||
})
|
})
|
||||||
->where('day', $day)->get();
|
->where('day', $day)->get();
|
||||||
|
|
||||||
foreach ($ss_days as $ss_day) {
|
foreach ($ss_days as $ss_day) {
|
||||||
|
|
||||||
$sofa_score_categorie_id = $ss_day->tournament->sofa_score_categorie_id;
|
$sofa_score_categorie_id = $ss_day->tournament->sofa_score_categorie_id;
|
||||||
|
$tournament_id = $ss_day->tournament_id;
|
||||||
|
|
||||||
$url = Nuh::$options['base_url'] . "api/v1/category/$sofa_score_categorie_id/scheduled-events/$day";
|
// $url = Nuh::$options['base_url'] . "api/v1/category/$sofa_score_categorie_id/scheduled-events/$day";
|
||||||
|
|
||||||
|
$url = Nuh::$options['base_url'] . "api/v1/unique-tournament/$tournament_id/scheduled-events/$day";
|
||||||
|
|
||||||
$rand = rand(500000, 1000000);
|
$rand = rand(500000, 1000000);
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
@@ -52,9 +104,7 @@ class Events
|
|||||||
|
|
||||||
foreach ($data['events'] as $event) {
|
foreach ($data['events'] as $event) {
|
||||||
|
|
||||||
if ($event['season']['name'] != "World Cup 2026") {
|
Notice::note($event['season']['name'].' '. $ss_day->day, 'bb');
|
||||||
Notice::note("All World Cup 2026 for " . $ss_day->day . ' grapped', 'bb', 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$folder = app_path() . self::$storage_path . $ss_day->day . '/' . $event['tournament']['slug'] . '/' . $event['slug'];
|
$folder = app_path() . self::$storage_path . $ss_day->day . '/' . $event['tournament']['slug'] . '/' . $event['slug'];
|
||||||
|
|
||||||
@@ -66,10 +116,10 @@ class Events
|
|||||||
|
|
||||||
File::put($folder . '/event.json', json_encode($event));
|
File::put($folder . '/event.json', json_encode($event));
|
||||||
|
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
* EVENT statistics
|
* EVENT statistics
|
||||||
*********************************/
|
*********************************/
|
||||||
|
|
||||||
$event_id = $event['id'];
|
$event_id = $event['id'];
|
||||||
|
|
||||||
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/statistics";
|
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/statistics";
|
||||||
@@ -87,6 +137,7 @@ class Events
|
|||||||
/*********************************
|
/*********************************
|
||||||
* EVENT lineups
|
* EVENT lineups
|
||||||
*********************************/
|
*********************************/
|
||||||
|
|
||||||
$event_id = $event['id'];
|
$event_id = $event['id'];
|
||||||
|
|
||||||
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/lineups";
|
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/lineups";
|
||||||
@@ -105,6 +156,7 @@ class Events
|
|||||||
/*********************************
|
/*********************************
|
||||||
* EVENT lineups
|
* EVENT lineups
|
||||||
*********************************/
|
*********************************/
|
||||||
|
|
||||||
$event_id = $event['id'];
|
$event_id = $event['id'];
|
||||||
|
|
||||||
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/odds/1/all";
|
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/odds/1/all";
|
||||||
|
|||||||
@@ -17,21 +17,37 @@ use Illuminate\Support\Facades\Log;
|
|||||||
|
|
||||||
class Tournament
|
class Tournament
|
||||||
{
|
{
|
||||||
public static $max_days = 30;
|
|
||||||
public static Carbon $days_back;
|
|
||||||
public static function load()
|
public static function load()
|
||||||
{
|
{
|
||||||
self::$days_back = Carbon::now()->subDays(self::$max_days);
|
|
||||||
|
|
||||||
$debug = Nuh::$options['d'] ?? 0;
|
$debug = Nuh::$options['d'] ?? 0;
|
||||||
|
|
||||||
|
$dback = Nuh::$options['days'] ?? 1;
|
||||||
|
|
||||||
|
$singleday = Nuh::$options['day'] ?? 0;
|
||||||
|
if($singleday){
|
||||||
|
$dback = 1;
|
||||||
|
}
|
||||||
|
|
||||||
$force = Nuh::$options['f'] ?? 0;
|
$force = Nuh::$options['f'] ?? 0;
|
||||||
|
|
||||||
$sport_id = Nuh::$options['sport_id'];
|
$sport_id = Nuh::$options['sport_id'];
|
||||||
|
|
||||||
$sport = Sport::where('id', $sport_id)->first();
|
$sport = Sport::where('id', $sport_id)->first();
|
||||||
|
|
||||||
foreach (Sofascore::$_days as $day) {
|
for ($i = 1; $i <= $dback; $i++) {
|
||||||
|
|
||||||
|
// remove one day to start yesterday
|
||||||
|
$day = Carbon::now()->subDays($i)->format('Y-m-d');
|
||||||
|
|
||||||
|
// call for spezific day
|
||||||
|
if($singleday){
|
||||||
|
$dback = 1;
|
||||||
|
$day = $singleday;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($debug) {
|
||||||
|
Notice::note($day, 'p');
|
||||||
|
}
|
||||||
|
|
||||||
$tournaments_counter = 0;
|
$tournaments_counter = 0;
|
||||||
|
|
||||||
@@ -41,7 +57,7 @@ class Tournament
|
|||||||
if ($force || ! SofaScoreDay::where('day', $day)->where($sport->ss_slug, 1)->first()) {
|
if ($force || ! SofaScoreDay::where('day', $day)->where($sport->ss_slug, 1)->first()) {
|
||||||
|
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
Notice::note('Grapping Sport: ' . Nuh::$options['sport'] . ' Day: ' . $day, 'g');
|
Notice::note('Grapping Sport: ' . Nuh::$options['sport'] . ' Day: ' . $day, 'p');
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = 1;
|
$page = 1;
|
||||||
@@ -63,7 +79,7 @@ class Tournament
|
|||||||
$page = false;
|
$page = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = false;
|
// $page = false;
|
||||||
|
|
||||||
foreach ($data['scheduled'] as $row) {
|
foreach ($data['scheduled'] as $row) {
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class Nuh extends Command
|
|||||||
|
|
||||||
public static $id = 0;
|
public static $id = 0;
|
||||||
|
|
||||||
protected $signature = 'nuh {process=help} {--truncate} {--days=0} {--day=0} {--id=0} {--fn=} {--gid=} {--p} {--d} {--x} {--t} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e}';
|
protected $signature = 'nuh {process=help} {--truncate} {--groups=0} {--days=0} {--day=0} {--id=0} {--fn=} {--gid=} {--p} {--d} {--x} {--t} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e} {--z}';
|
||||||
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
@@ -31,46 +31,57 @@ class Nuh extends Command
|
|||||||
self::$options['supervisor_id'] = $this->argument('process');
|
self::$options['supervisor_id'] = $this->argument('process');
|
||||||
|
|
||||||
$queries = self::$options['q'] ?? 0;
|
$queries = self::$options['q'] ?? 0;
|
||||||
|
|
||||||
|
$show_supervisors = self::$options['z'] ?? 0;
|
||||||
|
|
||||||
if ($this->argument('process') == 'help') {
|
if ($this->argument('process') == 'help') {
|
||||||
$txt = PHP_EOL;
|
$txt = PHP_EOL;
|
||||||
$txt .= 'Parameters' . PHP_EOL;
|
if(!$show_supervisors){
|
||||||
$txt .= '----------------------------------------------' . PHP_EOL;
|
$txt .= 'Parameters' . PHP_EOL;
|
||||||
$txt .= 'process [id] (required)' . PHP_EOL;
|
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||||
$txt .= '--id=matchid (optional) calling spezific id' . PHP_EOL;
|
$txt .= 'process [id] (required)' . PHP_EOL;
|
||||||
$txt .= '--fn=name (optional) [bkms, markets]' . PHP_EOL;
|
$txt .= '--id=matchid (optional) calling spezific id' . PHP_EOL;
|
||||||
$txt .= '--gid=groupid (optional) [bkms, groupid]' . PHP_EOL;
|
$txt .= '--fn=name (optional) [bkms, markets]' . PHP_EOL;
|
||||||
$txt .= '--truncate (optional)' . PHP_EOL;
|
$txt .= '--gid=groupid (optional) [bkms, groupid]' . PHP_EOL;
|
||||||
$txt .= '--day (optional) sofascore grap day format "Y-m-d" or --t for today' . PHP_EOL;
|
$txt .= '--truncate (optional)' . PHP_EOL;
|
||||||
$txt .= '--days (optional) sofascore grap days back from yesterday' . PHP_EOL;
|
$txt .= '-----------------------------------------------------------' . PHP_EOL . PHP_EOL;
|
||||||
$txt .= '----------------------------------------------' . PHP_EOL . PHP_EOL;
|
$txt .= 'Sofascore' . PHP_EOL;
|
||||||
$txt .= 'Options' . PHP_EOL;
|
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||||
$txt .= '----------------------------------------------' . PHP_EOL;
|
$txt .= '--day (optional) grap day format "Y-m-d" or --t for today' . PHP_EOL;
|
||||||
$txt .= '--t load today' . PHP_EOL;
|
$txt .= '--days (optional) grap days back from yesterday' . PHP_EOL;
|
||||||
$txt .= '--p use proxy' . PHP_EOL;
|
$txt .= '--groups (optional) csv of tournament_id\'s' . PHP_EOL;
|
||||||
$txt .= '--d debug' . PHP_EOL;
|
$txt .= '-----------------------------------------------------------' . PHP_EOL . PHP_EOL;
|
||||||
$txt .= '--f run also when odd' . PHP_EOL;
|
$txt .= 'Options' . PHP_EOL;
|
||||||
$txt .= '--x generate supervisors' . PHP_EOL;
|
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||||
$txt .= '--t load today' . PHP_EOL;
|
$txt .= '--t load today' . PHP_EOL;
|
||||||
$txt .= '--a all by id' . PHP_EOL;
|
$txt .= '--p use proxy' . PHP_EOL;
|
||||||
$txt .= '--b block update (reload all for txodds)' . PHP_EOL;
|
$txt .= '--d debug' . PHP_EOL;
|
||||||
$txt .= '--w laod this week (tx)' . PHP_EOL;
|
$txt .= '--f run also when odd' . PHP_EOL;
|
||||||
$txt .= '--g by minor groups (tx)' . PHP_EOL;
|
$txt .= '--x generate supervisors' . PHP_EOL;
|
||||||
$txt .= '--r read data from file ' . PHP_EOL;
|
$txt .= '--t load today' . PHP_EOL;
|
||||||
$txt .= '--s store data to file ' . PHP_EOL;
|
$txt .= '--a all by id' . PHP_EOL;
|
||||||
$txt .= '--f force update market' . PHP_EOL;
|
$txt .= '--b block update (reload all for txodds)' . PHP_EOL;
|
||||||
$txt .= '--q print all queries' . PHP_EOL;
|
$txt .= '--w laod this week (tx)' . PHP_EOL;
|
||||||
$txt .= '--e echo client data' . PHP_EOL;
|
$txt .= '--g by minor groups (tx)' . PHP_EOL;
|
||||||
|
$txt .= '--r read data from file ' . PHP_EOL;
|
||||||
|
$txt .= '--s store data to file ' . PHP_EOL;
|
||||||
|
$txt .= '--f force update market' . PHP_EOL;
|
||||||
|
$txt .= '--q print all queries' . PHP_EOL;
|
||||||
|
$txt .= '--e echo client data' . PHP_EOL;
|
||||||
|
$txt .= '--z show supervisors tasks' . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
$txt .= '----------------------------------------------' . PHP_EOL . PHP_EOL;
|
$txt .= '-----------------------------------------------------------' . PHP_EOL . PHP_EOL;
|
||||||
$txt .= 'Supervisors' . PHP_EOL;
|
$txt .= 'Supervisors (--z)' . PHP_EOL;
|
||||||
$txt .= '----------------------------------------------' . PHP_EOL;
|
if($show_supervisors){
|
||||||
$tmp = Supervisor::orderBy('provider_id')->get();
|
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||||
foreach ($tmp as $value) {
|
$tmp = Supervisor::orderBy('provider_id')->get();
|
||||||
if ($value->sport_id) {
|
foreach ($tmp as $value) {
|
||||||
$txt .= sprintf('% 3d', $value->id) . ' ' . $value->provider->name . ' - ' . $value->sport->name . ' ' . $value->name . PHP_EOL;
|
if ($value->sport_id) {
|
||||||
} else {
|
$txt .= sprintf('% 3d', $value->id) . ' ' . $value->provider->name . ' - ' . $value->sport->name . ' ' . $value->name . PHP_EOL;
|
||||||
$txt .= sprintf('% 3d', $value->id) . ' ' . $value->provider->name . ' - All ' . $value->name . PHP_EOL;
|
} else {
|
||||||
|
$txt .= sprintf('% 3d', $value->id) . ' ' . $value->provider->name . ' - All ' . $value->name . PHP_EOL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Notice::note($txt, 'b', 1);
|
Notice::note($txt, 'b', 1);
|
||||||
|
|||||||
Reference in new issue
Block a user