magloo grapper fix

This commit is contained in:
salam committed 2026-02-22 14:41:29 +01:00
1 parent 57a2d75b57
commit f424f33c32
9 files changed
+215 -176

No files matched your search

@@ -21,9 +21,9 @@ class Fixtures
FindFixture::start();
$event_id_collector = [];
$sportmap = Sport::map('magl', false, [1, 3]);
$sportmap = Sport::map('magl', 1, [1, 3]);
// dd($sportmap);
if ($proxy) {
Notice::note('PROXY USED', 'r');
@@ -33,88 +33,99 @@ class Fixtures
Notice::note(Nuh::$options['provider'].' '.Nuh::$options['name'], 'g');
}
/**
* Tornaments
*/
$url = Nuh::$options['base_url'].'/en/1/prematch/sport';
foreach ($sportmap as $sport_id => $magloo_sport_id) {
$data = Curl::load($url);
$event_id_collector = [];
/**
* Tornaments
*/
$url = Nuh::$options['base_url'].'/en/'.$magloo_sport_id.'/prematch/sport';
if (! is_array($data) or \count($data) == 0) {
Notice::note('no data in feed', 'r', 1);
$data = Curl::load($url);
return;
}
if (is_array($data) or \count($data)) {
$ligas = [];
foreach ($data as $value) {
$magloo_sport_id = (int) $value['i'];
if (array_key_exists($magloo_sport_id, $sportmap)) {
$tmp = [];
$tmp['sport'] = $value['n'];
$tmp['sport_id'] = $sportmap[$magloo_sport_id];
$tmp['magloo_sport_id'] = $magloo_sport_id;
foreach ($value['C'] as $key => $val1) {
$tmp['country_id'] = $val1['i'];
$tmp['country'] = $val1['n'];
foreach ($val1['T'] as $key => $val2) {
$tmp['group_id'] = $val2['i'];
$tmp['group'] = $val2['n'];
$ligas[] = $tmp;
$ligas = [];
foreach ($data as $value) {
$tmp = [];
if ($value['i'] == $magloo_sport_id) {
$tmp['sport'] = $value['n'];
$tmp['sport_id'] = $sport_id;
foreach ($value['C'] as $key => $val1) {
$tmp['country_id'] = $val1['i'];
$tmp['country'] = $val1['n'];
foreach ($val1['T'] as $key => $val2) {
$tmp['group_id'] = $val2['i'];
$tmp['group'] = $val2['n'];
$ligas[] = $tmp;
}
}
}
}
}
}
foreach ($ligas as $liga) {
if ($liga['group'] && strpos($liga['group'], 'Simulated') === false) {
foreach ($ligas as $liga) {
$sport_id = $liga['sport_id'];
// 19 => array:6 [
// "sport" => "Basketball"
// "sport_id" => 3
// "country_id" => 146
// "country" => "Israel"
// "group_id" => 525
// "group" => "Super League"
// ]
$url = Nuh::$options['base_url'].'/en/1/prematch/tournament/'.$liga['group_id'].'/event';
if ($liga['group'] && strpos($liga['group'], 'Simulated') === false) {
$data = Curl::load($url);
$sport_id = $liga['sport_id'];
if (! count($data)) {
return;
}
$url = Nuh::$options['base_url'].'/en/'.$magloo_sport_id.'/prematch/tournament/'.$liga['group_id'].'/event';
foreach ($data as $magloo) {
$data = Curl::load($url);
// print_r($magloo);
if (! count($data)) {
return;
}
$event = [];
$event['event_id'] = (int) $magloo['i'];
$event['betradar_id'] = (int) preg_replace('/\D/', '', $magloo['p']);
$event['sport_id'] = $sport_id;
$event['provider_id'] = Nuh::$options['provider_id'];
$event['country_id'] = $liga['country_id'];
$event['country'] = $liga['country'];
$event['group_id'] = $liga['group_id'];
$event['group'] = $liga['group'];
$event['starttime'] = Carbon::parse($magloo['dt'])->toDateTimeString();
$teams = explode(' v ', str_replace('|', ' ', $magloo['n']));
$event['home_id'] = $magloo['htId'];
$event['home'] = addslashes($teams[0]);
$event['away_id'] = $magloo['atId'];
$event['away'] = addslashes($teams[1]);
foreach ($data as $magloo) {
FindFixture::find($event);
$event = [];
$event['event_id'] = (int) $magloo['i'];
$event['betradar_id'] = (int) preg_replace('/\D/', '', $magloo['p']);
$event['sport_id'] = $sport_id;
$event['provider_id'] = Nuh::$options['provider_id'];
$event['country_id'] = $liga['country_id'];
$event['country'] = $liga['country'];
$event['group_id'] = $liga['group_id'];
$event['group'] = $liga['group'];
$event['starttime'] = Carbon::parse($magloo['dt'])->toDateTimeString();
$teams = explode(' v ', str_replace('|', ' ', $magloo['n']));
$event['home_id'] = $magloo['htId'];
$event['home'] = addslashes($teams[0]);
$event['away_id'] = $magloo['atId'];
$event['away'] = addslashes($teams[1]);
if (isset($event['id'])) {
DB::transaction(function () use ($event, $sport_id) {
EventBookmaker::updateOrCreate([
'event_id' => $event['id'],
'sport_id' => $sport_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'starttime' => $event['starttime']]);
}, 5);
FindFixture::find($event);
if (isset($event['id'])) {
$event_id_collector[] = $event['id'];
DB::transaction(function () use ($event, $sport_id) {
EventBookmaker::updateOrCreate([
'event_id' => $event['id'],
'sport_id' => $sport_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'],
], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'starttime' => $event['starttime']]);
}, 5);
}
}
}
}
if ($event_id_collector) {
EventBookmaker::whereNotIn('event_id', $event_id_collector)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->update(['in_feed' => 0]);
}
}
}
if ($event_id_collector) {
EventBookmaker::whereNotIn('event_id', $event_id_collector)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->update(['in_feed' => 0]);
}
}
}