grapper wip
This commit is contained in:
1 parent
3117a8dcbd
commit
7aa3c90344
3 files changed
+106
-27
No files matched your search
@@ -11,22 +11,71 @@ use Illuminate\Support\Facades\File;
|
||||
|
||||
class Events
|
||||
{
|
||||
public static $max_days = 30;
|
||||
public static Carbon $days_back;
|
||||
|
||||
public static $storage_path = '/Console/Commands/Grapper/Sofascore/grapped/';
|
||||
|
||||
public static function load()
|
||||
{
|
||||
self::$days_back = Carbon::now()->subDays(self::$max_days);
|
||||
|
||||
$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'];
|
||||
|
||||
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')
|
||||
->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);
|
||||
})
|
||||
@@ -35,8 +84,11 @@ class Events
|
||||
foreach ($ss_days as $ss_day) {
|
||||
|
||||
$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);
|
||||
if ($debug) {
|
||||
@@ -52,9 +104,7 @@ class Events
|
||||
|
||||
foreach ($data['events'] as $event) {
|
||||
|
||||
if ($event['season']['name'] != "World Cup 2026") {
|
||||
Notice::note("All World Cup 2026 for " . $ss_day->day . ' grapped', 'bb', 1);
|
||||
}
|
||||
Notice::note($event['season']['name'].' '. $ss_day->day, 'bb');
|
||||
|
||||
$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));
|
||||
|
||||
|
||||
/*********************************
|
||||
* EVENT statistics
|
||||
*********************************/
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/statistics";
|
||||
@@ -87,6 +137,7 @@ class Events
|
||||
/*********************************
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/lineups";
|
||||
@@ -105,6 +156,7 @@ class Events
|
||||
/*********************************
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/odds/1/all";
|
||||
|
||||
@@ -17,21 +17,37 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Tournament
|
||||
{
|
||||
public static $max_days = 30;
|
||||
public static Carbon $days_back;
|
||||
public static function load()
|
||||
{
|
||||
self::$days_back = Carbon::now()->subDays(self::$max_days);
|
||||
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$dback = Nuh::$options['days'] ?? 1;
|
||||
|
||||
$singleday = Nuh::$options['day'] ?? 0;
|
||||
if($singleday){
|
||||
$dback = 1;
|
||||
}
|
||||
|
||||
$force = Nuh::$options['f'] ?? 0;
|
||||
|
||||
$sport_id = Nuh::$options['sport_id'];
|
||||
|
||||
$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;
|
||||
|
||||
@@ -41,7 +57,7 @@ class Tournament
|
||||
if ($force || ! SofaScoreDay::where('day', $day)->where($sport->ss_slug, 1)->first()) {
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('Grapping Sport: ' . Nuh::$options['sport'] . ' Day: ' . $day, 'g');
|
||||
Notice::note('Grapping Sport: ' . Nuh::$options['sport'] . ' Day: ' . $day, 'p');
|
||||
}
|
||||
|
||||
$page = 1;
|
||||
@@ -63,7 +79,7 @@ class Tournament
|
||||
$page = false;
|
||||
}
|
||||
|
||||
$page = false;
|
||||
// $page = false;
|
||||
|
||||
foreach ($data['scheduled'] as $row) {
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class Nuh extends Command
|
||||
|
||||
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()
|
||||
{
|
||||
@@ -32,20 +32,27 @@ class Nuh extends Command
|
||||
|
||||
$queries = self::$options['q'] ?? 0;
|
||||
|
||||
$show_supervisors = self::$options['z'] ?? 0;
|
||||
|
||||
if ($this->argument('process') == 'help') {
|
||||
$txt = PHP_EOL;
|
||||
if(!$show_supervisors){
|
||||
$txt .= 'Parameters' . PHP_EOL;
|
||||
$txt .= '----------------------------------------------' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||
$txt .= 'process [id] (required)' . PHP_EOL;
|
||||
$txt .= '--id=matchid (optional) calling spezific id' . PHP_EOL;
|
||||
$txt .= '--fn=name (optional) [bkms, markets]' . PHP_EOL;
|
||||
$txt .= '--gid=groupid (optional) [bkms, groupid]' . PHP_EOL;
|
||||
$txt .= '--truncate (optional)' . PHP_EOL;
|
||||
$txt .= '--day (optional) sofascore grap day format "Y-m-d" or --t for today' . 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 .= '-----------------------------------------------------------' . PHP_EOL;
|
||||
$txt .= '--day (optional) grap day format "Y-m-d" or --t for today' . PHP_EOL;
|
||||
$txt .= '--days (optional) grap days back from yesterday' . PHP_EOL;
|
||||
$txt .= '--groups (optional) csv of tournament_id\'s' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL . PHP_EOL;
|
||||
$txt .= 'Options' . PHP_EOL;
|
||||
$txt .= '----------------------------------------------' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||
$txt .= '--t load today' . PHP_EOL;
|
||||
$txt .= '--p use proxy' . PHP_EOL;
|
||||
$txt .= '--d debug' . PHP_EOL;
|
||||
@@ -61,10 +68,13 @@ class Nuh extends Command
|
||||
$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 .= 'Supervisors' . PHP_EOL;
|
||||
$txt .= '----------------------------------------------' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL . PHP_EOL;
|
||||
$txt .= 'Supervisors (--z)' . PHP_EOL;
|
||||
if($show_supervisors){
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||
$tmp = Supervisor::orderBy('provider_id')->get();
|
||||
foreach ($tmp as $value) {
|
||||
if ($value->sport_id) {
|
||||
@@ -73,6 +83,7 @@ class Nuh extends Command
|
||||
$txt .= sprintf('% 3d', $value->id) . ' ' . $value->provider->name . ' - All ' . $value->name . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
Notice::note($txt, 'b', 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user