wip
This commit is contained in:
1 parent
78917241ad
commit
f098ba9b00
18 files changed
+499
-473
No files matched your search
@@ -6,6 +6,7 @@ use App\Console\Commands\Grapper\Sofascore\Grapper;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\SetStorage;
|
||||
use App\Console\Commands\Grapper\Sofascore\MakeExcel;
|
||||
use App\Console\Commands\Grapper\Sofascore\PlayerPerSeason;
|
||||
use App\Console\Commands\Grapper\Sofascore\SendMail;
|
||||
use App\Console\Commands\Grapper\Sofascore\SettingsToLocal;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Console\Command;
|
||||
@@ -20,92 +21,110 @@ class Grap extends Command
|
||||
|
||||
public static string $folder;
|
||||
|
||||
public static $id = 0;
|
||||
|
||||
public static string $useragent = '4';
|
||||
|
||||
protected $signature = 'grp {id=0} {task=0} {--d} {--r} {--f}';
|
||||
protected $signature = 'grp {id=0} {day=0} {--folder=} {--d} {--r} {--f}';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
self::$options = $this->options();
|
||||
|
||||
self::$options['task'] = $this->argument('task');
|
||||
|
||||
self::$options['id'] = (int) $this->argument('id');
|
||||
self::$options['day'] = (int) $this->argument('day');
|
||||
self::$options['base_url'] = 'https://www.sofascore.com/';
|
||||
|
||||
$id = $this->argument('id');
|
||||
|
||||
if (!$id) {
|
||||
$txt = 'PARAMETERS' . PHP_EOL;
|
||||
$txt .= '--d debug' . PHP_EOL;
|
||||
$txt .= '--r restart range' . PHP_EOL;
|
||||
$txt .= '--f force' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||
$txt .= 'FUNCTION' . PHP_EOL;
|
||||
$txt .= " 1\tPlayerPerSeason" . PHP_EOL;
|
||||
$txt .= " 2\tSettingsToLocal" . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||
$txt .= 'TASK' . PHP_EOL;
|
||||
$txt .= " 1\tgrapper daily" . PHP_EOL;
|
||||
$txt .= " 2\tgrapper" . PHP_EOL;
|
||||
if (! self::$options['id']) {
|
||||
$txt = 'PARAMETERS'.PHP_EOL;
|
||||
$txt .= '--d debug'.PHP_EOL;
|
||||
$txt .= '--r restart range'.PHP_EOL;
|
||||
$txt .= '--f force'.PHP_EOL;
|
||||
$txt .= '--folder'.PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------'.PHP_EOL;
|
||||
$txt .= 'FUNCTION'.PHP_EOL;
|
||||
$txt .= ' 1 grapper daily & subDays ( default 3)'.PHP_EOL;
|
||||
$txt .= ' 2 grapper date'.PHP_EOL;
|
||||
$txt .= ' 3 grapper range'.PHP_EOL;
|
||||
$txt .= ' 4 grapper rose'.PHP_EOL;
|
||||
// $txt .= " 1\tPlayerPerSeason".PHP_EOL;
|
||||
// $txt .= " 1\tPlayerPerSeason".PHP_EOL;
|
||||
// $txt .= " 1\tPlayerPerSeason".PHP_EOL;
|
||||
// $txt .= " 2\tSettingsToLocal".PHP_EOL;
|
||||
Notice::note($txt, 'b', 1);
|
||||
}
|
||||
|
||||
switch ($id) {
|
||||
Notice::note('Id '.self::$options['id'], 'bb');
|
||||
sleep(2);
|
||||
|
||||
switch (self::$options['id']) {
|
||||
|
||||
case 1:
|
||||
Notice::note('PlayerPerSeason sleep 5', 'bb');
|
||||
sleep(5);
|
||||
// SettingsToLocal::run();
|
||||
|
||||
SetStorage::set(1);
|
||||
|
||||
// Grapper::load(1);
|
||||
|
||||
// MakeExcel::create();
|
||||
|
||||
SendMail::run(1);
|
||||
|
||||
PlayerPerSeason::run();
|
||||
break;
|
||||
// case 2:
|
||||
// SetStorage::set();
|
||||
|
||||
case 2:
|
||||
Notice::note('SettingsToLocal sleep 5', 'bb');
|
||||
sleep(5);
|
||||
// Grapper::load(2);
|
||||
// break;
|
||||
// case 3:
|
||||
// SetStorage::set();
|
||||
|
||||
SettingsToLocal::run();
|
||||
break;
|
||||
// Grapper::load(3);
|
||||
// break;
|
||||
// case 4:
|
||||
// SetStorage::set();
|
||||
|
||||
case 3:
|
||||
SetStorage::set();
|
||||
Grapper::load();
|
||||
break;
|
||||
// Grapper::load(4);
|
||||
// break;
|
||||
// case 5:
|
||||
|
||||
case 4:
|
||||
SetStorage::set();
|
||||
MakeExcel::create();
|
||||
break;
|
||||
// PlayerPerSeason::run();
|
||||
// break;
|
||||
|
||||
// case 'zip':
|
||||
// self::setStorage();
|
||||
// ZipFolder::create();
|
||||
// break;
|
||||
// case 6:
|
||||
|
||||
// case 'mail':
|
||||
// self::setStorage();
|
||||
// SendMail::run();
|
||||
// break;
|
||||
// SettingsToLocal::run();
|
||||
// break;
|
||||
|
||||
// case 'rose':
|
||||
// self::setStorage();
|
||||
// Rose::run();
|
||||
// break;
|
||||
// case 7:
|
||||
|
||||
// case 'sql_mover':
|
||||
// SqlMover::run();
|
||||
// break;
|
||||
// SetStorage::set();
|
||||
// MakeExcel::create();
|
||||
// break;
|
||||
|
||||
// case 'zip':
|
||||
// self::setStorage();
|
||||
// ZipFolder::create();
|
||||
// break;
|
||||
|
||||
// case 'mail':
|
||||
// self::setStorage();
|
||||
// SendMail::run();
|
||||
// break;
|
||||
|
||||
// case 'torunament_teams':
|
||||
// TournamentTeams::get();
|
||||
// break;
|
||||
// case 'rose':
|
||||
// self::setStorage();
|
||||
// Rose::run();
|
||||
// break;
|
||||
|
||||
// case 'set_to_production':
|
||||
// SettingsToProduction::run();
|
||||
// break;
|
||||
// case 'sql_mover':
|
||||
// SqlMover::run();
|
||||
// break;
|
||||
|
||||
// case 'torunament_teams':
|
||||
// TournamentTeams::get();
|
||||
// break;
|
||||
|
||||
// case 'set_to_production':
|
||||
// SettingsToProduction::run();
|
||||
// break;
|
||||
|
||||
default:
|
||||
Notice::note('not a valid fuction', 'br', 1);
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grap;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\CurlSofa;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
|
||||
use App\Console\Commands\Grap;
|
||||
use App\Models\Country;
|
||||
use App\Models\SofaScoreCategory;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
@@ -16,157 +16,156 @@ class DaysTournament
|
||||
{
|
||||
/**
|
||||
* a Grap --d --f 67 --fun=4 --task=1
|
||||
*
|
||||
*
|
||||
* Ita Serie-A-Saison 23-08-2025 - 24-05-2026
|
||||
* Ger Bundesliga 22-08-2025 – 16-05-2026
|
||||
* Eng Premier league 15-08-2025 - 24-05-2026
|
||||
* Spa La Liga 15-08-2025 - 24-05-2026
|
||||
* Fra Liggue 15-08-2025 - 17-05-2026
|
||||
*/
|
||||
public static function get(array $d)
|
||||
public static function get(string $day)
|
||||
{
|
||||
$debug = Grap::$options['d'] ?? 0;
|
||||
|
||||
$tournaments_counter = 0;
|
||||
|
||||
$sport_id = $d['sport_id'];
|
||||
$has = SofaScoreDayTournament::where('day', $day)->first();
|
||||
|
||||
$day = $d['day'];
|
||||
$sport = [];
|
||||
$sport[1] = 'football';
|
||||
|
||||
$slug = $d['slug'];
|
||||
foreach ($sport as $sport_id => $slug) {
|
||||
if ($has) {
|
||||
if ($debug) {
|
||||
Notice::note("Tournaments $day for ".strtoupper($slug).' allready grapped', 'bb');
|
||||
}
|
||||
} else {
|
||||
|
||||
$has = SofaScoreDayTournament::where('day', $day)->where('sport_id', $sport_id)->first();
|
||||
|
||||
if ($has) {
|
||||
if ($debug) {
|
||||
Notice::note("Tournaments $day for " . strtoupper($slug) . " allready grapped", 'bb');
|
||||
}
|
||||
} else {
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("$day\ngrappig", 'g');
|
||||
}
|
||||
|
||||
$page = 1;
|
||||
|
||||
while ($page) {
|
||||
|
||||
$url = Grap::$options['base_url'] . "api/v1/sport/$slug/scheduled-tournaments/$day/page/$page";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
if ($data['hasNextPage']) {
|
||||
$page++;
|
||||
} else {
|
||||
$page = false;
|
||||
if ($debug) {
|
||||
Notice::note("$day\ngrappig", 'g');
|
||||
}
|
||||
|
||||
foreach ($data['scheduled'] as $row) {
|
||||
$page = 1;
|
||||
|
||||
if (isset($row['tournament']['uniqueTournament'])) {
|
||||
$tournament = $row['tournament']['uniqueTournament'];
|
||||
while ($page) {
|
||||
|
||||
$url = Grap::$options['base_url']."api/v1/sport/$slug/scheduled-tournaments/$day/page/$page";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
if ($data['hasNextPage']) {
|
||||
$page++;
|
||||
} else {
|
||||
$tournament = $row['tournament'];
|
||||
$page = false;
|
||||
}
|
||||
|
||||
$category = $tournament['category'];
|
||||
foreach ($data['scheduled'] as $row) {
|
||||
|
||||
if ($sport_id == 5) {
|
||||
$country_id = 470;
|
||||
} else {
|
||||
if (isset($row['tournament']['uniqueTournament'])) {
|
||||
$tournament = $row['tournament']['uniqueTournament'];
|
||||
} else {
|
||||
$tournament = $row['tournament'];
|
||||
}
|
||||
|
||||
$category = $tournament['category'];
|
||||
|
||||
if ($sport_id == 5) {
|
||||
$country_id = 470;
|
||||
} else {
|
||||
|
||||
/**
|
||||
* CATEGORY
|
||||
*/
|
||||
$find = [
|
||||
'Amateur',
|
||||
'Bosnia & Herzegovina',
|
||||
'Czechia',
|
||||
'DR Congo',
|
||||
'Netherlands',
|
||||
'North & Central America',
|
||||
'Bonaire',
|
||||
'Sao Tome and Principe',
|
||||
'Cape Verde',
|
||||
'Macao',
|
||||
'Saint Kitts and Nevis',
|
||||
'Eswatini',
|
||||
'Timor Leste',
|
||||
'Laos',
|
||||
'Congo Republic',
|
||||
|
||||
];
|
||||
$replace = [
|
||||
'',
|
||||
'Bosnia Herzegovina',
|
||||
'Czech Republic',
|
||||
'Congo DR',
|
||||
'Holland',
|
||||
'North America',
|
||||
'Bonaire, Sint Eustatius and Saba',
|
||||
'Sao Tome e Principe',
|
||||
'Cape Verde Islands',
|
||||
'Macau',
|
||||
'St. Kitts and Nevis',
|
||||
'Swaziland',
|
||||
'East Timor',
|
||||
'Lao Peoples\'s Democratic Republic',
|
||||
'Congo DR',
|
||||
];
|
||||
$country_id = Country::where('name', trim(str_replace($find, $replace, $category['name'])))->value('id');
|
||||
}
|
||||
|
||||
// dd($category, $country_id);
|
||||
|
||||
if (! $country_id) {
|
||||
// platzhalter fix later sofa_score_categories => txodds countries
|
||||
// CATEGORY find <-> replace
|
||||
Log::channel('sofascore')->info($tournament);
|
||||
|
||||
$sofa_score_category_id = 10000000;
|
||||
} else {
|
||||
$call = SofaScoreCategory::updateOrCreate([
|
||||
'id' => (int) $category['id'],
|
||||
'country_id' => (int) $country_id,
|
||||
'slug' => $category['slug'],
|
||||
], [
|
||||
'name' => $category['name'],
|
||||
]);
|
||||
|
||||
$sofa_score_category_id = $call->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* CATEGORY
|
||||
* TOURNAMENT
|
||||
*/
|
||||
$find = [
|
||||
'Amateur',
|
||||
'Bosnia & Herzegovina',
|
||||
'Czechia',
|
||||
'DR Congo',
|
||||
'Netherlands',
|
||||
'North & Central America',
|
||||
'Bonaire',
|
||||
'Sao Tome and Principe',
|
||||
'Cape Verde',
|
||||
'Macao',
|
||||
'Saint Kitts and Nevis',
|
||||
'Eswatini',
|
||||
'Timor Leste',
|
||||
'Laos',
|
||||
'Congo Republic',
|
||||
|
||||
];
|
||||
$replace = [
|
||||
'',
|
||||
'Bosnia Herzegovina',
|
||||
'Czech Republic',
|
||||
'Congo DR',
|
||||
'Holland',
|
||||
'North America',
|
||||
'Bonaire, Sint Eustatius and Saba',
|
||||
'Sao Tome e Principe',
|
||||
'Cape Verde Islands',
|
||||
'Macau',
|
||||
'St. Kitts and Nevis',
|
||||
'Swaziland',
|
||||
'East Timor',
|
||||
'Lao Peoples\'s Democratic Republic',
|
||||
'Congo DR',
|
||||
];
|
||||
$country_id = Country::where('name', trim(str_replace($find, $replace, $category['name'])))->value('id');
|
||||
}
|
||||
|
||||
// dd($category, $country_id);
|
||||
|
||||
if (! $country_id) {
|
||||
// platzhalter fix later sofa_score_categories => txodds countries
|
||||
// CATEGORY find <-> replace
|
||||
Log::channel('sofascore')->info($tournament);
|
||||
|
||||
$sofa_score_category_id = 10000000;
|
||||
} else {
|
||||
$call = SofaScoreCategory::updateOrCreate([
|
||||
'id' => (int) $category['id'],
|
||||
'country_id' => (int) $country_id,
|
||||
'slug' => $category['slug'],
|
||||
SofaScoreTournament::updateOrCreate([
|
||||
'sport_id' => (int) $sport_id,
|
||||
'tournament_id' => (int) $tournament['id'],
|
||||
'sofa_score_category_id' => (int) $sofa_score_category_id,
|
||||
], [
|
||||
'name' => $category['name'],
|
||||
'name' => $tournament['name'],
|
||||
'slug' => $tournament['slug'],
|
||||
]);
|
||||
|
||||
$sofa_score_category_id = $call->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* TOURNAMENT
|
||||
*/
|
||||
SofaScoreTournament::updateOrCreate([
|
||||
'sport_id' => (int) $sport_id,
|
||||
'tournament_id' => (int) $tournament['id'],
|
||||
'sofa_score_category_id' => (int) $sofa_score_category_id,
|
||||
], [
|
||||
'name' => $tournament['name'],
|
||||
'slug' => $tournament['slug'],
|
||||
]);
|
||||
$tournaments_counter++;
|
||||
$tournaments_counter++;
|
||||
|
||||
// if ($debug) {
|
||||
// Notice::note('tournament: ' . $tournament['name'], 'p');
|
||||
// }
|
||||
|
||||
/**
|
||||
* DAY TOURNAMENT
|
||||
*/
|
||||
SofaScoreDayTournament::updateOrCreate([
|
||||
'tournament_id' => (int) $tournament['id'],
|
||||
'sport_id' => (int) $sport_id,
|
||||
'day' => $day,
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* DAY TOURNAMENT
|
||||
*/
|
||||
SofaScoreDayTournament::updateOrCreate([
|
||||
'tournament_id' => (int) $tournament['id'],
|
||||
'sport_id' => (int) $sport_id,
|
||||
'day' => $day,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("tournaments: $tournaments_counter", 'p');
|
||||
if ($debug) {
|
||||
Notice::note("tournaments: $tournaments_counter", 'p');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grap;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Models\SofaScoreTaskDay;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use App\Models\SofaScoreEventGrapped;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
use App\Models\SofaScoreTaskTournament;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\CurlSofa;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
use App\Models\SofaScoreEventGrapped;
|
||||
use App\Models\SofaScoreTaskDay;
|
||||
use App\Models\SofaScoreTaskTournament;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class Grapper
|
||||
{
|
||||
public static function load()
|
||||
public static function load(int $task_id)
|
||||
{
|
||||
/**
|
||||
* , JSON_PRETTY_PRINT
|
||||
@@ -25,12 +25,12 @@ class Grapper
|
||||
$debug = Grap::$options['d'] ?? 0;
|
||||
$restart = Grap::$options['r'] ?? 0;
|
||||
$force = Grap::$options['f'] ?? 0;
|
||||
$task_id = Grap::$options['task'] ?? 0;
|
||||
|
||||
if (!$task_id)
|
||||
if (! $task_id) {
|
||||
Notice::note('task id missing', 'r', 1);
|
||||
}
|
||||
|
||||
$days = LoadDays::load();
|
||||
$days = LoadDays::load($task_id);
|
||||
|
||||
$count = 0;
|
||||
|
||||
@@ -39,18 +39,21 @@ class Grapper
|
||||
/**
|
||||
* daily restart always
|
||||
*/
|
||||
if ($task_id == 1) SofaScoreEventGrapped::where('grapper_id', $task_id)->delete();
|
||||
if ($task_id == 1) {
|
||||
SofaScoreEventGrapped::where('grapper_id', $task_id)->delete();
|
||||
}
|
||||
/**
|
||||
* Restart RANGE call
|
||||
* empty grapping folder
|
||||
* empty mailing text
|
||||
* empty mail text
|
||||
*/
|
||||
if ($restart) {
|
||||
|
||||
SofaScoreEventGrapped::where('grapper_id', $task_id)->delete();
|
||||
|
||||
foreach ($days as $d) {
|
||||
foreach ($days as $day) {
|
||||
SofaScoreTaskDay::where('grapper_id', (int) $task_id)
|
||||
->where('day', $d['day'])
|
||||
->where('day', $day)
|
||||
->update(['done' => 0]);
|
||||
}
|
||||
|
||||
@@ -63,16 +66,14 @@ class Grapper
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($days as $d) {
|
||||
foreach ($days as $day) {
|
||||
|
||||
DaysTournament::get($d);
|
||||
DaysTournament::get($day);
|
||||
|
||||
foreach ($active_tournaments as $tournament) {
|
||||
|
||||
$day = $d['day'];
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('START ' . $tournament->tournament->name, 'p');
|
||||
Notice::note('START '.$tournament->tournament->name, 'p');
|
||||
}
|
||||
|
||||
$res = SofaScoreDayTournament::whereDate('day', '=', $day)->where('tournament_id', $tournament->sofa_score_tournament_id)->first();
|
||||
@@ -83,7 +84,7 @@ class Grapper
|
||||
Notice::note($day, 'g');
|
||||
}
|
||||
|
||||
$url = Grap::$options['base_url'] . "api/v1/unique-tournament/$tournament->sofa_score_tournament_id/scheduled-events/$day";
|
||||
$url = Grap::$options['base_url']."api/v1/unique-tournament/$tournament->sofa_score_tournament_id/scheduled-events/$day";
|
||||
|
||||
Sleeper::rand(1);
|
||||
|
||||
@@ -95,9 +96,9 @@ class Grapper
|
||||
|
||||
Grap::$useragent = rand(1, 6);
|
||||
|
||||
if (!$force && SofaScoreEventGrapped::where('id', (int) $event['id'])->exists()) {
|
||||
if (! $force && SofaScoreEventGrapped::where('id', (int) $event['id'])->exists()) {
|
||||
if ($debug) {
|
||||
Notice::note('Grapped ' . $day . ' - ' . $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'], 'g');
|
||||
Notice::note('Grapped '.$day.' - '.$event['homeTeam']['name'].' vs '.$event['awayTeam']['name'], 'g');
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -112,18 +113,18 @@ class Grapper
|
||||
Sleeper::rand(1);
|
||||
|
||||
if ($debug) {
|
||||
Notice::note($day . ' - ' . $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'], 'bg');
|
||||
Notice::note($day.' - '.$event['homeTeam']['name'].' vs '.$event['awayTeam']['name'], 'bg');
|
||||
}
|
||||
|
||||
$grapped = SofaScoreEventGrapped::firstOrNew(['id' => $event['id']]);
|
||||
$grapped->grapper_id = $task_id;
|
||||
$grapped->day = $day;
|
||||
$grapped->liga = $event['tournament']['name'];
|
||||
$grapped->name = $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'];
|
||||
$grapped = SofaScoreEventGrapped::firstOrNew(['id' => $event['id']]);
|
||||
$grapped->grapper_id = $task_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();
|
||||
|
||||
$folder = Grap::$storage . '/' . $day . '/' . $day . '-' . $event['tournament']['slug'] . '/' . $event['slug'];
|
||||
$folder = Grap::$storage.'/'.$day.'/'.$day.'-'.$event['tournament']['slug'].'/'.$event['slug'];
|
||||
|
||||
File::makeDirectory($folder, 0775, true, true);
|
||||
|
||||
@@ -131,7 +132,7 @@ class Grapper
|
||||
* EVENT event
|
||||
*********************************/
|
||||
|
||||
File::put($folder . '/event.json', json_encode($event));
|
||||
File::put($folder.'/event.json', json_encode($event));
|
||||
|
||||
/*********************************
|
||||
* EVENT statistics
|
||||
@@ -139,7 +140,7 @@ class Grapper
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/statistics";
|
||||
$url = Grap::$options['base_url']."api/v1/event/$event_id/statistics";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
@@ -147,7 +148,7 @@ class Grapper
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder . '/statistics.json', json_encode($data));
|
||||
File::put($folder.'/statistics.json', json_encode($data));
|
||||
|
||||
$grapped->got_statistics = 1;
|
||||
|
||||
@@ -155,7 +156,7 @@ class Grapper
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/lineups";
|
||||
$url = Grap::$options['base_url']."api/v1/event/$event_id/lineups";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
@@ -163,7 +164,7 @@ class Grapper
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder . '/lineups.json', json_encode($data));
|
||||
File::put($folder.'/lineups.json', json_encode($data));
|
||||
|
||||
$grapped->got_lineups = 1;
|
||||
|
||||
@@ -171,7 +172,7 @@ class Grapper
|
||||
* EVENT odds
|
||||
*********************************/
|
||||
|
||||
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/odds/1/all";
|
||||
$url = Grap::$options['base_url']."api/v1/event/$event_id/odds/1/all";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
@@ -179,7 +180,7 @@ class Grapper
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder . '/odds.json', json_encode($data));
|
||||
File::put($folder.'/odds.json', json_encode($data));
|
||||
|
||||
$grapped->got_odds = 1;
|
||||
|
||||
@@ -187,7 +188,7 @@ class Grapper
|
||||
* EVENT incidents
|
||||
*********************************/
|
||||
|
||||
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/incidents";
|
||||
$url = Grap::$options['base_url']."api/v1/event/$event_id/incidents";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
@@ -195,7 +196,7 @@ class Grapper
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder . '/incidents.json', json_encode($data));
|
||||
File::put($folder.'/incidents.json', json_encode($data));
|
||||
|
||||
$grapped->got_incidents = 1;
|
||||
|
||||
@@ -206,7 +207,7 @@ class Grapper
|
||||
}
|
||||
}
|
||||
if ($debug) {
|
||||
Notice::note('END ' . $tournament->tournament->name, 'p');
|
||||
Notice::note('END '.$tournament->tournament->name, 'p');
|
||||
}
|
||||
}
|
||||
SofaScoreTaskDay::updateOrCreate([
|
||||
@@ -218,12 +219,10 @@ class Grapper
|
||||
|
||||
$count++;
|
||||
|
||||
Notice::note($count . ' DAYS DONE', 'bb');
|
||||
if ($debug) {
|
||||
Notice::note($count.' days done', 'bb');
|
||||
}
|
||||
|
||||
// if ($count > 20)
|
||||
// Notice::note($count . ' DAYS DONE', 'br', 1);
|
||||
// else
|
||||
// Notice::note($count . ' DAYS DONE', 'bb');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore\Helper;
|
||||
|
||||
class FileType
|
||||
{
|
||||
public static function filter(array $files, string $type = 'json')
|
||||
{
|
||||
$filtered = [];
|
||||
foreach ($files as $file) {
|
||||
$path_parts = pathinfo($file);
|
||||
if (isset($path_parts['extension']) && $path_parts['extension'] == $type) {
|
||||
$filtered[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
return $filtered;
|
||||
}
|
||||
}
|
||||
@@ -2,66 +2,47 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore\Helper;
|
||||
|
||||
use App\Utilities\Notice;
|
||||
use App\Console\Commands\Grap;
|
||||
use App\Models\SofaScoreTask;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Models\SofaScoreTaskDay;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class LoadDays
|
||||
{
|
||||
public static function load()
|
||||
public static function load(int $task_id)
|
||||
{
|
||||
$debug = Grap::$options['d'] ?? 0;
|
||||
|
||||
$restart = Grap::$options['restart'] ?? 0;
|
||||
|
||||
$task_id = Grap::$options['task'] ?? 0;
|
||||
|
||||
$folder = Grap::$options['folder'] ?? 0;
|
||||
|
||||
$dates = [];
|
||||
|
||||
if (!$task_id) {
|
||||
if (! $task_id) {
|
||||
Notice::note('no task id', 'br');
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
$task = SofaScoreTask::with('sport')->where('id', $task_id)->first();
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('Task id:' . $task->id . ', mode:' . $task->mode . ', sport:' . $task->sport->name);
|
||||
Notice::note('Task id:'.$task->id.', mode:'.$task->mode.', sport:'.$task->sport->name);
|
||||
}
|
||||
|
||||
switch ($task->mode) {
|
||||
|
||||
case 'daily':
|
||||
if ($folder) {
|
||||
$dates[] = [
|
||||
'day' => $folder,
|
||||
'slug' => $task->sport->ss_slug,
|
||||
'sport_id' => $task->sport_id,
|
||||
];
|
||||
} else {
|
||||
$dates[] = [
|
||||
'day' => Carbon::now()->subDays(3)->format('Y-m-d'),
|
||||
'slug' => $task->sport->ss_slug,
|
||||
'sport_id' => $task->sport_id,
|
||||
];
|
||||
}
|
||||
$dates[] = ValidateDate::get(Grap::$folder);
|
||||
break;
|
||||
|
||||
case 'date':
|
||||
$dates[] = [
|
||||
'day' => self::validateDate($task->day_from),
|
||||
'slug' => $task->sport->ss_slug,
|
||||
'sport_id' => $task->sport_id,
|
||||
];
|
||||
$dates[] = ValidateDate::get($task->day_from);
|
||||
break;
|
||||
|
||||
case 'range':
|
||||
$from = self::validateDate($task->day_from);
|
||||
$to = self::validateDate($task->day_to);
|
||||
$from = ValidateDate::get($task->day_from);
|
||||
$to = ValidateDate::get($task->day_to);
|
||||
|
||||
$from = Carbon::createFromDate($from);
|
||||
$to = Carbon::createFromDate($to);
|
||||
@@ -75,25 +56,17 @@ class LoadDays
|
||||
if ($restart) {
|
||||
// get all days
|
||||
while ($from <= $to) {
|
||||
$dates[] = [
|
||||
'day' => $from->format('Y-m-d'),
|
||||
'slug' => $task->sport->ss_slug,
|
||||
'sport_id' => $task->sport_id,
|
||||
];
|
||||
$dates[] = $from->format('Y-m-d');
|
||||
$from->addDay();
|
||||
}
|
||||
} else {
|
||||
// remove days done
|
||||
// remove days done
|
||||
while ($from <= $to) {
|
||||
|
||||
$res = SofaScoreTaskDay::firstOrNew(['grapper_id' => (int) $task_id, 'day' => $from->format('Y-m-d')]);
|
||||
|
||||
if (!$res->done) {
|
||||
$dates[] = [
|
||||
'day' => $from->format('Y-m-d'),
|
||||
'slug' => $task->sport->ss_slug,
|
||||
'sport_id' => $task->sport_id,
|
||||
];
|
||||
if (! $res->done) {
|
||||
$dates[] = $from->format('Y-m-d');
|
||||
}
|
||||
$from->addDay();
|
||||
}
|
||||
@@ -110,16 +83,6 @@ class LoadDays
|
||||
// remove when element in array is double (day and slug)
|
||||
$dates = array_unique($dates, SORT_REGULAR);
|
||||
|
||||
|
||||
return $dates;
|
||||
}
|
||||
|
||||
public static function validateDate(string $date)
|
||||
{
|
||||
if (Carbon::createFromDate($date) !== false) {
|
||||
return $date;
|
||||
} else {
|
||||
Notice::note('Wrong date format', 'r', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,47 +9,52 @@ use Illuminate\Support\Carbon;
|
||||
|
||||
class SetStorage
|
||||
{
|
||||
public static function set()
|
||||
public static function set(int $task_id)
|
||||
{
|
||||
$task = Grap::$options['task'] ?? 1;
|
||||
$debug = Grap::$options['d'];
|
||||
$folder = Grap::$options['folder'] ?? '';
|
||||
$task = SofaScoreTask::where('id', $task)->first();
|
||||
|
||||
$sofascore_data = storage_path('sofascore_data') . '/';
|
||||
$folder = Grap::$options['folder'] ?? '';
|
||||
|
||||
$day = Grap::$options['day'] == 0 ? 3 : Grap::$options['day'];
|
||||
|
||||
// must be connectet to task for activated ligas
|
||||
$task = SofaScoreTask::where('id', $task_id)->first();
|
||||
|
||||
$sofascore_data = storage_path('sofascore_data').'/';
|
||||
if ($task) {
|
||||
$storage_name = Strings::clean($task->name);
|
||||
|
||||
switch ($task->id) {
|
||||
case 1:
|
||||
Grap::$storage = $sofascore_data . $storage_name;
|
||||
Grap::$folder = Carbon::now()->subDays(3)->format('Y-m-d');
|
||||
Grap::$storage = $sofascore_data.$storage_name;
|
||||
Grap::$folder = Carbon::now()->subDays($day)->format('Y-m-d');
|
||||
break;
|
||||
case 2:
|
||||
Grap::$storage = $sofascore_data . $storage_name . '/' . $task->day_from;
|
||||
Grap::$zipfile = $sofascore_data . $storage_name . '/' . $task->day_from . '.zip';
|
||||
Grap::$storage = $sofascore_data.$storage_name.'/'.$task->day_from;
|
||||
Grap::$zipfile = $sofascore_data.$storage_name.'/'.$task->day_from.'.zip';
|
||||
break;
|
||||
case 3:
|
||||
Grap::$storage = $sofascore_data . $storage_name . '-' . $task->day_from . '-' . $task->day_to;
|
||||
Grap::$zipfile = $sofascore_data . $storage_name . '-' . $task->day_from . '-' . $task->day_to . '.zip';
|
||||
Grap::$storage = $sofascore_data.$storage_name.'-'.$task->day_from.'-'.$task->day_to;
|
||||
Grap::$zipfile = $sofascore_data.$storage_name.'-'.$task->day_from.'-'.$task->day_to.'.zip';
|
||||
break;
|
||||
case 4:
|
||||
Grap::$storage = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d');
|
||||
Grap::$zipfile = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d') . '.zip';
|
||||
Grap::$storage = $sofascore_data.$storage_name.'/rosa-'.Carbon::now()->format('Y-m-d');
|
||||
Grap::$zipfile = $sofascore_data.$storage_name.'/rosa-'.Carbon::now()->format('Y-m-d').'.zip';
|
||||
break;
|
||||
|
||||
default:
|
||||
Grap::$storage = $sofascore_data . $storage_name;
|
||||
Grap::$zipfile = $sofascore_data . $storage_name . '/archive.zip';
|
||||
Grap::$storage = $sofascore_data.$storage_name;
|
||||
Grap::$zipfile = $sofascore_data.$storage_name.'/archive.zip';
|
||||
break;
|
||||
}
|
||||
} else if ($folder) {
|
||||
} elseif ($folder) {
|
||||
Grap::$storage = $sofascore_data;
|
||||
Grap::$folder = $folder;
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Task: $task->name\n" . 'Storage: ' . Grap::$storage . "\nFolder: " . Grap::$folder);
|
||||
Notice::note("Task: $task->name\n".'Storage: '.Grap::$storage."\nFolder: ".Grap::$folder);
|
||||
sleep(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore\Helper;
|
||||
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class ValidateDate
|
||||
{
|
||||
public static function get(string $date)
|
||||
{
|
||||
if (Carbon::createFromDate($date) !== false) {
|
||||
return $date;
|
||||
} else {
|
||||
Notice::note('Wrong date format', 'r', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,28 +2,28 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore\Helper;
|
||||
|
||||
use App\Console\Commands\Grap;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use ZipArchive;
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
class ZipFolder
|
||||
{
|
||||
public static function create()
|
||||
{
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$zip = new ZipArchive;
|
||||
|
||||
if ($zip->open(Sofascore::$zipfile, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
|
||||
if ($zip->open(Grap::$zipfile, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
|
||||
|
||||
if (is_dir(Sofascore::$storage)) {
|
||||
if (is_dir(Grap::$storage)) {
|
||||
|
||||
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(Sofascore::$storage));
|
||||
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(Grap::$storage));
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (!$file->isDir()) {
|
||||
if (! $file->isDir()) {
|
||||
$filePath = $file->getRealPath();
|
||||
$relativePath = substr($filePath, strlen(Sofascore::$storage) + 1);
|
||||
$relativePath = substr($filePath, strlen(Grap::$storage) + 1);
|
||||
$zip->addFile($filePath, $relativePath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grap;
|
||||
use App\Console\Commands\Grapper\Grap\Helper\ZipFolder;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\FileType;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\ReadDir;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Utilities\Notice;
|
||||
@@ -18,27 +18,29 @@ class MakeExcel
|
||||
|
||||
public static function create()
|
||||
{
|
||||
ini_set("memory_limit", -1);
|
||||
ini_set('memory_limit', -1);
|
||||
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Make Excel folder to import: " . Grap::$folder . "\nmaximum files in excel: " . self::$max, 'b');
|
||||
Notice::note('Make Excel folder to import: '.Grap::$folder."\nmaximum files in excel: ".self::$max, 'b');
|
||||
}
|
||||
|
||||
$files = self::load_files();
|
||||
$files = ReadDir::get_tree(Grap::$storage.'/'.Grap::$folder);
|
||||
|
||||
$files = array_chunk(FileType::filter($files), self::$max);
|
||||
|
||||
foreach ($files as $key => $value) {
|
||||
|
||||
$has = count($value);
|
||||
if (!$key && $has < self::$max) {
|
||||
if (! $key && $has < self::$max) {
|
||||
$from = 1;
|
||||
$to = $has;
|
||||
} else if (!$key) {
|
||||
} elseif (! $key) {
|
||||
$from = 1;
|
||||
$key++;
|
||||
$to = $key * self::$max;
|
||||
} else if ($has == self::$max) {
|
||||
} elseif ($has == self::$max) {
|
||||
$from = $key * self::$max + 1;
|
||||
$key++;
|
||||
$to = $key * self::$max;
|
||||
@@ -47,7 +49,7 @@ class MakeExcel
|
||||
$to = $key * self::$max + $has;
|
||||
}
|
||||
|
||||
$filename = Grap::$folder . '-' . $from . '-' . $to . '.xlsx';
|
||||
$filename = Grap::$folder.'-'.$from.'-'.$to.'.xlsx';
|
||||
$spreadsheet = new Spreadsheet;
|
||||
$spreadsheet->getProperties()->setTitle($filename);
|
||||
$activeWorksheet = $spreadsheet->getActiveSheet();
|
||||
@@ -69,24 +71,9 @@ class MakeExcel
|
||||
|
||||
$spreadsheet->setActiveSheetIndex(0);
|
||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
$writer->save(Grap::$storage . '/' . $filename);
|
||||
$writer->save(Grap::$storage.'/'.$filename);
|
||||
|
||||
self::$filesToMail[] = Grap::$storage . '/' . $filename;
|
||||
self::$filesToMail[] = Grap::$storage.'/'.$filename;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function load_files()
|
||||
{
|
||||
$files = ReadDir::get_tree(Grap::$storage . '/' . Grap::$folder);
|
||||
|
||||
$filtered = [];
|
||||
foreach ($files as $file) {
|
||||
$path_parts = pathinfo($file);
|
||||
if (isset($path_parts['extension']) && $path_parts['extension'] == 'json') {
|
||||
$filtered[] = $file;
|
||||
}
|
||||
}
|
||||
return array_chunk($filtered, self::$max);
|
||||
}
|
||||
}
|
||||
@@ -2,81 +2,71 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Console\Commands\Grap;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\FileType;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\ReadDir;
|
||||
use App\Mail\SofaScoreDataMail;
|
||||
use App\Models\SofaScoreEventGrapped;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
use App\Models\SofaScoreTask;
|
||||
use App\Utilities\Notice;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendMail
|
||||
{
|
||||
public static function run()
|
||||
public static function run(int $task_id)
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$task_id = Nuh::$options['task'] ?? 0;
|
||||
$debug = Grap::$options['d'] ?? 0;
|
||||
|
||||
$task = SofaScoreTask::where('id', $task_id)->first();
|
||||
|
||||
$zip_file = Sofascore::$storage . Sofascore::$archive_name;
|
||||
$files = ReadDir::get_tree(Grap::$storage);
|
||||
|
||||
$sendfiles = FileType::filter($files, 'xlsx');
|
||||
|
||||
$header = self::createHeader($task);
|
||||
|
||||
$message = self::createMessage($task);
|
||||
$table = self::createTable($task);
|
||||
|
||||
if (File::exists($zip_file)) {
|
||||
|
||||
Mail::to('hermann.telser@gmail.com')
|
||||
->cc('ubaldo.perrucci@gmail.com')
|
||||
->send(
|
||||
new SofaScoreDataMail($header, $message)
|
||||
);
|
||||
if ($debug) {
|
||||
Notice::note('Mail: ' . $header);
|
||||
}
|
||||
} else {
|
||||
if ($debug) {
|
||||
Notice::note('zip not found ' . $zip_file, 'r', 1);
|
||||
}
|
||||
Mail::to('hermann.telser@gmail.com')
|
||||
->cc('ubaldo.perrucci@gmail.com')
|
||||
->send(
|
||||
new SofaScoreDataMail($header, $table, $sendfiles)
|
||||
);
|
||||
if ($debug) {
|
||||
Notice::note('Mail: '.$header);
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('Mail send', 'g');
|
||||
Notice::note('mail send', 'g');
|
||||
}
|
||||
}
|
||||
|
||||
public static function createMessage(SofaScoreTask $task)
|
||||
public static function createTable(SofaScoreTask $task)
|
||||
{
|
||||
$res = SofaScoreEventGrapped::where('grapper_id', $task->id)->get();
|
||||
|
||||
$text = '
|
||||
|
||||
';
|
||||
|
||||
$table = '';
|
||||
foreach ($res as $value) {
|
||||
$text .= $value->liga . ' - ' . $value->name . ' - ' . $value->starttime;
|
||||
$text .= '
|
||||
';
|
||||
$table .= '|'.$value->liga.'|'.$value->name.'|'.$value->starttime.'|
|
||||
';
|
||||
}
|
||||
return $text;
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
public static function createHeader(SofaScoreTask $task)
|
||||
{
|
||||
$text = "## ";
|
||||
$text = '## ';
|
||||
switch ($task->mode) {
|
||||
case 'daily':
|
||||
$text = $task->name . ' - ' . Carbon::now()->subDays(3)->format('Y-m-d');
|
||||
$text = $task->name.' - '.Carbon::now()->subDays(3)->format('Y-m-d');
|
||||
break;
|
||||
case 'date':
|
||||
$text = $task->name . ' - ' . $task->day_from;
|
||||
$text = $task->name.' - '.$task->day_from;
|
||||
break;
|
||||
case 'range':
|
||||
$text = $task->name . ' - ' . $task->day_from . ' - ' . $task->day_to;
|
||||
$text = $task->name.' - '.$task->day_from.' - '.$task->day_to;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Utilities\Notice;
|
||||
use App\Models\Supervisor;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Utilities\Supervisorctl;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Console\Commands\DbMapper\AutoMapper;
|
||||
use App\Console\Commands\Grapper\Betica;
|
||||
use App\Console\Commands\Grapper\Magloo;
|
||||
use App\Console\Commands\Grapper\TxOdds;
|
||||
use App\Console\Commands\Grapper\Betsapi;
|
||||
use App\Console\Commands\Grapper\Goldbet;
|
||||
use App\Console\Commands\Services\Services;
|
||||
use App\Console\Commands\Grapper\Logifuture;
|
||||
use App\Console\Commands\DbMapper\AutoMapper;
|
||||
use App\Console\Commands\Grapper\Magloo;
|
||||
use App\Console\Commands\Grapper\TxOdds;
|
||||
use App\Console\Commands\Services\Services;
|
||||
use App\Models\Supervisor;
|
||||
use App\Utilities\Notice;
|
||||
use App\Utilities\Supervisorctl;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Nuh extends Command
|
||||
{
|
||||
@@ -22,7 +22,7 @@ class Nuh extends Command
|
||||
|
||||
public static $id = 0;
|
||||
|
||||
protected $signature = 'nuh {process=help} {--folder=} {--id=0} {--gid=} {--p} {--d} {--x} {--t} {--y} {--m} {--l} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e} {--z}';
|
||||
protected $signature = 'nuh {process=help} {--id=0} {--gid=} {--p} {--d} {--x} {--t} {--y} {--m} {--l} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e} {--z}';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
@@ -35,45 +35,45 @@ class Nuh extends Command
|
||||
|
||||
if ($this->argument('process') == 'help') {
|
||||
$txt = PHP_EOL;
|
||||
if (!$show_supervisors) {
|
||||
$txt .= 'Parameters' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||
$txt .= 'process [id] (required)' . PHP_EOL;
|
||||
$txt .= '--id=matchid (optional) calling spezific id' . PHP_EOL;
|
||||
$txt .= '--fun=name (optional) [bkms, markets]' . PHP_EOL;
|
||||
$txt .= '--gid=groupid (optional) [bkms, groupid]' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL . PHP_EOL;
|
||||
$txt .= 'Options' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||
$txt .= '--a all by id' . PHP_EOL;
|
||||
$txt .= '--b block update (reload all for txodds)' . PHP_EOL;
|
||||
$txt .= '--d debug' . PHP_EOL;
|
||||
$txt .= '--e echo client data' . PHP_EOL;
|
||||
$txt .= '--f force (what ever in script)' . PHP_EOL;
|
||||
$txt .= '--g by minor groups (tx)' . PHP_EOL;
|
||||
$txt .= '--t load today' . PHP_EOL;
|
||||
$txt .= '--m mail it' . PHP_EOL;
|
||||
$txt .= '--p use proxy' . PHP_EOL;
|
||||
$txt .= '--q print all queries' . PHP_EOL;
|
||||
$txt .= '--r read data from file ' . PHP_EOL;
|
||||
$txt .= '--s store data to file ' . PHP_EOL;
|
||||
$txt .= '--t load today' . PHP_EOL;
|
||||
$txt .= '--w laod this week (tx)' . PHP_EOL;
|
||||
$txt .= '--x generate supervisors' . PHP_EOL;
|
||||
$txt .= '--y load yesterday' . PHP_EOL;
|
||||
$txt .= '--z show supervisors tasks' . PHP_EOL;
|
||||
if (! $show_supervisors) {
|
||||
$txt .= 'Parameters'.PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------'.PHP_EOL;
|
||||
$txt .= 'process [id] (required)'.PHP_EOL;
|
||||
$txt .= '--id=matchid (optional) calling spezific id'.PHP_EOL;
|
||||
$txt .= '--fun=name (optional) [bkms, markets]'.PHP_EOL;
|
||||
$txt .= '--gid=groupid (optional) [bkms, groupid]'.PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------'.PHP_EOL.PHP_EOL;
|
||||
$txt .= 'Options'.PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------'.PHP_EOL;
|
||||
$txt .= '--a all by id'.PHP_EOL;
|
||||
$txt .= '--b block update (reload all for txodds)'.PHP_EOL;
|
||||
$txt .= '--d debug'.PHP_EOL;
|
||||
$txt .= '--e echo client data'.PHP_EOL;
|
||||
$txt .= '--f force (what ever in script)'.PHP_EOL;
|
||||
$txt .= '--g by minor groups (tx)'.PHP_EOL;
|
||||
$txt .= '--t load today'.PHP_EOL;
|
||||
$txt .= '--m mail it'.PHP_EOL;
|
||||
$txt .= '--p use proxy'.PHP_EOL;
|
||||
$txt .= '--q print all queries'.PHP_EOL;
|
||||
$txt .= '--r read data from file '.PHP_EOL;
|
||||
$txt .= '--s store data to file '.PHP_EOL;
|
||||
$txt .= '--t load today'.PHP_EOL;
|
||||
$txt .= '--w laod this week (tx)'.PHP_EOL;
|
||||
$txt .= '--x generate supervisors'.PHP_EOL;
|
||||
$txt .= '--y load yesterday'.PHP_EOL;
|
||||
$txt .= '--z show supervisors tasks'.PHP_EOL;
|
||||
}
|
||||
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL . PHP_EOL;
|
||||
$txt .= 'Supervisors (--z)' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------'.PHP_EOL.PHP_EOL;
|
||||
$txt .= 'Supervisors (--z)'.PHP_EOL;
|
||||
if ($show_supervisors) {
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------'.PHP_EOL;
|
||||
$tmp = Supervisor::orderBy('provider_id')->get();
|
||||
foreach ($tmp as $value) {
|
||||
if ($value->sport_id) {
|
||||
$txt .= sprintf('% 3d', $value->id) . ' ' . $value->provider->name . ' - ' . $value->sport->name . ' ' . $value->name . PHP_EOL;
|
||||
$txt .= sprintf('% 3d', $value->id).' '.$value->provider->name.' - '.$value->sport->name.' '.$value->name.PHP_EOL;
|
||||
} else {
|
||||
$txt .= sprintf('% 3d', $value->id) . ' ' . $value->provider->name . ' - All ' . $value->name . PHP_EOL;
|
||||
$txt .= sprintf('% 3d', $value->id).' '.$value->provider->name.' - All '.$value->name.PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use Illuminate\Mail\Mailables\Attachment;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
class SofaScoreDataMail extends Mailable
|
||||
{
|
||||
@@ -17,13 +16,7 @@ class SofaScoreDataMail extends Mailable
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct(string $header, string $message)
|
||||
{
|
||||
$this->header = $header;
|
||||
$this->message = $message;
|
||||
$this->archive_name = Sofascore::$archive_name;
|
||||
$this->zip_file = Sofascore::$storage . Sofascore::$archive_name;
|
||||
}
|
||||
public function __construct(public string $header, public string $table, public array $sendfiles) {}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
@@ -43,7 +36,8 @@ class SofaScoreDataMail extends Mailable
|
||||
return new Content(
|
||||
markdown: 'mail.user.sofascore_data',
|
||||
with: [
|
||||
'message' => $this->message,
|
||||
'message' => $this->header,
|
||||
'table' => $this->table,
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -52,13 +46,16 @@ class SofaScoreDataMail extends Mailable
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, Attachment>
|
||||
* ->withMime('application/x-zip-compressed');
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [
|
||||
Attachment::fromPath($this->zip_file)
|
||||
->as($this->archive_name)
|
||||
->withMime('application/x-zip-compressed')
|
||||
];
|
||||
$attachments = [];
|
||||
foreach ($this->sendfiles as $sendfile) {
|
||||
$attachments[] = Attachment::fromPath($sendfile)
|
||||
->withMime('application/vnd.openxmlformats-officedocument.spreadsheetml.template');
|
||||
}
|
||||
|
||||
return $attachments;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
<x-mail::message>
|
||||
{{ $message }}
|
||||
</x-mail::message>
|
||||
@component('mail::message')
|
||||
# {{ $message }}
|
||||
|
||||
@component('mail::table')
|
||||
| Liga | Event | Starttime |
|
||||
|:------------- |:-------------| --------:|
|
||||
{{ $table }}
|
||||
@endcomponent
|
||||
|
||||
@endcomponent
|
||||
|
||||
+40
-21
@@ -1,22 +1,41 @@
|
||||
<tr>
|
||||
<td class="header">
|
||||
<div style="display: inline-block;">
|
||||
<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 !!}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<td class="header">
|
||||
<div style="display: inline-block;">
|
||||
<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 !!}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
+9
-3
@@ -1,5 +1,7 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
|
||||
<head>
|
||||
<title>{{ config('app.name') }}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
@@ -25,6 +27,7 @@ width: 100% !important;
|
||||
</style>
|
||||
{!! $head ?? '' !!}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table class="wrapper" width="100%" cellpadding="0" cellspacing="0" role="presentation">
|
||||
@@ -35,8 +38,10 @@ width: 100% !important;
|
||||
|
||||
<!-- Email Body -->
|
||||
<tr>
|
||||
<td class="body" width="100%" cellpadding="0" cellspacing="0" style="border: hidden !important;">
|
||||
<table class="inner-body" align="center" width="570" cellpadding="0" cellspacing="0" role="presentation">
|
||||
<td class="body" width="100%" cellpadding="0" cellspacing="0"
|
||||
style="border: hidden !important;">
|
||||
<table class="inner-body" align="center" width="570" cellpadding="0" cellspacing="0"
|
||||
role="presentation">
|
||||
<!-- Body content -->
|
||||
<tr>
|
||||
<td class="content-cell">
|
||||
@@ -55,4 +60,5 @@ width: 100% !important;
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+23
-23
@@ -1,27 +1,27 @@
|
||||
<x-mail::layout>
|
||||
{{-- Header --}}
|
||||
<x-slot:header>
|
||||
<x-mail::header :url="config('app.url')">
|
||||
by New-Odds Market Monitoring
|
||||
</x-mail::header>
|
||||
</x-slot:header>
|
||||
{{-- Header --}}
|
||||
<x-slot:header>
|
||||
<x-mail::header :url="config('app.url')">
|
||||
by NUH-Odds Gmbh - Market Monitoring
|
||||
</x-mail::header>
|
||||
</x-slot:header>
|
||||
|
||||
{{-- Body --}}
|
||||
{!! $slot !!}
|
||||
{{-- Body --}}
|
||||
{!! $slot !!}
|
||||
|
||||
{{-- Subcopy --}}
|
||||
@isset($subcopy)
|
||||
<x-slot:subcopy>
|
||||
<x-mail::subcopy>
|
||||
{!! $subcopy !!}
|
||||
</x-mail::subcopy>
|
||||
</x-slot:subcopy>
|
||||
@endisset
|
||||
{{-- Subcopy --}}
|
||||
@isset($subcopy)
|
||||
<x-slot:subcopy>
|
||||
<x-mail::subcopy>
|
||||
{!! $subcopy !!}
|
||||
</x-mail::subcopy>
|
||||
</x-slot:subcopy>
|
||||
@endisset
|
||||
|
||||
{{-- Footer --}}
|
||||
<x-slot:footer>
|
||||
<x-mail::footer>
|
||||
© {{ date('Y') }} NUH-Odds GmbH Innsbruck Austria, {{ __('All rights reserved.') }}
|
||||
</x-mail::footer>
|
||||
</x-slot:footer>
|
||||
</x-mail::layout>
|
||||
{{-- Footer --}}
|
||||
<x-slot:footer>
|
||||
<x-mail::footer>
|
||||
© {{ date('Y') }} NUH-Odds GmbH Innsbruck Austria, {{ __('All rights reserved.') }}
|
||||
</x-mail::footer>
|
||||
</x-slot:footer>
|
||||
</x-mail::layout>
|
||||
@@ -11,4 +11,3 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
<div class="table">
|
||||
{{ Illuminate\Mail\Markdown::parse($slot) }}
|
||||
</div>
|
||||
Reference in new issue
Block a user