wip fix
This commit is contained in:
1 parent
9bcd4432c6
commit
6f92f9e1d5
1209 files changed
+220940
No files matched your search
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Grapper\Fixtures\FindFixture;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Odds3way;
|
||||
use App\Models\OddsDc;
|
||||
use App\Models\OddsGgng;
|
||||
use App\Models\OddsTotal;
|
||||
use App\Utilities\Margin;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Betica
|
||||
{
|
||||
public static function switch()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(Nuh::$options['provider'], 'g');
|
||||
}
|
||||
|
||||
/**
|
||||
* periods
|
||||
* -1 Today
|
||||
* -2 Next 48hrs
|
||||
* 1 Tomorrow
|
||||
* 2 Saturday
|
||||
* 3 Sunday
|
||||
* 4 Monday
|
||||
* 5 Tuesday
|
||||
* 6 Wednesday
|
||||
* 7 Thursday
|
||||
* 8 Next Week
|
||||
* 9 All
|
||||
*/
|
||||
|
||||
/**
|
||||
* sort_options
|
||||
* 1 Highlights
|
||||
* 2 Start time
|
||||
* 3 Top leagues
|
||||
*/
|
||||
|
||||
/**
|
||||
* with limit
|
||||
* https://api.betika.com/v1/uo/matches?page=1&limit=10&tab=&sub_type_id=1,10,18,29&sport_id=14&tag_id=&sort_id=1&period_id=-1&esports=false
|
||||
*
|
||||
* ohne limit comes 100,
|
||||
* https://api.betika.com/v1/uo/matches?page=1&tab=&sub_type_id=1,10,18,29&sport_id=14&tag_id=&sort_id=1&period_id=9&esports=false
|
||||
*
|
||||
* in meta tag are the totals
|
||||
* "meta": {"total": "1053",
|
||||
*
|
||||
* loop max 100
|
||||
*/
|
||||
|
||||
/**
|
||||
* bettypes
|
||||
* 1 => 1X2
|
||||
* 10 => DOUBLE CHANCE
|
||||
* 18 => TOTAL
|
||||
* 19 => BOTH TEAMS TO SCORE (GG/NG)
|
||||
* sub_type_id=1,10,18,29
|
||||
*/
|
||||
|
||||
/**
|
||||
* TOR exit nodes
|
||||
* TANZANIA, UNITED REPUBLIC OF {tz}
|
||||
* KENYA {ke}
|
||||
* UGANDA {ug}
|
||||
* SOMALIA ? {so}
|
||||
* ETHIOPIA {et}
|
||||
*
|
||||
* ExitNodes {ke},{tz},{ug},{et}
|
||||
* vi /etc/tor/torrc
|
||||
*/
|
||||
for ($page = 1; $page < 20; $page++) {
|
||||
|
||||
$url = "https://api.betika.com/v1/uo/matches?page=$page&limit=100&sub_type_id=1,10,18,29&sport_id=14&sort_id=2&period_id=9&esports=false";
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
if (! is_array($data['data']) or \count($data['data']) == 0) {
|
||||
if ($debug) {
|
||||
Notice::note('NO DATA', 'r');
|
||||
}
|
||||
|
||||
return;
|
||||
} else {
|
||||
$total = $data['meta']['total'];
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('Total: '.$total, 'b');
|
||||
}
|
||||
|
||||
foreach ($data['data'] as $row) {
|
||||
|
||||
if (isset($row['parent_match_id']) && ! $row['is_esport']) {
|
||||
|
||||
$event = [
|
||||
'event_id' => (int) $row['match_id'],
|
||||
'betradar_id' => (int) $row['parent_match_id'] ?? 0,
|
||||
'sport_id' => (int) Nuh::$options['sport_id'],
|
||||
'provider_id' => (int) Nuh::$options['provider_id'],
|
||||
'starttime' => (string) $row['start_time'],
|
||||
'country' => $row['category'] ?? 0,
|
||||
'home' => $row['home_team'] ?? '',
|
||||
'away' => $row['away_team'] ?? '',
|
||||
'group' => $row['competition_name'] ?? '',
|
||||
'group_id' => (int) $row['competition_id'] ?? 0,
|
||||
];
|
||||
|
||||
FindFixture::find($event);
|
||||
|
||||
if (isset($event['id'])) {
|
||||
|
||||
$base = [];
|
||||
$base['sport_id'] = (int) Nuh::$options['sport_id'];
|
||||
$base['provider_id'] = Nuh::$options['provider_id'];
|
||||
$base['bmoid'] = (int) $row['match_id'];
|
||||
$base['flag'] = 1;
|
||||
|
||||
foreach ($row['odds'] as $bettypes) {
|
||||
|
||||
switch ($bettypes['sub_type_id']) {
|
||||
case 1:
|
||||
// 1x2
|
||||
$odds = [];
|
||||
foreach ($bettypes['odds'] as $bettype) {
|
||||
if ($bettype['outcome_id'] == 1) {
|
||||
$odds['h3w'] = $bettype['odd_value'];
|
||||
} elseif ($bettype['outcome_id'] == 2) {
|
||||
$odds['d3w'] = $bettype['odd_value'];
|
||||
} elseif ($bettype['outcome_id'] == 3) {
|
||||
$odds['a3w'] = $bettype['odd_value'];
|
||||
}
|
||||
}
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
$odds['starttime'] = (string) $row['start_time'];
|
||||
|
||||
DB::transaction(function () use ($base, $event, $odds) {
|
||||
Odds3way::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
||||
], $base + $odds);
|
||||
}, 5);
|
||||
|
||||
break;
|
||||
|
||||
case 10:
|
||||
// DOUBLE CHANCE
|
||||
$odds = [];
|
||||
foreach ($bettypes['odds'] as $bettype) {
|
||||
if ($bettype['outcome_id'] == 9) {
|
||||
$odds['dc1x'] = $bettype['odd_value'];
|
||||
} elseif ($bettype['outcome_id'] == 10) {
|
||||
$odds['dc12'] = $bettype['odd_value'];
|
||||
} elseif ($bettype['outcome_id'] == 11) {
|
||||
$odds['dcx2'] = $bettype['odd_value'];
|
||||
}
|
||||
}
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
|
||||
DB::transaction(function () use ($base, $event, $odds) {
|
||||
OddsDc::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
||||
], $base + $odds);
|
||||
}, 5);
|
||||
|
||||
break;
|
||||
|
||||
case 18:
|
||||
// TOTALS
|
||||
$odds = [];
|
||||
foreach ($bettypes['odds'] as $bettype) {
|
||||
if ($bettype['outcome_id'] == 12 && $bettype['odd_key'] == 'over 2.5') {
|
||||
$odds['over'] = $bettype['odd_value'];
|
||||
} elseif ($bettype['outcome_id'] == 13 && $bettype['odd_key'] == 'over 2.5') {
|
||||
$odds['under'] = $bettype['odd_value'];
|
||||
}
|
||||
}
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
$odds['total'] = 2.5;
|
||||
|
||||
DB::transaction(function () use ($base, $event, $odds) {
|
||||
OddsTotal::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
||||
], $base + $odds);
|
||||
}, 5);
|
||||
|
||||
break;
|
||||
|
||||
case 29:
|
||||
// BOTH TEAMS TO SCORE (GG/NG)
|
||||
$odds = [];
|
||||
foreach ($bettypes['odds'] as $bettype) {
|
||||
if ($bettype['outcome_id'] == 74) {
|
||||
$odds['gg'] = $bettype['odd_value'];
|
||||
} elseif ($bettype['outcome_id'] == 76) {
|
||||
$odds['ng'] = $bettype['odd_value'];
|
||||
}
|
||||
}
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
|
||||
DB::transaction(function () use ($base, $event, $odds) {
|
||||
OddsGgng::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
||||
], $base + $odds);
|
||||
}, 5);
|
||||
|
||||
default:
|
||||
dd($bettypes);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
usleep(rand(10000, 20000));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user