wip countries

This commit is contained in:
salam committed 2025-08-30 08:15:10 +02:00
1 parent 641b362752
commit 1b9a65b25a
23 files changed
+127755 -27137

No files matched your search

@@ -0,0 +1,35 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds;
use App\Console\Commands\Curl;
use App\Console\Commands\NuhBash;
use App\Models\Country;
use App\Utilities\Notice;
class Countries
{
public static function call()
{
$debug = NuhBash::$options['d'] ?? 0;
$print = NuhBash::$options['p'] ?? 0;
$url = 'https://xml2.txodds.com/feed/countries.php';
$data = Curl::load($url, $debug);
if ($print) {
Notice::note($data, '', 1);
}
$count = 0;
foreach ($data as $row) {
Country::updateOrCreate(
['txid' => (int) $row->id],
['name' => (string) $row->name, 'cc' => (string) $row->cc]
);
$count++;
}
Notice::note("$count countries processed", 'g');
}
}
@@ -1,34 +0,0 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Fixtures;
use App\Models\Country;
class TxCountries
{
public static function get($group)
{
// "group": {
// "@attributes": {
// "id": "177425",
// "cgid": "336",
// "spid": "1",
// "cnid": "381",
// "mgid": "1373",
// "cname": "UEFA Women's Champions League"
// },
// "@text": "WFBECUP UEFA Women's Champions League > Qualifying Rounds-25"
// },
$cnid = array_column($group, 'cnid');
$cname = array_column($group, 'cname');
$country = Country::firstOrCreate(
['txid' => $cnid[0]],
['name' => $cname[0]]
);
return $cnid[0];
}
}
@@ -0,0 +1,22 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds\Fixtures;
use App\Models\Country;
class TxCountry
{
public static function find($group)
{
$cnid = array_column($group, 'cnid');
$cname = array_column($group, 'cname');
$country = Country::firstOrCreate(
['txid' => $cnid[0]],
['name' => $cname[0]]
);
return $country->id;
}
}
@@ -2,18 +2,14 @@
namespace App\Console\Commands\Grapper\TxOdds\Fixtures;
use App\Console\Commands\NuhBash;
use App\Models\Liga;
class TxLigas
class TxLiga
{
public static function find($group)
public static function find($country_id, $group)
{
$debug = NuhBash::$options['debug'] ?? 0;
$cname = array_column($group, 'cname');
$spid = array_column($group, 'spid');
$country_id = TxCountries::get($group);
$cgid = array_column($group, 'cgid');
$liga = Liga::firstOrCreate([
@@ -24,6 +20,5 @@ class TxLigas
]);
return $liga->id;
}
}
@@ -3,11 +3,13 @@
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\TxLigas;
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 FixturesSoccer
{
@@ -15,13 +17,18 @@ class FixturesSoccer
{
$debug = NuhBash::$options['d'] ?? 0;
$print = NuhBash::$options['p'] ?? 0;
$read = NuhBash::$options['r'] ?? 0;
$break = NuhBash::$options['b'] ?? 0;
$total = 0;
for ($i = 0; $i < 30; $i++) {
$str1 = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') + $i, date('Y')));
$str2 = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') + 1 + $i, date('Y')));
$date = Carbon::now();
$url = 'https://xml2.txodds.com/feed/result/xml.php?ident=betaid1&passwd='.config('nuh.txodds_token')."&date=$str1,$str2&json=2";
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?ident=betaid1&passwd='.config('nuh.txodds_token')."&date=$from,$to&json=2";
$data = Curl::load($url, $debug);
if ($print) {
@@ -30,26 +37,32 @@ class FixturesSoccer
$count = 0;
foreach ($data['match'] as $row) {
$count++;
$txodds_id = array_column($row, 'id');
$spid = array_column($row['group'], 'spid');
$liga_id = TxLigas::find($row['group']);
$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::firstOrCreate([
$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,
'liga_id' => $liga_id,
'home_id' => $home_id,
'away_id' => $away_id,
'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,
]);
// dd($event);
}
Notice::note("$str1 - $count events processed", 'g');
Notice::note("$from - $count events processed", 'g');
$total += $count;
if ($break) {
break;
}
}
Notice::note("Total - $total events processed", 'g');
}
@@ -2,6 +2,7 @@
namespace App\Console\Commands\Grapper;
use App\Console\Commands\Grapper\TxOdds\Countries;
use App\Console\Commands\Grapper\TxOdds\FixturesSoccer;
use App\Console\Commands\NuhBash;
@@ -18,6 +19,7 @@ class TxSwitch
FixturesSoccer::call();
break;
case 2:
Countries::call();
break;
case 3:
break;