mapper wip

This commit is contained in:
salam committed 2025-12-19 15:32:23 +01:00
1 parent ba6c2263e3
commit 02712ec610
27 files changed
+1070 -158

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Console\Commands\Grapper;
use App\Console\Commands\Grapper\Betsapi\Fixtures;
use App\Console\Commands\Grapper\Betsapi\IdMapper;
use App\Console\Commands\Grapper\Betsapi\Odds;
use App\Console\Commands\Nuh;
use App\Utilities\Notice;
class Betsapi
{
public static function switch()
{
switch (Nuh::$options['name']) {
case 'Fixtures':
Fixtures::grap();
break;
case 'Odds':
Odds::grap();
break;
case 'IdMapper':
IdMapper::grap();
break;
default:
Notice::note('prosses name does not exist', 'r', 1);
break;
}
}
}
@@ -0,0 +1,68 @@
<?php
namespace App\Console\Commands\Grapper\Betsapi;
use App\Console\Commands\Curl;
use App\Console\Commands\Nuh;
use App\Models\Mapper;
use App\Models\Sport;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
class Fixtures
{
public static function grap()
{
$debug = Nuh::$options['d'] ?? 0;
$test = Nuh::$options['t'] ?? 0;
$echo = Nuh::$options['e'] ?? 0;
$sportmap = Sport::map('bapi');
$total = 10;
foreach ($sportmap as $sport_id => $betsapi_sport_id) {
$page = 1;
while ($page <= $total) {
$url = "https://api.b365api.com/v3/events/upcoming?sport_id=$betsapi_sport_id&page=$page&skip_esports=1&token=".config('env.betsapi_token');
$data = Curl::load($url);
$page++;
$total = round($data['pager']['total'] / $data['pager']['per_page']);
if ($debug) {
Notice::note("Page: $page \nTotal: $total");
}
if (isset($data['results'])) {
foreach ($data['results'] as $row) {
$event = [
'sport_id' => (int) $row['sport_id'],
'provider_id' => (int) Nuh::$options['provider_id'],
'starttime' => Carbon::createFromTimestamp((string) $row['time'])->toDateTimeString(),
'home' => $row['home']['name'] ?? '',
'home_id' => (int) $row['home']['id'],
'home_cc' => $row['home']['cc'] ?? '',
'away' => $row['away']['name'] ?? '',
'away_id' => (int) $row['away']['id'],
'away_cc' => $row['away']['cc'] ?? '',
'group' => $row['league']['name'] ?? '',
'group_id' => (int) $row['league']['id'] ?? 0,
'group_cc' => $row['league']['cc'] ?? '',
];
Mapper::updateOrCreate(['betsapi_id' => (int) $row['id']], $event);
}
}
}
if ($debug) {
Notice::note('FIRST LOOP', 'g', 1);
}
}
}
}
@@ -0,0 +1,73 @@
<?php
namespace App\Console\Commands\Grapper\Betsapi;
use App\Console\Commands\Curl;
use App\Console\Commands\Nuh;
use App\Models\Mapper;
use App\Utilities\Notice;
class IdMapper
{
public static function grap()
{
$debug = Nuh::$options['d'] ?? 0;
$test = Nuh::$options['t'] ?? 0;
$echo = Nuh::$options['e'] ?? 0;
$total = 10;
$bookmakers = [[
'name' => 'betfair',
'url' => 'https://api.b365api.com/v1/betfair/sb/upcoming?sport_id=###sport_id###&page=###page###',
], [
'name' => '1xbet',
'url' => 'https://api.b365api.com/v1/1xbet/upcoming?sport_id=###sport_id###&page=###page###',
]];
foreach ($bookmakers as $bookmaker) {
if ($bookmaker['name'] == '1xbet') {
// same like txodds
$sportmap = [1, 2, 3];
} elseif ($bookmaker['name'] == 'betfair') {
// 1 soccer
// 7522 basketball
$sportmap = [1, 7522];
}
foreach ($sportmap as $sport_id) {
$page = 1;
$url = str_replace('###sport_id###', $sport_id, $bookmaker['url']).'&token='.config('env.betsapi_token');
while ($page <= $total) {
$url = str_replace('###page###', $page, $url);
$data = Curl::load($url);
$page++;
$total = round($data['pager']['total'] / $data['pager']['per_page']);
if ($debug) {
Notice::note("Page: $page \nTotal: $total");
}
if (isset($data['results'])) {
foreach ($data['results'] as $row) {
if ($bookmaker['name'] == '1xbet') {
Mapper::where('betsapi_id', (int) $row['our_event_id'])->update(['_1xbet_id' => (int) $row['id']]);
} elseif ($bookmaker['name'] == 'betfair') {
Mapper::where('betsapi_id', (int) $row['our_event_id'])->update(['betfairsb_id' => (int) $row['id']]);
}
}
}
}
}
}
}
}
@@ -0,0 +1,14 @@
<?php
namespace App\Console\Commands\Grapper\Betsapi;
class Odds
{
/**
* Create a new class instance.
*/
public function __construct()
{
//
}
}
@@ -0,0 +1,8 @@
6 Unibet
13 Sportingbet
42 William Hill
110 BetFair
117 SNAI
314 Matchbook
649 1XBet
824 BetPlay
@@ -61,6 +61,7 @@ class Fixtures
// </match>
$event = [];
$event['tx_id'] = (int) $row['id'];
$event['provider_id'] = (int) Nuh::$options['provider_id'];
$event['starttime'] = Carbon::createFromDate((string) $row->time)->toDateTimeString();
$group_name = (string) $row->group;
$event['group_id'] = (int) $row->group['id'];
@@ -260,7 +260,6 @@ class Odds
if ($debug) {
Notice::note('END '.Nuh::$_event->id, 'g');
Notice::note('END', 'g');
}
}
}
+6 -3
View File
@@ -2,6 +2,7 @@
namespace App\Console\Commands;
use App\Console\Commands\Grapper\Betsapi;
use App\Console\Commands\Grapper\Magloo;
use App\Console\Commands\Grapper\TxOdds;
use App\Models\Supervisor;
@@ -83,14 +84,16 @@ class Nuh extends Command
switch (self::$options['provider_id']) {
case 1:
TxOdds::switch();
break;
case 2:
// betsapi
Betsapi::switch();
break;
case 3:
// MAGLOO KENIA
// Kenia
Magloo::switch();
break;
case 4:
// MAGLOO NIGERIA
// Nigeria
Magloo::switch();
break;
case 5: