popup and grapper wip
This commit is contained in:
1 parent
a3c9f16550
commit
c9588f39b6
18 files changed
+656
-156248
No files matched your search
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper;
|
||||
use App\Console\Commands\Grapper\Betsapi\Bwin;
|
||||
use App\Console\Commands\Grapper\Betsapi\Fixtures;
|
||||
use App\Console\Commands\Grapper\Betsapi\Odds;
|
||||
use App\Console\Commands\Grapper\Betsapi\Willhill;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ class Bwin
|
||||
|
||||
$sportmap = Sport::map('bwin');
|
||||
|
||||
$sportmap = [4];
|
||||
|
||||
$total = 1;
|
||||
foreach ($sportmap as $sport_id => $bwin_sport_id) {
|
||||
|
||||
@@ -25,28 +27,32 @@ class Bwin
|
||||
/**
|
||||
* BWIN ODDS & BETRADAR ID (per page)
|
||||
*/
|
||||
$url = 'https://api.b365api.com/v1/bwin/prematch?token='.config('env.betsapi_token').'&page=###page###&sport_id='.$bwin_sport_id;
|
||||
$base_url = 'https://api.b365api.com/v1/bwin/prematch?token='.config('env.betsapi_token').'&skip_markets=1&page=###page###&sport_id='.$bwin_sport_id;
|
||||
|
||||
while ($page <= $total) {
|
||||
|
||||
$url = str_replace('###page###', $page, $url);
|
||||
$url = str_replace('###page###', $page, $base_url);
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
$page++;
|
||||
|
||||
$total = round($data['pager']['total'] / $data['pager']['per_page']);
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Page: $page \nTotal: $total");
|
||||
}
|
||||
|
||||
$page++;
|
||||
|
||||
if (isset($data['results'])) {
|
||||
foreach ($data['results'] as $event) {
|
||||
|
||||
$bwin_id = $event['Id'];
|
||||
$betsapi_id = $event['our_event_id'] ?? 0;
|
||||
$betradar_id = $event['BetRadarId'] ?? 0;
|
||||
$betsapi_id = $event['our_event_id'];
|
||||
$bwin_id = $event['Id'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(["Betsapi ID : $betsapi_id", "Betradar ID : $betradar_id", "Bwin ID : $bwin_id"]);
|
||||
}
|
||||
|
||||
if ($betradar_id) {
|
||||
Event::where('betsapi_id', (int) $betsapi_id)->update(['betradar_id' => $betradar_id, 'bwin_id' => $bwin_id]);
|
||||
|
||||
@@ -17,49 +17,61 @@ class Fixtures
|
||||
|
||||
$sportmap = Sport::map('bapi');
|
||||
|
||||
$total = 1;
|
||||
foreach ($sportmap as $sport_id => $betsapi_sport_id) {
|
||||
$page = 1;
|
||||
while ($page <= $total) {
|
||||
$now = Carbon::now();
|
||||
|
||||
$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) $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(['event_id' => (int) $row['id']], $event);
|
||||
}
|
||||
}
|
||||
}
|
||||
for ($i = 0; $i < 30; $i++) {
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('FIRST LOOP', 'g', 1);
|
||||
Notice::note('Day: '.$now->format('d. M Y'), 'g');
|
||||
}
|
||||
|
||||
$base_url = 'https://api.b365api.com/v3/events/upcoming?sport_id=###sport_id###&page=###page###&day='.$now->format('Ymd').'skip_esports=1&token='.config('env.betsapi_token');
|
||||
|
||||
$now->addDays(1);
|
||||
|
||||
$total = 1;
|
||||
foreach ($sportmap as $sport_id => $betsapi_sport_id) {
|
||||
|
||||
$sport_url = str_replace('###sport_id###', $sport_id, $base_url);
|
||||
|
||||
$page = 1;
|
||||
while ($page <= $total) {
|
||||
|
||||
$url = str_replace('###page###', $page, $sport_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) {
|
||||
|
||||
$event = [
|
||||
'sport_id' => (int) $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(['event_id' => (int) $row['id']], $event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,26 +21,25 @@ class Fixtures
|
||||
|
||||
$count = 0;
|
||||
$total = 0;
|
||||
|
||||
$now = Carbon::now();
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*/
|
||||
// $info = 0;
|
||||
$info = Event::where('starttime', '<', $now->toDateTimeString())->delete();
|
||||
$info = Event::where('starttime', '<', Carbon::now()->toDateTimeString())->delete();
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Deleted: $info");
|
||||
}
|
||||
|
||||
/**
|
||||
* Grap
|
||||
*/
|
||||
for ($i = 0; $i < 30; $i++) {
|
||||
|
||||
$from = $now->addDays($i)->toDateString();
|
||||
$to = $now->addDays($i + 1)->toDateString();
|
||||
|
||||
$url = 'https://xml2.txodds.com/feed/result/xml.php?'.Nuh::$AUTHTOKEN."&date=$from,$to";
|
||||
$url = 'https://xml2.txodds.com/feed/result/xml.php?'.Nuh::$AUTHTOKEN.'&date='.$now->toDateString().','.$now->addDays(1)->toDateString();
|
||||
|
||||
$data = Xml::load($url);
|
||||
|
||||
@@ -94,12 +93,12 @@ class Fixtures
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("$from - $count events processed", 'g');
|
||||
Notice::note($now->toDateString()." - $count events processed", 'g');
|
||||
}
|
||||
|
||||
$total += $count;
|
||||
|
||||
if ($break || $debug) {
|
||||
if ($break) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,10 @@ class Odds
|
||||
dd($data);
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('call counter: '.$counter, 'g');
|
||||
}
|
||||
|
||||
foreach ($data as $row) {
|
||||
|
||||
$event = [
|
||||
|
||||
+331
-156067
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user