logifuture
This commit is contained in:
1 parent
91ec9d11cc
commit
0e34020a01
22 files changed
+546
-442
No files matched your search
@@ -16,9 +16,10 @@ class Curl
|
||||
$proxy = Nuh::$options['p'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note($url, 'g');
|
||||
if ($proxy) {
|
||||
Notice::note(Nuh::$options['proxy'], 'r');
|
||||
Notice::note($url.PHP_EOL.Nuh::$options['proxy'], 'b');
|
||||
} else {
|
||||
Notice::note($url, 'g');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,44 +33,8 @@ class Curl
|
||||
|
||||
return json_decode($file, true);
|
||||
}
|
||||
if ($proxy) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, Nuh::$options['proxy']);
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, ['url' => $url]);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Proxy-Auth: AIkcoRnipSgMK88WMQhOQQN3LKDrNDCIebNfPnEayJdmDeTigx',
|
||||
]);
|
||||
} else {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FAILONERROR, true);
|
||||
// POST
|
||||
if (isset($_config['post'])) {
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($_config['post']));
|
||||
}
|
||||
// JSON
|
||||
if (isset($_config['header'])) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $_config['header']);
|
||||
}
|
||||
}
|
||||
|
||||
$file = curl_exec($ch);
|
||||
|
||||
$curl_errorno = curl_errno($ch);
|
||||
if ($curl_errorno) {
|
||||
Notice::note('curl_errorno: '.self::curlerrorcode($curl_errorno));
|
||||
}
|
||||
$file = self::fetch_data_with_retries($url, $_config);
|
||||
|
||||
if ($save) {
|
||||
$filename = app_path().self::$testfiles.strtolower(str_replace(' ', '_', Nuh::$options['name'])).'.json';
|
||||
@@ -102,6 +67,78 @@ class Curl
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function fetch_data_with_retries($url, $_config = [], $max_retries = 3)
|
||||
{
|
||||
$attempt = 0;
|
||||
$timeout = 10; // seconds
|
||||
$connect_timeout = 5; // seconds
|
||||
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
$proxy = Nuh::$options['p'] ?? 0;
|
||||
|
||||
while ($attempt < $max_retries) {
|
||||
|
||||
if ($proxy) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, Nuh::$options['proxy']);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); // Total timeout
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connect_timeout); // Connection timeout
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
if (isset($_config['post'])) {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $_config['post']);
|
||||
} else {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, ['url' => $url]);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Proxy-Auth: AIkcoRnipSgMK88WMQhOQQN3LKDrNDCIebNfPnEayJdmDeTigx',
|
||||
]);
|
||||
} else {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); // Total timeout
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connect_timeout); // Connection timeout
|
||||
|
||||
curl_setopt($ch, CURLOPT_FAILONERROR, true);
|
||||
// POST
|
||||
if (isset($_config['post'])) {
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($_config['post']));
|
||||
}
|
||||
// JSON
|
||||
if (isset($_config['header'])) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $_config['header']);
|
||||
}
|
||||
}
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if ($response === false) {
|
||||
$attempt++;
|
||||
$curl_errorno = curl_errno($ch);
|
||||
if ($debug && $curl_errorno) {
|
||||
Notice::note('curl_errorno: '.self::curlerrorcode($curl_errorno));
|
||||
}
|
||||
if ($debug) {
|
||||
echo "Attempt $attempt failed. Retrying...\n";
|
||||
}
|
||||
sleep(2); // Optional: Sleep between retries
|
||||
} else {
|
||||
curl_close($ch);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
echo "All attempts failed.\n";
|
||||
curl_close($ch);
|
||||
|
||||
return null; // Return null if all retries fail
|
||||
}
|
||||
|
||||
public static function curlerrorcode($id)
|
||||
{
|
||||
$error_codes = [
|
||||
|
||||
@@ -75,7 +75,7 @@ class Fixtures
|
||||
Notice::note("Page: $page \nTotal: $total");
|
||||
}
|
||||
|
||||
if (isset($data['results']) && count($data['results'])) {
|
||||
if (isset($data['results']) && \count($data['results'])) {
|
||||
|
||||
foreach ($data['results'] as $row) {
|
||||
|
||||
@@ -88,7 +88,7 @@ class Fixtures
|
||||
'sport_id' => (int) $sport_id,
|
||||
'provider_id' => (int) Nuh::$options['provider_id'],
|
||||
'starttime' => Carbon::createFromTimestamp((string) $row['time'])->toDateTimeString(),
|
||||
'country_id' => $cc != null ? $country_map[$cc] : 0,
|
||||
'country_id' => $country_map[$cc] ?? 0,
|
||||
'home' => $row['home']['name'] ?? '',
|
||||
'home_id' => (int) $row['home']['id'],
|
||||
'home_cc' => strtoupper($row['home']['cc']) ?? '',
|
||||
|
||||
@@ -2,10 +2,18 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper;
|
||||
|
||||
use App\Console\Commands\Grapper\Logifuture\ActiveEvent;
|
||||
use App\Console\Commands\Grapper\Logifuture\Auth;
|
||||
use App\Console\Commands\Grapper\Logifuture\BaseUrl;
|
||||
use App\Console\Commands\Grapper\Logifuture\Basketball;
|
||||
use App\Console\Commands\Grapper\Logifuture\Icehockey;
|
||||
use App\Console\Commands\Grapper\Logifuture\MapEvent;
|
||||
use App\Console\Commands\Grapper\Logifuture\Soccer;
|
||||
use App\Console\Commands\Grapper\Logifuture\Tennis;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Mapper\FindFixture;
|
||||
use App\Mapper\LoadElements;
|
||||
use App\Mapper\LoadGroups;
|
||||
use App\Models\EventBookmaker;
|
||||
use App\Models\Sport;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
@@ -15,8 +23,14 @@ class Logifuture
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$_elements = LoadElements::load(Nuh::$options['provider_id'], true);
|
||||
|
||||
$_groups = LoadGroups::load(Nuh::$options['provider_id'], true);
|
||||
|
||||
$sportmap = Sport::map('logi', 1, [1, 2, 3, 5]);
|
||||
|
||||
$event_id_collector = [];
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(Nuh::$options['provider']['name'].' '.Nuh::$options['sport']['name'], 'g');
|
||||
}
|
||||
@@ -30,29 +44,37 @@ class Logifuture
|
||||
break;
|
||||
}
|
||||
|
||||
// https://external-api.bet9ja.com/external/v1/matches?sport_id=1
|
||||
// https://external-api.bet9ja.com/external
|
||||
|
||||
$data = Auth::exe();
|
||||
|
||||
foreach ($sportmap as $client_sportid => $sportid) {
|
||||
$header = [];
|
||||
$header[] = 'Authorization: Bearer '.$data['token'];
|
||||
$header[] = 'accept: application/json';
|
||||
$header[] = 'content-type: application/json';
|
||||
|
||||
foreach ($sportmap as $client_sport_id => $sport_id) {
|
||||
$post_fields = [
|
||||
'url' => BaseUrl::get().'/v1/matches?sportId='.$client_sportid,
|
||||
'header' => json_encode(['Authorization: Bearer '.$data['token'], 'accept: application/json', 'content-type: application/json']),
|
||||
'url' => BaseUrl::get().'/v1/matches?sportId='.$client_sport_id,
|
||||
'header' => json_encode($header),
|
||||
];
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, 'https://proxydb1.nuhodds.com/logifuture.php');
|
||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Proxy-Auth: AIkcoRnipSgMK88WMQhOQQN3LKDrNDCIebNfPnEayJdmDeTigx',
|
||||
]);
|
||||
|
||||
$file = curl_exec($ch);
|
||||
|
||||
$matches = json_decode($file, 1);
|
||||
|
||||
if (! isset($matches['error'])) {
|
||||
@@ -61,72 +83,47 @@ class Logifuture
|
||||
|
||||
if (strpos($match['sportCategory'], 'Simulated Reality') === false) {
|
||||
|
||||
$event = ActiveEvent::filter($sportid, $match);
|
||||
$event = MapEvent::filter($sport_id, $match);
|
||||
|
||||
dd($event);
|
||||
FindFixture::search($event, $_groups[$sport_id], $_elements[$sport_id], true);
|
||||
|
||||
$_spreads = [];
|
||||
switch ($sportid) {
|
||||
case 1:
|
||||
Soccer::get($event, $match);
|
||||
break;
|
||||
case 2:
|
||||
Icehockey::get($event, $_spreads, $match);
|
||||
break;
|
||||
case 3:
|
||||
Basket::get($event, $_spreads, $match);
|
||||
break;
|
||||
case 5:
|
||||
Tennis::get($event, $_spreads, $match);
|
||||
break;
|
||||
if ($event['id']) {
|
||||
|
||||
default:
|
||||
Notice::note('SPORT NOT IMPLEMENTED', 'r', 1);
|
||||
break;
|
||||
}
|
||||
$event_id_collector[] = $event['id'];
|
||||
|
||||
Parser::$_matches_array = [];
|
||||
Parser::$_matches_array[] = $event;
|
||||
EventBookmaker::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
||||
], ['in_feed' => 1, 'bmoid' => $event['event_id']]);
|
||||
|
||||
$matchid = Parser::processData(1);
|
||||
$_spreads = [];
|
||||
switch ($sport_id) {
|
||||
case 1:
|
||||
Soccer::get($event, $match);
|
||||
break;
|
||||
case 2:
|
||||
Icehockey::get($event, $_spreads, $match);
|
||||
break;
|
||||
case 3:
|
||||
Basketball::get($event, $_spreads, $match);
|
||||
break;
|
||||
case 5:
|
||||
Tennis::get($event, $_spreads, $match);
|
||||
break;
|
||||
|
||||
if ($matchid) {
|
||||
|
||||
$event['matchid'] = $matchid;
|
||||
|
||||
if (isset($_spreads['point'])) {
|
||||
$tmp = $event + $_spreads['point'];
|
||||
DB_Parser::addPointOdds('bai_points', $matchid, $tmp);
|
||||
}
|
||||
|
||||
if (isset($_spreads['point_qt'])) {
|
||||
$tmp = $event + $_spreads['point_qt'];
|
||||
DB_Parser::addPointOdds('bai_points_qt', $matchid, $tmp);
|
||||
}
|
||||
|
||||
if (isset($_spreads['total'])) {
|
||||
$tmp = $event + $_spreads['total'];
|
||||
DB_Parser::addTotalOdds('bai_totals', $matchid, $tmp);
|
||||
}
|
||||
|
||||
if (isset($_spreads['total_qt'])) {
|
||||
$tmp = $event + $_spreads['total_qt'];
|
||||
DB_Parser::addTotalOdds('bai_totals_qt', $matchid, $tmp);
|
||||
}
|
||||
|
||||
if (isset($_spreads['mlset1'])) {
|
||||
$tmp = $event + $_spreads['mlset1'];
|
||||
DB_Parser::addTotalOdds('bai_2way_set1', $matchid, $tmp);
|
||||
}
|
||||
|
||||
if (Database::$debug) {
|
||||
Notice::note($event, 'y');
|
||||
default:
|
||||
Notice::note('SPORT NOT IMPLEMENTED', 'r', 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Parser::flagStatus($sportid);
|
||||
|
||||
}
|
||||
}
|
||||
if ($event_id_collector) {
|
||||
EventBookmaker::whereNotIn('event_id', $event_id_collector)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->update(['in_feed' => 0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Logifuture;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
|
||||
class ActiveEvent
|
||||
{
|
||||
public static function filter($sportid, $match)
|
||||
{
|
||||
$event = [];
|
||||
$event['status'] = 1;
|
||||
$event['bmoid'] = (int) $match['id'];
|
||||
$event['bkmid'] = Nuh::$options['bookmaker_id'];
|
||||
$event['sportid'] = $sportid;
|
||||
$event['brmatchid'] = (int) preg_replace('"\D"', '', $match['externalId']);
|
||||
|
||||
$date = new DateTime($match['startDate'], new DateTimeZone('UTC'));
|
||||
$date->setTimezone(new DateTimeZone('Europe/Vienna'));
|
||||
$event['starttime'] = $date->getTimestamp();
|
||||
|
||||
$event['groupname'] = addslashes($match['tournamentName']);
|
||||
$event['groupid'] = (int) $match['tournamentId'];
|
||||
$event['country'] = addslashes($match['sportCategory']);
|
||||
$str = str_replace('||', '|', $match['description']);
|
||||
$str = trim(str_replace('|', ' ', $str));
|
||||
$event['event'] = addslashes($str);
|
||||
if (Nuh::$options['bookmaker_id'] == 36) {
|
||||
$teams = explode(' v ', $str);
|
||||
} else {
|
||||
$teams = explode(' - ', $str);
|
||||
}
|
||||
$event['home'] = addslashes($teams[0]);
|
||||
$event['away'] = addslashes($teams[1]);
|
||||
|
||||
return $event;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Logifuture;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class MapEvent
|
||||
{
|
||||
public static function filter($sport_id, $match)
|
||||
{
|
||||
|
||||
$event = [];
|
||||
$event['event_id'] = (int) $match['id'];
|
||||
$event['bookmaker_id'] = Nuh::$options['bookmaker_id'];
|
||||
$event['betradar_id'] = (int) preg_replace('"\D"', '', $match['externalId']);
|
||||
$event['sport_id'] = $sport_id;
|
||||
$event['provider_id'] = Nuh::$options['provider_id'];
|
||||
$event['starttime'] = Carbon::parse($match['startDate'])->toDateTimeString();
|
||||
$event['country'] = $match['sportCategory'];
|
||||
$event['group_id'] = (int) $match['tournamentId'];
|
||||
$event['group'] = addslashes($match['tournamentName']);
|
||||
|
||||
$str = str_replace('||', '|', $match['description']);
|
||||
$str = trim(str_replace('|', ' ', $str));
|
||||
if (Nuh::$options['bookmaker_id'] == 36) {
|
||||
$teams = explode(' v ', $str);
|
||||
} else {
|
||||
$teams = explode(' - ', $str);
|
||||
}
|
||||
$event['home'] = addslashes($teams[0]);
|
||||
$event['away'] = addslashes($teams[1]);
|
||||
|
||||
return $event;
|
||||
}
|
||||
}
|
||||
@@ -2,58 +2,135 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Logifuture;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Odds3way;
|
||||
use App\Models\OddsDc;
|
||||
use App\Models\OddsGgng;
|
||||
use App\Models\OddsTotal;
|
||||
use App\Models\OddsTq;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class Soccer
|
||||
{
|
||||
public static function get(&$event, $match)
|
||||
{
|
||||
$_3way = [];
|
||||
$_total = [];
|
||||
$_ggng = [];
|
||||
$_dc = [];
|
||||
$_tq = [];
|
||||
|
||||
foreach ($match['odds'] as $name => $value) {
|
||||
switch ($name) {
|
||||
case 'S_1X2_1':
|
||||
$event['h3w'] = (float) $value;
|
||||
$_3way['h3w'] = (float) $value;
|
||||
break;
|
||||
case 'S_1X2_X':
|
||||
$event['d3w'] = (float) $value;
|
||||
$_3way['d3w'] = (float) $value;
|
||||
break;
|
||||
case 'S_1X2_2':
|
||||
$event['a3w'] = (float) $value;
|
||||
$_3way['a3w'] = (float) $value;
|
||||
break;
|
||||
|
||||
case 'S_OU@2.5_O':
|
||||
$event['total'] = 2.5;
|
||||
$event['over'] = (float) $value;
|
||||
$_total['over'] = (float) $value;
|
||||
break;
|
||||
case 'S_OU@2.5_U':
|
||||
$event['total'] = 2.5;
|
||||
$event['under'] = (float) $value;
|
||||
$_total['under'] = (float) $value;
|
||||
break;
|
||||
|
||||
case 'S_GGNG_Y':
|
||||
$event['gg'] = (float) $value;
|
||||
$_ggng['gg'] = (float) $value;
|
||||
break;
|
||||
case 'S_GGNG_N':
|
||||
$event['ng'] = (float) $value;
|
||||
$_ggng['ng'] = (float) $value;
|
||||
break;
|
||||
// case 'S_DNB_1':
|
||||
// break;
|
||||
// case 'S_DNB_2':
|
||||
// break;
|
||||
// case 'S_DC_12':
|
||||
// $event['dc12'] = (float) $value;
|
||||
// break;
|
||||
// case 'S_DC_1X':
|
||||
// $event['dc1x'] = (float) $value;
|
||||
// break;
|
||||
// case 'S_DC_X2':
|
||||
// $event['dcx2'] = (float) $value;
|
||||
// break;
|
||||
case 'S_DC_12':
|
||||
$_dc['dc12'] = (float) $value;
|
||||
break;
|
||||
case 'S_DC_1X':
|
||||
$_dc['dc1x'] = (float) $value;
|
||||
break;
|
||||
case 'S_DC_X2':
|
||||
$_dc['dcx2'] = (float) $value;
|
||||
break;
|
||||
|
||||
case 'S_12QUALIFY_1':
|
||||
$event['one'] = (float) $value;
|
||||
$_tq['htq'] = (float) $value;
|
||||
break;
|
||||
case 'S_12QUALIFY_2':
|
||||
$event['two'] = (float) $value;
|
||||
$_tq['atq'] = (float) $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$base = [];
|
||||
$base['sport_id'] = $event['sport_id'];
|
||||
$base['provider_id'] = Nuh::$options['provider_id'];
|
||||
$base['bmoid'] = $event['event_id'];
|
||||
$base['flag'] = 1;
|
||||
|
||||
// 1x2
|
||||
if (\count($_3way) == 3) {
|
||||
|
||||
$_3way['margin'] = (float) Margin::calculate($_3way, 1);
|
||||
$_3way['starttime'] = $event['starttime'];
|
||||
|
||||
Odds3way::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => $event['bookmaker_id'],
|
||||
], $base + $_3way);
|
||||
}
|
||||
// OU
|
||||
if (\count($_total) == 2) {
|
||||
|
||||
$_total['margin'] = (float) Margin::calculate($_total, 1);
|
||||
$_total['total'] = 2.5;
|
||||
$_total['starttime'] = $event['starttime'];
|
||||
|
||||
OddsTotal::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => $event['bookmaker_id'],
|
||||
], $base + $_total);
|
||||
}
|
||||
// GG NG
|
||||
if (\count($_ggng) == 2) {
|
||||
|
||||
$_ggng['margin'] = (float) Margin::calculate($_ggng, 1);
|
||||
$_ggng['starttime'] = $event['starttime'];
|
||||
|
||||
OddsGgng::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => $event['bookmaker_id'],
|
||||
], $base + $_ggng);
|
||||
}
|
||||
|
||||
// DC
|
||||
if (\count($_dc) == 3) {
|
||||
|
||||
$_dc['margin'] = (float) Margin::calculate($_dc, 1);
|
||||
$_dc['starttime'] = $event['starttime'];
|
||||
|
||||
OddsDc::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => $event['bookmaker_id'],
|
||||
], $base + $_dc);
|
||||
}
|
||||
|
||||
// TQ
|
||||
if (\count($_tq) == 2) {
|
||||
|
||||
$_tq['margin'] = (float) Margin::calculate($_tq, 1);
|
||||
$_tq['starttime'] = $event['starttime'];
|
||||
|
||||
OddsTq::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => $event['bookmaker_id'],
|
||||
], $base + $_tq);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,6 @@ class Fixtures
|
||||
$event['betradar_id'] = (int) preg_replace('/\D/', '', $magloo['p']);
|
||||
$event['sport_id'] = $sport_id;
|
||||
$event['provider_id'] = Nuh::$options['provider_id'];
|
||||
$event['starttime'] = strtotime($magloo['dt']);
|
||||
$event['country_id'] = $liga['country_id'];
|
||||
$event['country'] = $liga['country'];
|
||||
$event['group_id'] = $liga['group_id'];
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Console\Commands\Grapper\Magloo;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Grapper\Magloo\Odds\FilterHandicap;
|
||||
use App\Console\Commands\Grapper\Magloo\Odds\FilterHandicapQ1;
|
||||
use App\Console\Commands\Grapper\Magloo\Odds\FilterTotals;
|
||||
use App\Console\Commands\Grapper\Magloo\Odds\FilterTotalsQ1;
|
||||
use App\Console\Commands\Nuh;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Utilities\Notice;
|
||||
use SimpleXMLElement;
|
||||
|
||||
class Xml
|
||||
{
|
||||
@@ -48,7 +49,7 @@ class Xml
|
||||
}
|
||||
}
|
||||
|
||||
$data = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
$data = self::fetch_data_with_retries($url);
|
||||
|
||||
if ($data === false && $debug) {
|
||||
Notice::note("Error: Failed to load XML from $url", 'r', 1);
|
||||
@@ -73,4 +74,35 @@ class Xml
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function fetch_data_with_retries($url, $max_retries = 3)
|
||||
{
|
||||
$attempt = 0;
|
||||
$timeout = 10; // seconds
|
||||
$connect_timeout = 5; // seconds
|
||||
|
||||
while ($attempt < $max_retries) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); // Total timeout
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connect_timeout); // Connection timeout
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if ($response === false) {
|
||||
$attempt++;
|
||||
echo "Attempt $attempt failed. Retrying...\n";
|
||||
sleep(2); // Optional: Sleep between retries
|
||||
} else {
|
||||
curl_close($ch);
|
||||
|
||||
return new SimpleXMLElement($response);
|
||||
}
|
||||
}
|
||||
echo "All attempts failed.\n";
|
||||
curl_close($ch);
|
||||
|
||||
return null; // Return null if all retries fail
|
||||
}
|
||||
}
|
||||
+76
-37
@@ -10,8 +10,10 @@ use Illuminate\Support\Carbon;
|
||||
|
||||
class FindFixture
|
||||
{
|
||||
public static function search($event, &$groups, &$elements)
|
||||
public static function search(&$event, &$groups, &$elements, $find_by_name = false)
|
||||
{
|
||||
$match_id = false;
|
||||
|
||||
$event_id = $event['event_id'];
|
||||
|
||||
$betradar_id = $event['betradar_id'] ?? 0;
|
||||
@@ -24,8 +26,6 @@ class FindFixture
|
||||
|
||||
$bwin_id = $event['bwin_id'] ?? 0;
|
||||
|
||||
unset($event['event_id']);
|
||||
|
||||
switch ($event['provider_id']) {
|
||||
case 2:
|
||||
// BETSAPI
|
||||
@@ -53,12 +53,15 @@ class FindFixture
|
||||
if (! $match_id && $betradar_id) {
|
||||
$match_id = Event::where('betradar_id', $betradar_id)->value('id');
|
||||
}
|
||||
|
||||
$home_id = $elements[$event['home_id']] ?? 0;
|
||||
|
||||
$away_id = $elements[$event['away_id']] ?? 0;
|
||||
|
||||
$cgid = $groups[$event['group_id']] ?? 0;
|
||||
if ($find_by_name) {
|
||||
$home = $elements[$event['home']] ?? 0;
|
||||
$away = $elements[$event['away']] ?? 0;
|
||||
$groupname = $groups[$event['group']] ?? 0;
|
||||
} else {
|
||||
$home_id = $elements[$event['home_id']] ?? 0;
|
||||
$away_id = $elements[$event['away_id']] ?? 0;
|
||||
$competition_group_id = $groups[$event['group_id']] ?? 0;
|
||||
}
|
||||
|
||||
if ($match_id) {
|
||||
|
||||
@@ -66,29 +69,50 @@ class FindFixture
|
||||
|
||||
$match = Event::where('id', $match_id)->first();
|
||||
|
||||
if (! $home_id) {
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $event['sport_id'];
|
||||
$ele['provider_id'] = $event['provider_id'];
|
||||
$ele['element_id'] = $match->home_id ?? 0;
|
||||
$ele['name'] = $event['home'];
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $event['home_id']], $ele);
|
||||
}
|
||||
if (! $away_id) {
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $event['sport_id'];
|
||||
$ele['provider_id'] = $event['provider_id'];
|
||||
$ele['element_id'] = $match->away_id ?? 0;
|
||||
$ele['name'] = $event['away'];
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $event['away_id']], $ele);
|
||||
}
|
||||
if (! $cgid) {
|
||||
$group = [];
|
||||
$group['sport_id'] = $event['sport_id'];
|
||||
$group['provider_id'] = $event['provider_id'];
|
||||
$group['competition_group_id'] = $match->competition_group_id;
|
||||
$group['name'] = $event['group'];
|
||||
CompetitionGroupProvider::updateOrCreate(['provider_group_id' => (int) $event['group_id']], $group);
|
||||
if ($find_by_name) {
|
||||
if (! $home) {
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $event['sport_id'];
|
||||
$ele['provider_id'] = $event['provider_id'];
|
||||
ElementProvider::updateOrCreate(['name' => (int) $event['home']], $ele);
|
||||
}
|
||||
if (! $away) {
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $event['sport_id'];
|
||||
$ele['provider_id'] = $event['provider_id'];
|
||||
ElementProvider::updateOrCreate(['name' => (int) $event['away']], $ele);
|
||||
}
|
||||
if (! $groupname) {
|
||||
$group = [];
|
||||
$group['sport_id'] = $event['sport_id'];
|
||||
$group['provider_id'] = $event['provider_id'];
|
||||
CompetitionGroupProvider::updateOrCreate(['name' => (int) $event['group']], $group);
|
||||
}
|
||||
} else {
|
||||
if (! $home_id) {
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $event['sport_id'];
|
||||
$ele['provider_id'] = $event['provider_id'];
|
||||
$ele['element_id'] = $match->home_id ?? 0;
|
||||
$ele['name'] = $event['home'];
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $event['home_id']], $ele);
|
||||
}
|
||||
if (! $away_id) {
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $event['sport_id'];
|
||||
$ele['provider_id'] = $event['provider_id'];
|
||||
$ele['element_id'] = $match->away_id ?? 0;
|
||||
$ele['name'] = $event['away'];
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $event['away_id']], $ele);
|
||||
}
|
||||
if (! $competition_group_id) {
|
||||
$group = [];
|
||||
$group['sport_id'] = $event['sport_id'];
|
||||
$group['provider_id'] = $event['provider_id'];
|
||||
$group['competition_group_id'] = $match->competition_group_id;
|
||||
$group['name'] = $event['group'];
|
||||
CompetitionGroupProvider::updateOrCreate(['provider_group_id' => (int) $event['group_id']], $group);
|
||||
}
|
||||
}
|
||||
|
||||
$update_array = [];
|
||||
@@ -144,18 +168,31 @@ class FindFixture
|
||||
|
||||
$startime = $event['starttime'];
|
||||
|
||||
if ($home_id && $away_id && $cgid) {
|
||||
$from = Carbon::createFromDate($startime)->subDay();
|
||||
|
||||
$from = Carbon::createFromDate($startime)->subDay();
|
||||
$to = Carbon::createFromDate($startime)->addDay();
|
||||
|
||||
$to = Carbon::createFromDate($startime)->addDay();
|
||||
if ($find_by_name) {
|
||||
$home_id = ElementProvider::where(['sport_id' => (int) $event['sport_id']])
|
||||
->where('provider_id', $event['provider_id'])
|
||||
->where('name', $home)
|
||||
->value('element_id');
|
||||
$away_id = ElementProvider::where(['sport_id' => (int) $event['sport_id']])
|
||||
->where('provider_id', $event['provider_id'])
|
||||
->where('name', $away)
|
||||
->value('element_id');
|
||||
$competition_group_id = CompetitionGroupProvider::where(['sport_id' => (int) $event['sport_id']])
|
||||
->where('provider_id', $event['provider_id'])
|
||||
->where('name', $groupname)
|
||||
->value('competition_group_id');
|
||||
}
|
||||
|
||||
// dd($home_id, $away_id, $cgid, $from->toDateTimeString(), $to->toDateTimeString());
|
||||
if ($home_id && $away_id && $competition_group_id) {
|
||||
|
||||
$match_id = Event::query()
|
||||
->where('home_id', $home_id)
|
||||
->where('away_id', $away_id)
|
||||
->where('competition_group_id', $cgid)
|
||||
->where('competition_group_id', $competition_group_id)
|
||||
->where('starttime', '>', $from->toDateTimeString())
|
||||
->where('starttime', '<', $to->toDateTimeString())
|
||||
->value('id');
|
||||
@@ -208,5 +245,7 @@ class FindFixture
|
||||
Mapper::updateOrCreate(['event_id' => $event_id], $event);
|
||||
}
|
||||
}
|
||||
|
||||
$event['id'] = $match_id;
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,17 @@ use App\Models\ElementProvider;
|
||||
|
||||
class LoadElements
|
||||
{
|
||||
public static function load($provider_id)
|
||||
public static function load($provider_id, $load_by_name = false)
|
||||
{
|
||||
$res = ElementProvider::where('provider_id', $provider_id)->get();
|
||||
|
||||
$r = [];
|
||||
foreach ($res as $val) {
|
||||
$r[$val->sport_id][$val->provider_element_id] = $val->element_id;
|
||||
if ($load_by_name) {
|
||||
$r[$val->sport_id][$val->name] = $val->element_id;
|
||||
} else {
|
||||
$r[$val->sport_id][$val->provider_element_id] = $val->element_id;
|
||||
}
|
||||
}
|
||||
|
||||
return $r;
|
||||
|
||||
@@ -6,13 +6,17 @@ use App\Models\CompetitionGroupProvider;
|
||||
|
||||
class LoadGroups
|
||||
{
|
||||
public static function load($provider_id)
|
||||
public static function load($provider_id, $load_by_name = false)
|
||||
{
|
||||
$res = CompetitionGroupProvider::where('provider_id', $provider_id)->get();
|
||||
|
||||
$r = [];
|
||||
foreach ($res as $val) {
|
||||
$r[$val->sport_id][$val->provider_group_id] = $val->competition_group_id;
|
||||
if ($load_by_name) {
|
||||
$r[$val->sport_id][$val->name] = $val->competition_group_id;
|
||||
} else {
|
||||
$r[$val->sport_id][$val->provider_group_id] = $val->competition_group_id;
|
||||
}
|
||||
}
|
||||
|
||||
return $r;
|
||||
|
||||
Reference in new issue
Block a user