txodds grapping odds - wip
This commit is contained in:
1 parent
16c5608fd1
commit
a597d3161b
27 files changed
+410
-15713
No files matched your search
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\TxOdds;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Grapper\TxOdds\Fixtures\TxCountry;
|
||||
use App\Console\Commands\Grapper\TxOdds\Fixtures\TxElement;
|
||||
use App\Console\Commands\Grapper\TxOdds\Fixtures\TxLiga;
|
||||
use App\Console\Commands\NuhBash;
|
||||
use App\Models\Event;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class Fixtures
|
||||
{
|
||||
public static function grap()
|
||||
{
|
||||
$debug = NuhBash::$options['d'] ?? 0;
|
||||
$print = NuhBash::$options['p'] ?? 0;
|
||||
$read = NuhBash::$options['r'] ?? 0;
|
||||
$break = NuhBash::$options['b'] ?? 0;
|
||||
|
||||
$total = 0;
|
||||
$date = Carbon::now();
|
||||
|
||||
for ($i = 0; $i < 30; $i++) {
|
||||
|
||||
$from = $date->addDays($i)->toDateString();
|
||||
$to = $date->addDays($i + 1)->toDateString();
|
||||
|
||||
$url = 'https://xml2.txodds.com/feed/result/xml.php?'.config('nuh.txodds_token_soccer')."&date=$from,$to&json=2";
|
||||
$data = Curl::load($url, $debug);
|
||||
|
||||
if ($print) {
|
||||
Notice::note($data, '', 1);
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
foreach ($data['match'] as $row) {
|
||||
|
||||
$count++;
|
||||
$txodds_id = array_column($row, 'id');
|
||||
$spid = array_column($row['group'], 'spid');
|
||||
$country_id = TxCountry::find($row['group']);
|
||||
$liga_id = TxLiga::find($country_id, $row['group']);
|
||||
$home_id = TxElement::find($row['hteam'], 1);
|
||||
$away_id = TxElement::find($row['ateam'], 1);
|
||||
|
||||
$event = Event::updateOrCreate([
|
||||
'starttime' => date('Y-m-d H:i:s', strtotime($row['time'])),
|
||||
'sport_id' => (int) $spid[0],
|
||||
'provider_id' => 1,
|
||||
'txodds_id' => (int) $txodds_id[0],
|
||||
'country_id' => (int) $country_id,
|
||||
'liga_id' => (int) $liga_id,
|
||||
'home_id' => (int) $home_id,
|
||||
'away_id' => (int) $away_id,
|
||||
]);
|
||||
}
|
||||
Notice::note("$from - $count events processed", 'g');
|
||||
$total += $count;
|
||||
|
||||
if ($break) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Notice::note("Total - $total events processed", 'g');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user