This commit is contained in:
salam committed 2026-01-08 19:57:49 +01:00
1 parent 4f9125ef12
commit 61418c8cee
47 files changed
+726 -221

No files matched your search

@@ -8,6 +8,7 @@ use App\Models\CompetitionGroup;
use App\Models\Element;
use App\Models\Event;
use App\Models\Group;
use App\Models\Sport;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
@@ -16,12 +17,12 @@ class Fixtures
public static function grap()
{
$debug = Nuh::$options['d'] ?? 0;
$echo = Nuh::$options['e'] ?? 0;
$break = Nuh::$options['t'] ?? 0;
$today = Nuh::$options['t'] ?? 0;
$week = Nuh::$options['w'] ?? 0;
$count = 0;
$total = 0;
$total_soccer = 0;
$total_others = 0;
$now = Carbon::now();
@@ -35,81 +36,94 @@ class Fixtures
Notice::note("Deleted: $info");
}
$sports = Sport::where('is_active', 1)->pluck('id')->toArray();
/**
* Grap
*/
for ($i = Nuh::$options['days_from']; $i < Nuh::$options['days_to']; $i++) {
$AUTHTOKEN = [
'SOCCER' => 'ident=betaid1&passwd=Dy59vpRC',
'OTHER' => 'ident=betaid2&passwd=Dy59vpRC',
];
$url = 'https://xml2.txodds.com/feed/result/xml.php?'.Nuh::$AUTHTOKEN.'&date='.$now->toDateString().','.$now->addDays(1)->toDateString();
foreach ($AUTHTOKEN as $konto => $authentication) {
// code...
$data = Xml::load($url);
if ($echo) {
dd($data);
if ($today) {
Nuh::$options['days_from'] = 0;
Nuh::$options['days_to'] = 1;
} elseif ($week) {
Nuh::$options['days_from'] = 0;
Nuh::$options['days_to'] = 6;
}
foreach ($data as $row) {
for ($i = Nuh::$options['days_from']; $i < Nuh::$options['days_to']; $i++) {
$event = [
'provider_id' => (int) Nuh::$options['provider_id'],
'starttime' => Carbon::createFromDate((string) $row->time)->toDateTimeString(),
'sport_id' => (int) $row->group['spid'],
'home_id' => (int) $row->hteam['id'],
'away_id' => (int) $row->ateam['id'],
'country_id' => (int) $row->group['cnid'],
'group_id' => (int) $row->group['id'],
'competition_group_id' => (int) $row->group['cgid'],
];
$url = "https://xml2.txodds.com/feed/result/xml.php?$authentication&days=$i,1";
Event::updateOrCreate(['id' => (int) $row['id']], $event);
$data = Xml::load($url);
$group = [
'competition_group_id' => (string) $row->group['cgid'],
'sport_id' => (int) $row->group['spid'],
'country_id' => (int) $row->group['cnid'],
'name' => (string) $row->group,
];
Group::updateOrCreate(['id' => (int) $row->group['id']], $group);
foreach ($data as $row) {
$compgroup = [
'sport_id' => $event['sport_id'],
'country_id' => $event['country_id'],
'name' => (string) $row->group['cname'],
];
$sport_id = (int) $row->group['spid'];
CompetitionGroup::updateOrCreate(['id' => (int) $row->group['cgid']], $compgroup);
if (in_array($sport_id, $sports)) {
$element = [
'name' => (string) $row->hteam,
'sport_id' => (int) $row->group['spid'],
];
Element::updateOrCreate(['id' => (int) $row->hteam['id']], $element);
$event = [
'provider_id' => (int) Nuh::$options['provider_id'],
'starttime' => Carbon::createFromDate((string) $row->time)->toDateTimeString(),
'sport_id' => (int) $sport_id,
'home_id' => (int) $row->hteam['id'],
'away_id' => (int) $row->ateam['id'],
'country_id' => (int) $row->group['cnid'],
'group_id' => (int) $row->group['id'],
'competition_group_id' => (int) $row->group['cgid'],
];
$element = [
'name' => (string) $row->ateam,
'sport_id' => (int) $row->group['spid'],
];
Element::updateOrCreate(['id' => (int) $row->ateam['id']], $element);
Event::updateOrCreate(['id' => (int) $row['id']], $event);
$count++;
$group = [
'competition_group_id' => (string) $row->group['cgid'],
'sport_id' => (int) $sport_id,
'country_id' => (int) $row->group['cnid'],
'name' => (string) $row->group,
];
Group::updateOrCreate(['id' => (int) $row->group['id']], $group);
$compgroup = [
'sport_id' => (int) $sport_id,
'country_id' => $event['country_id'],
'name' => (string) $row->group['cname'],
];
CompetitionGroup::updateOrCreate(['id' => (int) $row->group['cgid']], $compgroup);
$element = [
'name' => (string) $row->hteam,
'sport_id' => (int) $sport_id,
];
Element::updateOrCreate(['id' => (int) $row->hteam['id']], $element);
$element = [
'name' => (string) $row->ateam,
'sport_id' => (int) $sport_id,
];
Element::updateOrCreate(['id' => (int) $row->ateam['id']], $element);
if ($sport_id == 1) {
$total_soccer++;
} else {
$total_others++;
}
}
}
}
if ($debug) {
Notice::note($now->toDateString()." - $count events processed", 'g');
}
$total += $count;
if ($break) {
break;
}
if ($week && $i == 7) {
break;
}
}
if ($debug) {
Notice::note("Total - $total events processed", 'g');
Notice::note("Total Soccer - $total_soccer\nTotal Others - $total_others", 'g');
}
}
}