toDateTimeString())->delete(); if ($debug) { Notice::note("Deleted: $info"); } /************************************************* * https://xml2.txodds.com/feed/odds_types.php * BETTYPE IDS 0 3-WAY 1 2-WAY 3 POINTS 4 TOTALS 131073 MONEY LINE - Q1 65536 3-WAY HALF TIME 65540 TOTALS HALF TIME 65539 POINTS HALF TIME 131075 POINTS QUARTER TIME 131076 TOTALS QUARTER TIME 5242880 DOUBLE CHANCE 6291457 DRAW NO BET 11534337 GG/NG (both teams to score) 7340033 TO PROGRESS (to qualify) Not used: 5 Asian 131072 3 WAY QUARTER TIME 262148 TOTALS OVER TIME 262147 POINTS OVER TIME 65537 2-WAY HALF TIME 327680 3-WAY 2ND HALF 327681 2-WAY 2ND HALF 327683 POINT 2ND HALF 327684 TOTALS 2ND HALF 1048577 GOAL / NO GOAL 2097153 ODD / EVEN 4194304 TOTAL GOALS 8388608 1X2 EURO HANDCIAP 9437188 TOTAL CORNERS 9502724 TOTAL CORNERS 1ST HALF 20971520 3-WAY CORNERS 28311555 HANDICAP SETS 28311556 TOTAL SETS *************************************************/ $debug = Nuh::$options['d'] ?? 0; switch (Nuh::$options['sport_id']) { case 1: /** * 0 3-WAY * 4 TOTALS * 65536 3-WAY HALF TIME * 65540 TOTALS HALF TIME * 11534337 GG/NG (both teams to score) * 5242880 DOUBLE CHANCE * 7340033 TO PROGRESS (to qualify) * 6291457 DRAW NO BET */ $markets = '0,4,65536,65540,11534337,5242880,7340033,6291457'; break; case 2: /** * 0 3-WAY * 1 2-WAY * 3 POINTS * 4 TOTALS * 131075 POINTS QUARTER TIME * 131076 TOTALS QUARTER TIME */ $markets = '0,1,3,4,131076,131075'; break; case 3: /** * 1 2-WAY * 3 POINTS * 4 TOTALS * 65539 POINTS HALF TIME * 65540 TOTALS HALF TIME * 131075 POINTS QUARTER TIME * 131076 TOTALS QUARTER TIME */ $markets = '1,3,4,65539,65540,131075,131076'; break; case 5: /** * 1 2-WAY * 131073 MONEY LINE - Q1 * 3 POINTS * 4 TOTALS */ $markets = '1,3,4,131073'; break; default: Notice::note('sport not defined', 'r', 1); break; } /************************************************* * URL *************************************************/ if (Nuh::$options['sport_id'] == 1) { $AUTHTOKEN = 'ident=betaid1&passwd=Dy59vpRC'; } else { $AUTHTOKEN = 'ident=betaid2&passwd=Dy59vpRC'; } $url = 'https://xml2.txodds.com/feed/odds/xml.php?'.$AUTHTOKEN.'&all_odds=2'; $_calls = []; if (Nuh::$options['id']) { if ($debug) { Notice::note("BY ID \nsport_id: ".Nuh::$options['sport_id'], 'p'); } /** * by SINGLE ID */ $_calls[] = $url."&ot=$markets&peid=".Nuh::$options['id']; } elseif (Nuh::$options['a']) { if ($debug) { Notice::note("ALL \nsport_id: ".Nuh::$options['sport_id'], 'p'); } /** * ALL by ID */ $res = Event::where('starttime', '>', Carbon::now()->toDateTimeString())->pluck('id'); foreach ($res as $id) { $_calls[] = $url."&ot=$markets&peid=".$id; } } elseif (Nuh::$options['g']) { if ($debug) { Notice::note("GROUP_ID \nsport_id: ".Nuh::$options['sport_id'], 'p'); } /** * PER GROUP_ID * with from-to */ $groupids = Event::where('starttime', '>', Carbon::now()->toDateTimeString())->groupBy('group_id')->pluck('group_id'); foreach ($groupids as $groupid) { $_calls[] = $url = 'https://xml2.txodds.com/feed/odds/xml.php?'.Nuh::$AUTHTOKEN.'&all_odds=2&ot='.$markets.'&days='.Nuh::$options['days_from'].','.Nuh::$options['days_to'].'&pgid='.$groupid; } } elseif (Nuh::$options['t']) { if ($debug) { Notice::note("TODAY \nsport_id: ".Nuh::$options['sport_id'], 'p'); } /** * TODAY */ $from = Carbon::now()->toDateTimeString(); $to = Carbon::now()->addDays(1)->toDateTimeString(); $res = Event::where('sport_id', Nuh::$options['sport_id'])->where('starttime', '>=', $from)->where('starttime', '<', $to)->pluck('id'); foreach ($res as $id) { $_calls[] = $url.'&spid='.Nuh::$options['sport_id']."&ot=$markets&peid=".$id; } } elseif (Nuh::$options['w']) { if ($debug) { Notice::note("WEEK \nsport_id: ".Nuh::$options['sport_id'], 'p'); } /** * ONE WEEK */ $res = Event::where('sport_id', Nuh::$options['sport_id'])->where('starttime', '>', Carbon::now()->toDateTimeString())->where('starttime', '<', Carbon::now()->addDays(7)->toDateTimeString())->pluck('id'); foreach ($res as $id) { $_calls[] = $url."&ot=$markets&peid=".$id; } } else { if ($debug) { Notice::note("LASTCALL \nsport_id: ".Nuh::$options['sport_id'], 'p'); } /** * WITH LASTCALL Parameter * with from-to days */ $_calls[] = $url.'&spid='.Nuh::$options['sport_id']."&ot=$markets&days=".Nuh::$options['days_from'].','.Nuh::$options['days_to'].'&last='.Nuh::$options['lastcall']; } /************************************************* * CALL *************************************************/ $counter = 0; foreach ($_calls as $url) { $counter++; $data = Xml::load($url); if ($debug) { Notice::note('counter: '.count($_calls).'/'.$counter, 'g'); } foreach ($data as $row) { $sport_id = (int) $row->group['spid']; $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'], ]; Event::firstOrCreate(['id' => (int) $row['id']], $event); $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); $compgroup = [ 'sport_id' => $event['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, 'country_id' => (int) $row->group['cnid'], ]; Element::updateOrCreate(['id' => (int) $row->hteam['id']], $element); $element_group = [ 'competition_group_id' => (int) $row->group['cgid'], ]; ElementGroup::updateOrCreate(['element_id' => (int) $row->hteam['id'], 'group_id' => (int) $row->group['id']], $element_group); $element = [ 'name' => (string) $row->ateam, 'sport_id' => (int) $sport_id, 'country_id' => (int) $row->group['cnid'], ]; Element::updateOrCreate(['id' => (int) $row->ateam['id']], $element); $element_group = [ 'competition_group_id' => (int) $row->group['cgid'], ]; ElementGroup::updateOrCreate(['element_id' => (int) $row->ateam['id'], 'group_id' => (int) $row->group['id']], $element_group); Nuh::$collector = []; foreach ($row->bookmaker as $book) { Nuh::$id = (int) $row['id']; Nuh::$bookmaker_id = (int) $book['bid']; $odds = []; $odds['sport_id'] = (int) $event['sport_id']; $odds['provider_id'] = Nuh::$options['provider_id']; $odds['nuh_check'] = 0; BookmakerOffer::collect($book['bid'], $event['sport_id']); foreach ($book->offer as $offer) { $bettypeid = 0; foreach ($offer->attributes() as $attributeName => $attributeValue) { switch ($attributeName) { case 'id': $odds['offer_id'] = (int) $attributeValue; break; case 'ot': $bettypeid = (int) $attributeValue; break; case 'bmoid': $odds['bmoid'] = (string) $attributeValue; break; case 'flag': $odds['flag'] = (string) $attributeValue; break; } } switch ($bettypeid) { case 0: _3Way::grap($odds, $offer); break; case 1: _2Way::grap($odds, $offer); break; case 3: _Points::grap($odds, $offer); break; case 4: _Totals::grap($odds, $offer); break; case 131073: _2WayS1::grap($odds, $offer); break; case 65536: _3WayHt::grap($odds, $offer); break; case 65540: _TotalsHt::grap($odds, $offer); break; case 65539: _PointsHt::grap($odds, $offer); break; case 131075: _PointsQ1::grap($odds, $offer); break; case 131076: _TotalsQ1::grap($odds, $offer); break; case 5242880: _Dc::grap($odds, $offer); break; case 6291457: _Dnb::grap($odds, $offer); break; case 11534337: _Ggng::grap($odds, $offer); break; case 7340033: _Tq::grap($odds, $offer); break; default: Notice::note('ERROR Bettype ID not set: '.$bettypeid, 'r'); break; } } } ActiveSpread::set(); } } BookmakerOffer::finalize(); if ($debug) { Notice::note('DONE - EVENTS: '.$counter, 'g'); } } }