wip
This commit is contained in:
1 parent
5f4a788927
commit
f4f01a58fa
13 files changed
+186
-84
No files matched your search
@@ -16,10 +16,14 @@ ini_set('magic_quotes_runtime', false);
|
||||
|
||||
class Sofascore
|
||||
{
|
||||
public static string $storage;
|
||||
|
||||
public static function switch()
|
||||
{
|
||||
$function = Nuh::$options['fun'];
|
||||
|
||||
self::$storage = storage_path('sofascore_data');
|
||||
|
||||
switch ($function) {
|
||||
case 1:
|
||||
PlayerPerSeason::run();
|
||||
@@ -28,23 +32,23 @@ class Sofascore
|
||||
SettingsToLocal::run();
|
||||
break;
|
||||
case 3:
|
||||
CreateZip::run();
|
||||
break;
|
||||
case 4:
|
||||
SendMail::run();
|
||||
break;
|
||||
case 5:
|
||||
DaysTournament::run();
|
||||
break;
|
||||
case 6:
|
||||
Grapper::load();
|
||||
break;
|
||||
case 7:
|
||||
TaskConfig::start();
|
||||
break;
|
||||
case 8:
|
||||
case 4:
|
||||
DaysTournament::run();
|
||||
break;
|
||||
case 5:
|
||||
Grapper::load();
|
||||
break;
|
||||
case 6:
|
||||
TaskConfig::end();
|
||||
break;
|
||||
case 7:
|
||||
CreateZip::run();
|
||||
break;
|
||||
case 8:
|
||||
SendMail::run();
|
||||
break;
|
||||
|
||||
default:
|
||||
Notice::note('id not valid', 'br', 1);
|
||||
|
||||
@@ -23,7 +23,7 @@ class CreateZip
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(\count($days).' days as zip created', 'bb');
|
||||
Notice::note('zips created', 'bb');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class DaysTournament
|
||||
|
||||
if ($has) {
|
||||
if ($debug) {
|
||||
Notice::note("All tournament for $day have been allready grapped", 'r');
|
||||
Notice::note("All tournament for $day have been allready grapped", 'g');
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\CurlSofa;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
|
||||
@@ -15,17 +16,15 @@ use Illuminate\Support\Facades\File;
|
||||
|
||||
class Grapper
|
||||
{
|
||||
public static function load()
|
||||
{
|
||||
|
||||
/**
|
||||
* yesterday
|
||||
* last 3 days = task 1
|
||||
*
|
||||
* nuh --d --f 67 --fun=6 --task=1
|
||||
*
|
||||
* 1783710000
|
||||
* 10 July 2026 09:00:00 PM CEST
|
||||
*/
|
||||
|
||||
public static function load()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$force = Nuh::$options['f'] ?? 0;
|
||||
@@ -38,6 +37,15 @@ class Grapper
|
||||
|
||||
// dd($active_tournaments->toArray());
|
||||
|
||||
|
||||
/**
|
||||
* empty grapping folder
|
||||
* empty mailing text
|
||||
*/
|
||||
// File::cleanDirectory(Sofascore::$storage); dd('clead dir');
|
||||
|
||||
SofaScoreEventGrapped::query()->update(['in_current_grapper' => false]);
|
||||
|
||||
foreach ($active_tournaments as $tournament) {
|
||||
|
||||
if ($debug) {
|
||||
@@ -61,8 +69,6 @@ class Grapper
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
// dd($data);
|
||||
|
||||
Nuh::$options['s'] = 0;
|
||||
|
||||
Nuh::$options['r'] = 0;
|
||||
@@ -72,15 +78,25 @@ class Grapper
|
||||
foreach ($data['events'] as $event) {
|
||||
|
||||
$now = Carbon::now()->subHours(4);
|
||||
$starttime = Carbon::createFromTimestamp($event->startTimestamp);
|
||||
$starttime = Carbon::createFromTimestamp($event['startTimestamp']);
|
||||
|
||||
if ($now->greaterThan($starttime)) {
|
||||
|
||||
$event_grapped = SofaScoreEventGrapped::where('id', $event['id'])->first();
|
||||
$event_grapped['name'] = $event->homeTeam['name'] . ' vs ' . $event->awayTeam['name'];
|
||||
$event_grapped['url'] = $url;
|
||||
Sleeper::rand();
|
||||
|
||||
$folder = storage_path('sofascore_data') . $day . '/' . $event['tournament']['slug'] . '/' . $event['slug'];
|
||||
if ($debug) {
|
||||
Notice::note($day . ' - ' . $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'], 'bg');
|
||||
}
|
||||
|
||||
$grapped = SofaScoreEventGrapped::firstOrNew(['id' => $event['id']]);
|
||||
$grapped->day = $day;
|
||||
$grapped->liga = $event['tournament']['name'];
|
||||
$grapped->name = $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'];
|
||||
$grapped->url = $url;
|
||||
$grapped->starttime = $starttime->toDateTimeString();
|
||||
$grapped->in_current_grapper = true;
|
||||
|
||||
$folder = Sofascore::$storage . '/' . $day . '/' . $event['tournament']['slug'] . '/' . $event['slug'];
|
||||
|
||||
File::makeDirectory($folder, 0775, true, true);
|
||||
|
||||
@@ -96,7 +112,7 @@ class Grapper
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
if ($force || !$event_grapped['got_statistics'] && $event->hasEventPlayerStatistics) {
|
||||
// if (!$grapped['got_statistics'] && isset($event['hasEventPlayerStatistics']) && $event['hasEventPlayerStatistics'] == true) {
|
||||
|
||||
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/statistics";
|
||||
|
||||
@@ -108,14 +124,14 @@ class Grapper
|
||||
|
||||
File::put($folder . '/statistics.json', json_encode($data));
|
||||
|
||||
$event_grapped['got_statistics'] = 1;
|
||||
}
|
||||
$grapped->got_statistics = 1;
|
||||
// }
|
||||
|
||||
/*********************************
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
if ($force || !$event_grapped['got_lineups']) {
|
||||
// if (!$grapped['got_lineups']) {
|
||||
|
||||
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/lineups";
|
||||
|
||||
@@ -127,14 +143,14 @@ class Grapper
|
||||
|
||||
File::put($folder . '/lineups.json', json_encode($data));
|
||||
|
||||
$event_grapped['got_lineups'] = 1;
|
||||
}
|
||||
$grapped->got_lineups = 1;
|
||||
// }
|
||||
|
||||
/*********************************
|
||||
* EVENT odds
|
||||
*********************************/
|
||||
|
||||
if ($force || !$event_grapped['got_odds']) {
|
||||
// if (!$grapped['got_odds']) {
|
||||
|
||||
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/odds/1/all";
|
||||
|
||||
@@ -146,14 +162,14 @@ class Grapper
|
||||
|
||||
File::put($folder . '/odds.json', json_encode($data));
|
||||
|
||||
$event_grapped['got_odds'] = 1;
|
||||
}
|
||||
$grapped->got_odds = 1;
|
||||
// }
|
||||
|
||||
/*********************************
|
||||
* EVENT incidents
|
||||
*********************************/
|
||||
|
||||
if ($force || !$event_grapped['got_incidents']) {
|
||||
// if (!$grapped['got_incidents']) {
|
||||
|
||||
$url = Nuh::$options['base_url'] . "api/v1/event/$event_id/incidents";
|
||||
|
||||
@@ -165,8 +181,10 @@ class Grapper
|
||||
|
||||
File::put($folder . '/incidents.json', json_encode($data));
|
||||
|
||||
$event_grapped['got_incidents'] = 1;
|
||||
}
|
||||
$grapped->got_incidents = 1;
|
||||
// }
|
||||
|
||||
$grapped->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class Sleeper
|
||||
if ($langsam) {
|
||||
$sleep = rand(3000000, 6000000);
|
||||
} else {
|
||||
$sleep = rand(500000, 100000);
|
||||
$sleep = rand(100000, 150000);
|
||||
}
|
||||
usleep($sleep);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Mail\SofaScoreDataMail;
|
||||
use App\Models\SofaScoreEventGrapped;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
@@ -20,25 +23,20 @@ class SendMail
|
||||
|
||||
$day = $d['day'];
|
||||
|
||||
$zip_file = storage_path('sofascore_data') . '/' . $day . '.zip';
|
||||
$message = self::createMailText($day);
|
||||
|
||||
$zip_file = Sofascore::$storage . '/' . $day . '.zip';
|
||||
|
||||
if (File::exists($zip_file)) {
|
||||
|
||||
Mail::to('hermann.telser@gmail.com')
|
||||
->cc('ubaldo.perrucci@gmail.com')
|
||||
->send(
|
||||
new SofaScoreDataMail($day, $message, $zip_file)
|
||||
);
|
||||
if ($debug) {
|
||||
Notice::note('Mail send' . $day);
|
||||
}
|
||||
|
||||
|
||||
Mail::send([], [], function ($message) use ($day, $zip_file) {
|
||||
|
||||
$message->to('hermann.telser@gmail.com', 'sofa archive ' . $day)
|
||||
->cc('ubaldo.perrucci@gmail.com', 'sofa archive ' . $day)
|
||||
->subject("sofa archive $day")
|
||||
->attach($zip_file, [
|
||||
'mime' => 'application/x-zip-compressed',
|
||||
'as' => 'sofa archive ' . $day . '.zip',
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,4 +44,16 @@ class SendMail
|
||||
Notice::note('Mail send', 'g');
|
||||
}
|
||||
}
|
||||
|
||||
public static function createMailText(string $day)
|
||||
{
|
||||
$res = SofaScoreEventGrapped::where('day', $day)->get();
|
||||
$text = "## Mail Content $day
|
||||
";
|
||||
foreach ($res as $value) {
|
||||
$text .= "### $value->liga * $value->name * $value->starttime
|
||||
";
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Attachment;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SofaScoreDataMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct(string $day, string $message, string $zip_file)
|
||||
{
|
||||
$this->day = $day;
|
||||
$this->message = $message;
|
||||
$this->zip_file = $zip_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Sofa Score ' . $this->day,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
markdown: 'mail.user.sofascore_data',
|
||||
with: [
|
||||
'message' => $this->message,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [
|
||||
Attachment::fromPath($this->zip_file)
|
||||
->as('sofa archive ' . $this->day . '.zip')
|
||||
->withMime('application/x-zip-compressed')
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use ZipArchive;
|
||||
@@ -11,9 +12,9 @@ class ZipFolder
|
||||
public static function create(string $day)
|
||||
{
|
||||
|
||||
$zipFilePath = storage_path('sofascore_data') . '/' . $day . '.zip';
|
||||
$zipFilePath = Sofascore::$storage . '/' . $day . '.zip';
|
||||
|
||||
$path = storage_path('sofascore_data') . $day;
|
||||
$path = Sofascore::$storage . '/' . $day;
|
||||
|
||||
$zip = new ZipArchive();
|
||||
|
||||
|
||||
+13
-13
@@ -21,28 +21,28 @@ case "$1" in
|
||||
echo "\n⚽ open vpn"
|
||||
ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190
|
||||
|
||||
echo "\n⚽ copy settings"
|
||||
echo "\n⚽ SettingsToLocal"
|
||||
php artisan nuh --d --f 67 --fun=2 --task=$1
|
||||
|
||||
echo "\n⚽ close vpn"
|
||||
killall ssh
|
||||
|
||||
echo "\n⚽ start task"
|
||||
php artisan nuh --d --f 67 --fun=7 --task=$1
|
||||
|
||||
echo "\n⚽ get tournaments for the day"
|
||||
php artisan nuh --d --f 67 --fun=5 --task=$1
|
||||
|
||||
echo "\n⚽ grapper events for the day"
|
||||
php artisan nuh --d --f 67 --fun=6 --task=$1
|
||||
|
||||
echo "\n⚽ create zip archive"
|
||||
echo "\n⚽ TaskConfig start"
|
||||
php artisan nuh --d --f 67 --fun=3 --task=$1
|
||||
|
||||
echo "\n⚽ mail archive"
|
||||
echo "\n⚽ DaysTournament"
|
||||
php artisan nuh --d --f 67 --fun=4 --task=$1
|
||||
|
||||
echo "\n⚽ end task"
|
||||
echo "\n⚽ Grapper"
|
||||
php artisan nuh --d --f 67 --fun=5 --task=$1
|
||||
|
||||
echo "\n⚽ TaskConfig end"
|
||||
php artisan nuh --d --f 67 --fun=6 --task=$1
|
||||
|
||||
echo "\n⚽ CreateZip"
|
||||
php artisan nuh --d --f 67 --fun=7 --task=$1
|
||||
|
||||
echo "\n⚽ SendMail"
|
||||
php artisan nuh --d --f 67 --fun=8 --task=$1
|
||||
|
||||
echo "\n😎 done :)"
|
||||
|
||||
@@ -13,9 +13,12 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('sofa_score_event_grappeds', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->date('day')->nullable();
|
||||
$table->string('liga')->nullable();
|
||||
$table->string('name')->nullable();
|
||||
$table->string('url')->nullable();
|
||||
$table->dateTime('starttime')->nullable();
|
||||
$table->string('url')->nullable();
|
||||
$table->boolean('in_current_grapper')->default(false);
|
||||
$table->boolean('got_statistics')->default(false);
|
||||
$table->boolean('got_lineups')->default(false);
|
||||
$table->boolean('got_odds')->default(false);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<x-mail::message>
|
||||
{{ $message }}
|
||||
</x-mail::message>
|
||||
+13
-12
@@ -1,18 +1,19 @@
|
||||
<tr>
|
||||
<td class="header">
|
||||
<div style="display: inline-block;">
|
||||
<svg fill="currentColor" viewBox="0 0 1668 410" version="1.1" class="logo"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"
|
||||
xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<path id="N" d="M117,0L0,0L0,410L71,410L71,51L123,51L123,410L194,410L194,51L117,0Z" />
|
||||
<path id="U" d="M218,0L218,410L336,410L412,359L412,0L342,0L341,359L289,359L290,0L218,0Z" />
|
||||
<path id="H" d="M436,0L436,410L507,410L508,230L559,229L559,410L630,410L630,0L559,0L559,179L507,179L507,0L436,0Z" />
|
||||
<rect x="669" y="180" width="114" height="49" />
|
||||
<path id="O" d="M896,0L819,51L819,358L896,410L937,410L1014,359L1014,51L938,0L896,0ZM943,51L890,51L890,359L943,359L943,51Z" />
|
||||
<path id="D" d="M1038,0L1155,0L1231,50L1231,359L1156,410L1038,410L1038,0ZM1160,51L1109,51L1109,359L1160,359L1160,51Z" />
|
||||
<path id="D2" d="M1256,0L1374,0L1450,50L1450,359L1374,410L1256,410L1256,0ZM1378,51L1327,51L1327,359L1378,359L1378,51Z" />
|
||||
<path id="S" d="M1549,0L1667,0L1667,128L1596,128L1596,51L1545,51L1545,179L1667,179L1667,359L1591,410L1473,410L1473,282L1544,282L1544,359L1596,359L1596,230L1473,230L1473,50L1549,0Z" />
|
||||
<svg width="100%" height="100%" viewBox="0 0 600 169" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g transform="matrix(0.1,0,0,-0.172449,0,169)">
|
||||
<path d="M146,877C78,788 54,665 85,569C95,539 123,475 148,425C187,348 194,326 194,275C194,211 174,160 124,101C110,83 100,67 103,64C113,54 393,60 405,70C430,90 469,178 481,238C497,321 484,379 420,509C393,563 367,626 362,648C346,718 372,798 436,878L463,910L171,910L146,877Z" style="fill-rule:nonzero;" />
|
||||
<path d="M510,910L510,730L700,730L700,60L960,60L960,729L1037,732L1113,735L1136,820C1149,867 1160,906 1160,908C1160,909 1014,910 835,910L510,910Z" style="fill-rule:nonzero;" />
|
||||
<path d="M1237,853C1165,691 1145,560 1154,321C1157,224 1163,127 1168,105L1175,65L1308,62C1380,61 1440,63 1440,67C1440,71 1434,109 1426,150C1418,191 1410,256 1408,293L1405,361L1615,361L1612,293C1609,231 1597,139 1583,82L1578,59L1844,65L1852,104C1867,174 1875,389 1868,496C1860,614 1832,737 1791,838L1763,905L1513,908L1263,910L1237,853ZM1543,783C1566,731 1610,579 1610,551C1610,544 1575,540 1510,540C1445,540 1410,544 1410,551C1410,604 1492,840 1510,840C1514,840 1529,814 1543,783Z" style="fill-rule:nonzero;" />
|
||||
<path d="M1900,910L1900,730L2080,730L2080,60L2340,60L2340,730L2498,730L2519,808C2531,851 2540,892 2540,898C2540,907 2459,910 2220,910L1900,910Z" style="fill-rule:nonzero;" />
|
||||
<path d="M2600,911L2600,60L2870,60L2868,483L2865,905L2733,908L2600,911Z" style="fill-rule:nonzero;" />
|
||||
<path d="M3023,862C2986,808 2972,774 2960,708C2946,638 2963,571 3025,440C3069,347 3080,315 3080,275C3080,218 3055,156 3009,99L2978,60L3286,60L3317,113C3358,180 3373,244 3368,323C3365,375 3353,409 3302,516C3254,615 3240,655 3240,690C3240,740 3272,818 3313,866C3328,884 3340,901 3340,904C3340,907 3276,910 3198,910L3055,910L3023,862Z" style="fill-rule:nonzero;" />
|
||||
<path d="M3400,910L3400,730L3580,730L3580,60L3840,60L3840,730L3997,730L4018,809C4030,852 4040,892 4040,899C4040,907 3951,910 3720,910L3400,910Z" style="fill-rule:nonzero;" />
|
||||
<rect x="4100" y="60" width="260" height="850" style="fill-rule:nonzero;" />
|
||||
<path d="M4470,910L4470,60L4730,60L4730,450L4753,450C4788,450 4835,416 4854,375C4875,332 4890,240 4890,153C4890,55 4883,60 5037,60L5171,60L5166,118C5163,149 5158,209 5155,250C5146,358 5122,436 5086,474C5069,492 5048,510 5040,513C5028,517 5031,523 5053,540C5109,584 5124,632 5128,778L5132,910L4862,910L4858,773C4855,614 4841,572 4785,546C4767,537 4747,530 4741,530C4733,530 4730,589 4730,720L4730,910L4470,910Z" style="fill-rule:nonzero;" />
|
||||
<path d="M5300,858C5259,763 5240,670 5234,535C5227,381 5244,261 5291,139L5321,60L5868,60L5889,110C5937,221 5945,274 5945,480C5945,686 5937,731 5880,864L5861,910L5322,910L5300,858ZM5626,786C5640,756 5657,701 5665,663C5682,585 5685,388 5670,309C5658,244 5611,110 5600,110C5590,110 5540,223 5523,284C5502,363 5495,518 5510,607C5523,691 5575,840 5591,840C5597,840 5612,816 5626,786Z" style="fill-rule:nonzero;" />
|
||||
</g>
|
||||
</svg>
|
||||
<br />
|
||||
{!! $slot !!}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
{{-- Header --}}
|
||||
<x-slot:header>
|
||||
<x-mail::header :url="config('app.url')">
|
||||
{{ config('app.name') }}
|
||||
by New-Odds Market Monitoring
|
||||
</x-mail::header>
|
||||
</x-slot:header>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
{{-- Footer --}}
|
||||
<x-slot:footer>
|
||||
<x-mail::footer>
|
||||
© {{ date('Y') }} {{ config('app.name') }}. {{ __('All rights reserved.') }}
|
||||
© {{ date('Y') }} NUH-Odds GmbH Innsbruck Austria, {{ __('All rights reserved.') }}
|
||||
</x-mail::footer>
|
||||
</x-slot:footer>
|
||||
</x-mail::layout>
|
||||
Reference in new issue
Block a user