regular scedule com.sofascore.grapper
This commit is contained in:
1 parent
fb31825b22
commit
3fc0724137
12 files changed
+758
-590
No files matched your search
@@ -1,30 +1,58 @@
|
|||||||
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>Sofascore Grapper</key>
|
<key>Label</key>
|
||||||
<string>com.sofascore.grapper</string>
|
<string>com.sofascore.grapper</string>
|
||||||
<key>ProgramArguments</key>
|
<key>ProgramArguments</key>
|
||||||
<array>
|
<array>
|
||||||
<string>/Users/hermanntelser/Sites/nuhodds_fi4/apple_damon.sh</string>
|
<string>/Users/hermanntelser/Sites/nuhodds_fi4/apple_damon.sh</string>
|
||||||
|
<string>2</string>
|
||||||
</array>
|
</array>
|
||||||
<key>StartCalendarInterval</key>
|
<key>StartCalendarInterval</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Hour</key>
|
<key>Hour</key>
|
||||||
<integer>2</integer>
|
<integer>2</integer>
|
||||||
<key>Minute</key>
|
<key>Minute</key>
|
||||||
<integer>30</integer>
|
<integer>15</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
||||||
|
|
||||||
1) Sicher an diesem Ort:
|
1) Sicher an diesem Ort:
|
||||||
Für einen bestimmten Benutzer: ~/Library/LaunchAgents/
|
Für einen bestimmten Benutzer: ~/Library/LaunchAgents/
|
||||||
Für alle Benutzer (Systemweit): /Library/LaunchAgents/
|
Für alle Benutzer (Systemweit): /Library/LaunchAgents/
|
||||||
Für das gesamte Betriebssystem: /Library/LaunchDaemons/
|
Für das gesamte Betriebssystem: /Library/LaunchDaemons/
|
||||||
|
|
||||||
2) Die Datei: Speichern Sie den Code oben in einer
|
2) Die Datei: Speichern Sie den Code oben in einer
|
||||||
.plist-Datei (z.B. com.beispiel.skript.plist).
|
.plist-Datei (z.B. com.sofascore.grapper.plist).
|
||||||
|
|
||||||
3) Aktivieren: Laden Sie den Prozess im Terminal mit dem Befehl:
|
3) Aktivieren: Laden Sie den Prozess im Terminal mit dem Befehl:
|
||||||
launchctl load ~/Library/LaunchAgents/com.beispiel.skript.plist
|
# sudo launchctl load -w /Library/LaunchDaemons/com.sofascore.grapper.plist
|
||||||
|
4) Dieser script wir nur ausgeführt wenn der PC nicht schläft!
|
||||||
|
|
||||||
|
|
||||||
|
1) Type the following command to wake your Mac at 8:00 AM every Monday through Friday:
|
||||||
|
# sudo pmset repeat wake MTWRFSU 20:00:00
|
||||||
|
|
||||||
|
M = Monday
|
||||||
|
T = Tuesday
|
||||||
|
W = Wednesday
|
||||||
|
R = Thursday
|
||||||
|
F = Friday
|
||||||
|
S = Saturday
|
||||||
|
SU = Sunday
|
||||||
|
MTWRF = Weekdays only
|
||||||
|
X = Every day
|
||||||
|
|
||||||
|
2) sudo pmset repeat wake MTWRF 02:20:00
|
||||||
|
|
||||||
|
3) Check the current schedule: Type
|
||||||
|
# pmset -g sched
|
||||||
|
in Terminal and press Return.
|
||||||
|
|
||||||
|
4) Cancel the schedule: Type
|
||||||
|
# sudo pmset repeat cancel
|
||||||
|
and press Return.
|
||||||
@@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands\Grapper\Sofascore;
|
namespace App\Console\Commands\Grapper\Sofascore;
|
||||||
|
|
||||||
use App\Console\Commands\Grapper\Sofascore\Tools\LoadTournaments;
|
use App\Console\Commands\Grapper\Sofascore\Tools\LoadDays;
|
||||||
|
use App\Console\Commands\Grapper\Sofascore\Tools\Sleeper;
|
||||||
use App\Console\Commands\Nuh;
|
use App\Console\Commands\Nuh;
|
||||||
|
use App\Models\SofaScoreDayTournament;
|
||||||
|
use App\Models\SofaScoreTournament;
|
||||||
use App\Utilities\Notice;
|
use App\Utilities\Notice;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
|
|
||||||
@@ -11,132 +14,106 @@ class EventsDatabase
|
|||||||
{
|
{
|
||||||
public static $storage_path = '/Console/Commands/Grapper/Sofascore/grapped/';
|
public static $storage_path = '/Console/Commands/Grapper/Sofascore/grapped/';
|
||||||
|
|
||||||
public static function load($days)
|
public static function load()
|
||||||
{
|
{
|
||||||
$debug = Nuh::$options['d'] ?? 0;
|
$debug = Nuh::$options['d'] ?? 0;
|
||||||
|
|
||||||
$print = Nuh::$options['p'] ?? 0;
|
|
||||||
|
|
||||||
$langsam = Nuh::$options['l'] ?? 0;
|
|
||||||
|
|
||||||
$tornaments = LoadTournaments::load();
|
$days = LoadDays::load();
|
||||||
|
|
||||||
if ($print) {
|
foreach ($days as $d) {
|
||||||
Notice::note($days, 'p');
|
|
||||||
Notice::note($tornaments->toArray(), 'b', 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($days as $day) {
|
$langsam = $d['run_slow'];
|
||||||
|
$sport_id = $d['sport_id'];
|
||||||
|
$day = $d['day'];
|
||||||
|
|
||||||
if ($debug) {
|
$active_tournaments = SofaScoreTournament::select('name', 'tournament_id')->where('sport_id', $sport_id)->where('enabled', 1)->get();
|
||||||
Notice::note($day, 'b');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($tornaments as $tournament) {
|
foreach ($active_tournaments as $tournament) {
|
||||||
|
|
||||||
if ($debug) {
|
$has = SofaScoreDayTournament::where('day', $day)->where('tournament_id', $tournament->tournament_id)->first();
|
||||||
Notice::note($tournament->name, 'b');
|
|
||||||
}
|
|
||||||
|
|
||||||
$url = Nuh::$options['base_url']."api/v1/unique-tournament/$tournament->tournament_id/scheduled-events/$day";
|
if ($has) {
|
||||||
|
if ($debug) {
|
||||||
|
Notice::note($day.' - '.$tournament->name.' grapping', 'g');
|
||||||
|
}
|
||||||
|
|
||||||
$rand = self::rand($langsam);
|
$url = Nuh::$options['base_url']."api/v1/unique-tournament/$tournament->tournament_id/scheduled-events/$day";
|
||||||
if ($debug) {
|
|
||||||
Notice::note("Sleep $rand msec", 'y');
|
|
||||||
}
|
|
||||||
|
|
||||||
usleep($rand);
|
Sleeper::rand($langsam);
|
||||||
|
|
||||||
$data = CurlSofa::load($url);
|
$data = CurlSofa::load($url);
|
||||||
|
|
||||||
Nuh::$options['s'] = 0;
|
Nuh::$options['s'] = 0;
|
||||||
|
|
||||||
Nuh::$options['r'] = 0;
|
Nuh::$options['r'] = 0;
|
||||||
|
|
||||||
if (isset($data['events'])) {
|
if (isset($data['events'])) {
|
||||||
|
|
||||||
foreach ($data['events'] as $event) {
|
foreach ($data['events'] as $event) {
|
||||||
|
|
||||||
Notice::note($event['season']['name'].' '.$day, 'bb');
|
Notice::note($event['season']['name'].' '.$day, 'bb');
|
||||||
|
|
||||||
$folder = app_path().self::$storage_path.$day.'/'.$event['tournament']['slug'].'/'.$event['slug'];
|
$folder = app_path().self::$storage_path.$day.'/'.$event['tournament']['slug'].'/'.$event['slug'];
|
||||||
|
|
||||||
File::makeDirectory($folder, 0775, true, true);
|
File::makeDirectory($folder, 0775, true, true);
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
* EVENT event
|
* EVENT event
|
||||||
*********************************/
|
*********************************/
|
||||||
|
|
||||||
File::put($folder.'/event.json', json_encode($event));
|
File::put($folder.'/event.json', json_encode($event));
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
* EVENT statistics
|
* EVENT statistics
|
||||||
*********************************/
|
*********************************/
|
||||||
|
|
||||||
$event_id = $event['id'];
|
$event_id = $event['id'];
|
||||||
|
|
||||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/statistics";
|
$url = Nuh::$options['base_url']."api/v1/event/$event_id/statistics";
|
||||||
|
|
||||||
$rand = self::rand($langsam);
|
Sleeper::rand($langsam);
|
||||||
if ($debug) {
|
|
||||||
Notice::note("Sleep $rand msec", 'y');
|
$data = CurlSofa::load($url);
|
||||||
|
|
||||||
|
$data['id'] = $event_id;
|
||||||
|
|
||||||
|
File::put($folder.'/statistics.json', json_encode($data));
|
||||||
|
|
||||||
|
/*********************************
|
||||||
|
* EVENT lineups
|
||||||
|
*********************************/
|
||||||
|
|
||||||
|
$url = Nuh::$options['base_url']."api/v1/event/$event_id/lineups";
|
||||||
|
|
||||||
|
Sleeper::rand($langsam);
|
||||||
|
|
||||||
|
$data = CurlSofa::load($url);
|
||||||
|
|
||||||
|
$data['id'] = $event_id;
|
||||||
|
|
||||||
|
File::put($folder.'/lineups.json', json_encode($data));
|
||||||
|
|
||||||
|
/*********************************
|
||||||
|
* EVENT lineups
|
||||||
|
*********************************/
|
||||||
|
|
||||||
|
$url = Nuh::$options['base_url']."api/v1/event/$event_id/odds/1/all";
|
||||||
|
|
||||||
|
Sleeper::rand($langsam);
|
||||||
|
|
||||||
|
$data = CurlSofa::load($url);
|
||||||
|
|
||||||
|
$data['id'] = $event_id;
|
||||||
|
|
||||||
|
File::put($folder.'/odds.json', json_encode($data));
|
||||||
}
|
}
|
||||||
usleep($rand);
|
}
|
||||||
|
} else {
|
||||||
$data = CurlSofa::load($url);
|
if ($debug) {
|
||||||
|
Notice::note($day.' - '.$tournament->name.' not active', 'r');
|
||||||
$data['id'] = $event_id;
|
|
||||||
|
|
||||||
File::put($folder.'/statistics.json', json_encode($data));
|
|
||||||
|
|
||||||
/*********************************
|
|
||||||
* EVENT lineups
|
|
||||||
*********************************/
|
|
||||||
|
|
||||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/lineups";
|
|
||||||
|
|
||||||
$rand = self::rand($langsam);
|
|
||||||
if ($debug) {
|
|
||||||
Notice::note("Sleep $rand msec", 'y');
|
|
||||||
}
|
|
||||||
usleep($rand);
|
|
||||||
|
|
||||||
$data = CurlSofa::load($url);
|
|
||||||
|
|
||||||
$data['id'] = $event_id;
|
|
||||||
|
|
||||||
File::put($folder.'/lineups.json', json_encode($data));
|
|
||||||
|
|
||||||
/*********************************
|
|
||||||
* EVENT lineups
|
|
||||||
*********************************/
|
|
||||||
|
|
||||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/odds/1/all";
|
|
||||||
|
|
||||||
$rand = self::rand($langsam);
|
|
||||||
if ($debug) {
|
|
||||||
Notice::note("Sleep $rand msec", 'y');
|
|
||||||
}
|
|
||||||
usleep($rand);
|
|
||||||
|
|
||||||
$data = CurlSofa::load($url);
|
|
||||||
|
|
||||||
$data['id'] = $event_id;
|
|
||||||
|
|
||||||
File::put($folder.'/odds.json', json_encode($data));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function rand(bool $langsam = false)
|
|
||||||
{
|
|
||||||
if($langsam){
|
|
||||||
return rand(500000, 50000000);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return rand(500000, 1000000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,18 +2,23 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands\Grapper\Sofascore\Specials;
|
namespace App\Console\Commands\Grapper\Sofascore\Specials;
|
||||||
|
|
||||||
|
use App\Console\Commands\Grapper\Sofascore\Tools\LoadDays;
|
||||||
use App\Utilities\Notice;
|
use App\Utilities\Notice;
|
||||||
use App\Utilities\ZipFolder;
|
use App\Utilities\ZipFolder;
|
||||||
|
|
||||||
class CreateZip
|
class CreateZip
|
||||||
{
|
{
|
||||||
|
public static function run()
|
||||||
public static function run($days)
|
|
||||||
{
|
{
|
||||||
foreach ($days as $day) {
|
$days = LoadDays::load();
|
||||||
|
|
||||||
|
foreach ($days as $d) {
|
||||||
|
|
||||||
|
$day = $d['day'];
|
||||||
|
|
||||||
ZipFolder::create($day);
|
ZipFolder::create($day);
|
||||||
}
|
}
|
||||||
|
|
||||||
Notice::note('Archive created', 'g', 1);
|
Notice::note('Archive created', 'g', 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,150 +4,167 @@ namespace App\Console\Commands\Grapper\Sofascore\Specials;
|
|||||||
|
|
||||||
use App\Console\Commands\Grapper\Sofascore\CurlSofa;
|
use App\Console\Commands\Grapper\Sofascore\CurlSofa;
|
||||||
use App\Console\Commands\Grapper\Sofascore\Tools\LoadDays;
|
use App\Console\Commands\Grapper\Sofascore\Tools\LoadDays;
|
||||||
|
use App\Console\Commands\Grapper\Sofascore\Tools\Sleeper;
|
||||||
use App\Console\Commands\Nuh;
|
use App\Console\Commands\Nuh;
|
||||||
|
use App\Models\Country;
|
||||||
use App\Models\SofaScoreCategorie;
|
use App\Models\SofaScoreCategorie;
|
||||||
use App\Models\SofaScoreDayTournament;
|
use App\Models\SofaScoreDayTournament;
|
||||||
use App\Models\SofaScoreTournament;
|
use App\Models\SofaScoreTournament;
|
||||||
use App\Utilities\Notice;
|
use App\Utilities\Notice;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class DaysTournament
|
class DaysTournament
|
||||||
{
|
{
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
|
$debug = Nuh::$options['d'] ?? 0;
|
||||||
|
|
||||||
$days = LoadDays::load();
|
$days = LoadDays::load();
|
||||||
|
|
||||||
dd($days);
|
$tournaments_counter = 0;
|
||||||
|
|
||||||
foreach ($days as $day) {
|
foreach ($days as $d) {
|
||||||
|
|
||||||
$page = 1;
|
$langsam = $d['run_slow'];
|
||||||
|
$sport_id = $d['sport_id'];
|
||||||
|
$day = $d['day'];
|
||||||
|
$slug = $d['slug'];
|
||||||
|
|
||||||
while ($page) {
|
$has = SofaScoreDayTournament::where('day', $day)->first();
|
||||||
|
|
||||||
$url = Nuh::$options['base_url'] . "api/v1/sport/$sport->ss_slug/scheduled-tournaments/$day/page/$page";
|
if ($has) {
|
||||||
|
|
||||||
$rand = rand(500000, 1000000);
|
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
Notice::note("Sleep $rand msec", 'y');
|
Notice::note("$day\nis allready grapped", 'r');
|
||||||
}
|
}
|
||||||
usleep($rand);
|
} else {
|
||||||
|
if ($debug) {
|
||||||
$data = CurlSofa::load($url);
|
Notice::note("$day\ngrappig", 'g');
|
||||||
|
|
||||||
if ($data['hasNextPage']) {
|
|
||||||
$page++;
|
|
||||||
} else {
|
|
||||||
$page = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// $page = false;
|
$page = 1;
|
||||||
|
|
||||||
foreach ($data['scheduled'] as $row) {
|
while ($page) {
|
||||||
|
|
||||||
if (isset($row['tournament']['uniqueTournament'])) {
|
$url = Nuh::$options['base_url']."api/v1/sport/$slug/scheduled-tournaments/$day/page/$page";
|
||||||
$tournament = $row['tournament']['uniqueTournament'];
|
|
||||||
|
Sleeper::rand($langsam);
|
||||||
|
|
||||||
|
$data = CurlSofa::load($url);
|
||||||
|
|
||||||
|
if ($data['hasNextPage']) {
|
||||||
|
$page++;
|
||||||
} else {
|
} else {
|
||||||
$tournament = $row['tournament'];
|
$page = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$category = $tournament['category'];
|
foreach ($data['scheduled'] as $row) {
|
||||||
|
|
||||||
if ($sport_id == 5) {
|
if (isset($row['tournament']['uniqueTournament'])) {
|
||||||
$country_id = 470;
|
$tournament = $row['tournament']['uniqueTournament'];
|
||||||
} else {
|
} 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_categorie_id = 10000000;
|
||||||
|
} else {
|
||||||
|
$call = SofaScoreCategorie::updateOrCreate([
|
||||||
|
'id' => (int) $category['id'],
|
||||||
|
'country_id' => (int) $country_id,
|
||||||
|
'slug' => $category['slug'],
|
||||||
|
], [
|
||||||
|
'name' => $category['name'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$sofa_score_categorie_id = $call->id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CATEGORY
|
* TOURNAMENT
|
||||||
*/
|
*/
|
||||||
$find = [
|
SofaScoreTournament::updateOrCreate([
|
||||||
'Amateur',
|
'sport_id' => (int) $sport_id,
|
||||||
'Bosnia & Herzegovina',
|
'tournament_id' => (int) $tournament['id'],
|
||||||
'Czechia',
|
'sofa_score_categorie_id' => (int) $sofa_score_categorie_id,
|
||||||
'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_categorie_id = 10000000;
|
|
||||||
} else {
|
|
||||||
$call = SofaScoreCategorie::updateOrCreate([
|
|
||||||
'id' => (int) $category['id'],
|
|
||||||
'country_id' => (int) $country_id,
|
|
||||||
'slug' => $category['slug'],
|
|
||||||
], [
|
], [
|
||||||
'name' => $category['name'],
|
'name' => $tournament['name'],
|
||||||
|
'slug' => $tournament['slug'],
|
||||||
]);
|
]);
|
||||||
|
$tournaments_counter++;
|
||||||
|
|
||||||
$sofa_score_categorie_id = $call->id;
|
if ($debug) {
|
||||||
|
Notice::note('tournament: '.$tournament['name'], 'p');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DAY TOURNAMENT
|
||||||
|
*/
|
||||||
|
SofaScoreDayTournament::updateOrCreate([
|
||||||
|
'tournament_id' => (int) $tournament['id'],
|
||||||
|
'day' => $day,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
if ($debug) {
|
||||||
* TOURNAMENT
|
Notice::note("tournaments: $tournaments_counter", 'p');
|
||||||
*/
|
}
|
||||||
SofaScoreTournament::updateOrCreate([
|
|
||||||
'sport_id' => (int) $sport_id,
|
|
||||||
'tournament_id' => (int) $tournament['id'],
|
|
||||||
'sofa_score_categorie_id' => (int) $sofa_score_categorie_id,
|
|
||||||
], [
|
|
||||||
'name' => $tournament['name'],
|
|
||||||
'slug' => $tournament['slug'],
|
|
||||||
]);
|
|
||||||
$tournaments_counter++;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DAY TOURNAMENT
|
|
||||||
*/
|
|
||||||
|
|
||||||
SofaScoreDayTournament::updateOrCreate([
|
|
||||||
'tournament_id' => (int) $tournament['id'],
|
|
||||||
'day' => $day,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($debug) {
|
|
||||||
Notice::note("tournaments: $tournaments_counter", 'p');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Notice::note('days tournament done', 'g');
|
||||||
Notice::note('Archive created', 'g', 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,29 +3,34 @@
|
|||||||
namespace App\Console\Commands\Grapper\Sofascore\Specials;
|
namespace App\Console\Commands\Grapper\Sofascore\Specials;
|
||||||
|
|
||||||
use App\Console\Commands\Grapper\Sofascore\Special;
|
use App\Console\Commands\Grapper\Sofascore\Special;
|
||||||
|
use App\Console\Commands\Grapper\Sofascore\Tools\LoadDays;
|
||||||
use App\Utilities\Notice;
|
use App\Utilities\Notice;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
class SendMail
|
class SendMail
|
||||||
{
|
{
|
||||||
public static function run($days)
|
public static function run()
|
||||||
{
|
{
|
||||||
foreach ($days as $day) {
|
$days = LoadDays::load();
|
||||||
|
|
||||||
|
foreach ($days as $d) {
|
||||||
|
|
||||||
|
$day = $d['day'];
|
||||||
|
|
||||||
$zip_file = Special::$storage_path.'/'.$day.'.zip';
|
$zip_file = Special::$storage_path.'/'.$day.'.zip';
|
||||||
|
|
||||||
Mail::send([], [], function ($message) use($day, $zip_file) {
|
Mail::send([], [], function ($message) use ($day, $zip_file) {
|
||||||
|
|
||||||
$message->to("hermann.telser@gmail.com", "sofa archive ".$day)
|
$message->to('hermann.telser@gmail.com', 'sofa archive '.$day)
|
||||||
->cc("ubaldo.perrucci@gmail.com", "sofa archive ".$day)
|
->cc('ubaldo.perrucci@gmail.com', 'sofa archive '.$day)
|
||||||
->subject("sofa archive $day")
|
->subject("sofa archive $day")
|
||||||
->attach($zip_file, [
|
->attach($zip_file, [
|
||||||
'mime' => 'application/x-zip-compressed',
|
'mime' => 'application/x-zip-compressed',
|
||||||
'as' => 'sofa archive '.$day.'.zip'
|
'as' => 'sofa archive '.$day.'.zip',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Notice::note('Mail send', 'g');
|
Notice::note('Mail send', 'g');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,29 +15,33 @@ class LoadDays
|
|||||||
|
|
||||||
$yesterday = Nuh::$options['y'] ?? 0;
|
$yesterday = Nuh::$options['y'] ?? 0;
|
||||||
|
|
||||||
if($today){
|
if ($today) {
|
||||||
return [Carbon::now()->format('Y-m-d')];
|
return [Carbon::now()->format('Y-m-d')];
|
||||||
}
|
} elseif ($yesterday) {
|
||||||
else if($yesterday){
|
|
||||||
return [Carbon::now()->subDay()->format('Y-m-d')];
|
return [Carbon::now()->subDay()->format('Y-m-d')];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
$res = SofaScoreTask::with('sport')->where('is_active', 1)->get();
|
$res = SofaScoreTask::with('sport')->where('is_active', 1)->get();
|
||||||
$dates = [];
|
$dates = [];
|
||||||
foreach ($res as $row) {
|
foreach ($res as $row) {
|
||||||
|
|
||||||
switch($row->mode){
|
switch ($row->mode) {
|
||||||
case 'yesterday':
|
case 'yesterday':
|
||||||
$dates[] = [
|
$dates[] = [
|
||||||
'day' => Carbon::now()->subDay()->format('Y-m-d'),
|
'day' => Carbon::now()->subDay()->format('Y-m-d'),
|
||||||
'slug' => $row->sport->ss_slug
|
'slug' => $row->sport->ss_slug,
|
||||||
|
'run_slow' => $row->run_slow,
|
||||||
|
'sport_id' => $row->sport_id,
|
||||||
|
'run_repeatedly' => $row->run_repeatedly,
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
case 'date':
|
case 'date':
|
||||||
$dates[] = [
|
$dates[] = [
|
||||||
'day' => self::validateDate($row->day_from),
|
'day' => self::validateDate($row->day_from),
|
||||||
'slug' => $row->sport->ss_slug
|
'slug' => $row->sport->ss_slug,
|
||||||
|
'run_slow' => $row->run_slow,
|
||||||
|
'sport_id' => $row->sport_id,
|
||||||
|
'run_repeatedly' => $row->run_repeatedly,
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
case 'range':
|
case 'range':
|
||||||
@@ -49,39 +53,40 @@ class LoadDays
|
|||||||
|
|
||||||
$lengthdates = $from->diffInDays($to);
|
$lengthdates = $from->diffInDays($to);
|
||||||
|
|
||||||
if($lengthdates < 1){
|
if ($lengthdates < 1) {
|
||||||
Notice::note('wrong date start must be before end', 'r', 1);
|
Notice::note('wrong date start must be before end', 'r', 1);
|
||||||
}
|
} elseif ($lengthdates > 60) {
|
||||||
else if($lengthdates > 60){
|
|
||||||
Notice::note('wrong date maximal 60 dates allowed', 'r', 1);
|
Notice::note('wrong date maximal 60 dates allowed', 'r', 1);
|
||||||
}
|
}
|
||||||
while ($from < $to){
|
while ($from < $to) {
|
||||||
$dates[] = [
|
$dates[] = [
|
||||||
'day' => $from->format('Y-m-d'),
|
'day' => $from->format('Y-m-d'),
|
||||||
'slug' => $row->sport->ss_slug
|
'slug' => $row->sport->ss_slug,
|
||||||
|
'run_slow' => $row->run_slow,
|
||||||
|
'sport_id' => $row->sport_id,
|
||||||
|
'run_repeatedly' => $row->run_repeatedly,
|
||||||
];
|
];
|
||||||
$from->addDay();
|
$from->addDay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $dates) {
|
if (! $dates) {
|
||||||
Notice::note(__file__.PHP_EOL.'no dates', 'r', 1);
|
Notice::note(__FILE__.PHP_EOL.'no dates', 'r', 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// remove when element in array is double (day and slug)
|
// remove when element in array is double (day and slug)
|
||||||
$dates = array_unique($dates, SORT_REGULAR);
|
$dates = array_unique($dates, SORT_REGULAR);
|
||||||
|
|
||||||
return $dates;
|
return $dates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function validateDate(string $date)
|
public static function validateDate(string $date)
|
||||||
{
|
{
|
||||||
if(Carbon::createFromDate($date) !== false){
|
if (Carbon::createFromDate($date) !== false) {
|
||||||
return $date;
|
return $date;
|
||||||
}
|
} else {
|
||||||
else {
|
Notice::note('Wrong date format', 'r', 1);
|
||||||
Notice::note('Wrong date format','r', 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,8 +10,7 @@ use App\Utilities\Notice;
|
|||||||
* FIFA World Cup 16
|
* FIFA World Cup 16
|
||||||
* China Super League 649
|
* China Super League 649
|
||||||
* Veikkausliiga 41
|
* Veikkausliiga 41
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class LoadTournaments
|
class LoadTournaments
|
||||||
{
|
{
|
||||||
public static function load()
|
public static function load()
|
||||||
@@ -21,15 +20,14 @@ class LoadTournaments
|
|||||||
$sport_id = Nuh::$options['sport_id'];
|
$sport_id = Nuh::$options['sport_id'];
|
||||||
$grps = Nuh::$options['grps'] ?? 0;
|
$grps = Nuh::$options['grps'] ?? 0;
|
||||||
|
|
||||||
if($grps){
|
if ($grps) {
|
||||||
$tornaments = SofaScoreTournament::select('name', 'tournament_id')->whereIn('tournament_id', explode(",", $grps))->where('enabled', 1)->get();
|
$tornaments = SofaScoreTournament::select('name', 'tournament_id')->whereIn('tournament_id', explode(',', $grps))->where('enabled', 1)->get();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$tornaments = SofaScoreTournament::select('name', 'tournament_id')->where('sport_id', $sport_id)->where('enabled', 1)->get();
|
$tornaments = SofaScoreTournament::select('name', 'tournament_id')->where('sport_id', $sport_id)->where('enabled', 1)->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $tornaments) {
|
if (! $tornaments) {
|
||||||
Notice::note(__file__.PHP_EOL.'no tornaments', 'r', 1);
|
Notice::note(__FILE__.PHP_EOL.'no tornaments', 'r', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tornaments;
|
return $tornaments;
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\Grapper\Sofascore\Tools;
|
||||||
|
|
||||||
|
use App\Console\Commands\Nuh;
|
||||||
|
use App\Utilities\Notice;
|
||||||
|
|
||||||
|
class Sleeper
|
||||||
|
{
|
||||||
|
public static function rand(bool $langsam = false)
|
||||||
|
{
|
||||||
|
$debug = Nuh::$options['d'] ?? 0;
|
||||||
|
|
||||||
|
if ($debug) {
|
||||||
|
$langsam = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($langsam) {
|
||||||
|
$sleep = rand(500000, 50000000);
|
||||||
|
} else {
|
||||||
|
$sleep = rand(500000, 1000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($debug) {
|
||||||
|
Notice::note("sleeping $sleep msec", 'y');
|
||||||
|
}
|
||||||
|
|
||||||
|
usleep($sleep);
|
||||||
|
}
|
||||||
|
}
|
||||||
+43
-20
@@ -1,28 +1,51 @@
|
|||||||
# AUTO GRAPPER SOFASCORE
|
case "$1" in
|
||||||
|
"1")
|
||||||
|
# AUTO GRAPPER SOFASCORE (debug)
|
||||||
|
echo "\n⚽ close all open vpn"
|
||||||
|
killall ssh
|
||||||
|
|
||||||
|
echo "\n⚽ open vpn tunnel to prod"
|
||||||
|
ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190
|
||||||
|
|
||||||
# echo "\n⚽ close all open vpn"
|
echo "\n⚽ copy active tournaments"
|
||||||
# killall ssh
|
php artisan nuh --d --f 73 --prc=2
|
||||||
|
|
||||||
# echo "\n⚽ open vpn tunnel to prod"
|
echo "\n⚽ close tunnel"
|
||||||
# ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190
|
killall ssh
|
||||||
|
|
||||||
# echo "\n⚽ copy active tournaments"
|
echo "\n⚽ grap avilable tournaments for given days"
|
||||||
# php artisan nuh --d --f 73 --prc=2
|
php artisan nuh --d --f 73 --prc=5
|
||||||
|
|
||||||
# echo "\n⚽ close tunnel"
|
echo "\n⚽ grapp data sofascore"
|
||||||
# killall ssh
|
php artisan nuh --d --f 72
|
||||||
|
|
||||||
echo "\n⚽ grap avilable tournaments for given day"
|
echo "\n⚽ create zip archive"
|
||||||
php artisan nuh --d --f 73 --prc=5
|
php artisan nuh --d --f 73 --prc=3
|
||||||
|
|
||||||
# echo "\n⚽ grapp data sofascore"
|
echo "\n⚽ mail archive"
|
||||||
# php artisan nuh --d --f --y 72
|
php artisan nuh --d --f 73 --prc=4
|
||||||
|
|
||||||
# echo "\n⚽ create zip archive"
|
echo "\n😎 done :)"
|
||||||
# php artisan nuh --d --f --y 73 --prc=3
|
;;
|
||||||
|
"2")
|
||||||
# echo "\n⚽ mail archive"
|
# AUTO GRAPPER SOFASCORE (production no debug and slow)
|
||||||
# php artisan nuh --d --f --y 73 --prc=4
|
killall ssh
|
||||||
|
ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190
|
||||||
# echo "\n😎 done :)"
|
php artisan nuh --f 73 --prc=2
|
||||||
|
killall ssh
|
||||||
|
php artisan nuh --f 73 --prc=5
|
||||||
|
php artisan nuh --f 72
|
||||||
|
php artisan nuh --f 73 --prc=3
|
||||||
|
php artisan nuh --f 73 --prc=4
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo ""
|
||||||
|
echo "--------------------------"
|
||||||
|
echo "apple damon grapper sofascore"
|
||||||
|
echo "--------------------------"
|
||||||
|
echo "1 => debug runs faster and echos notices"
|
||||||
|
echo "2 => for production no notices"
|
||||||
|
echo "--------------------------"
|
||||||
|
echo ""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Generated
+92
-12
@@ -4457,24 +4457,24 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "mongodb/mongodb",
|
"name": "mongodb/mongodb",
|
||||||
"version": "2.2.0",
|
"version": "2.3.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/mongodb/mongo-php-library.git",
|
"url": "https://github.com/mongodb/mongo-php-library",
|
||||||
"reference": "bbb13f969e37e047fd822527543df55fdc1c9298"
|
"reference": "12e56461166d915e3dd8e4969ad0940ed5207d88"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/bbb13f969e37e047fd822527543df55fdc1c9298",
|
"url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/12e56461166d915e3dd8e4969ad0940ed5207d88",
|
||||||
"reference": "bbb13f969e37e047fd822527543df55fdc1c9298",
|
"reference": "12e56461166d915e3dd8e4969ad0940ed5207d88",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"composer-runtime-api": "^2.0",
|
"composer-runtime-api": "^2.0",
|
||||||
"ext-mongodb": "^2.2",
|
"ext-mongodb": "^2.3",
|
||||||
"php": "^8.1",
|
"php": "^8.1",
|
||||||
"psr/log": "^1.1.4|^2|^3",
|
"psr/log": "^1.1.4|^2|^3",
|
||||||
"symfony/polyfill-php85": "^1.32"
|
"symfony/polyfill-php85": "^1.33"
|
||||||
},
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
"mongodb/builder": "*"
|
"mongodb/builder": "*"
|
||||||
@@ -4526,11 +4526,7 @@
|
|||||||
"mongodb",
|
"mongodb",
|
||||||
"persistence"
|
"persistence"
|
||||||
],
|
],
|
||||||
"support": {
|
"time": "2026-04-28T12:50:06+00:00"
|
||||||
"issues": "https://github.com/mongodb/mongo-php-library/issues",
|
|
||||||
"source": "https://github.com/mongodb/mongo-php-library/tree/2.2.0"
|
|
||||||
},
|
|
||||||
"time": "2026-02-11T11:39:56+00:00"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "monolog/monolog",
|
"name": "monolog/monolog",
|
||||||
@@ -8027,6 +8023,90 @@
|
|||||||
],
|
],
|
||||||
"time": "2026-04-10T16:19:22+00:00"
|
"time": "2026-04-10T16:19:22+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/polyfill-iconv",
|
||||||
|
"version": "v1.37.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/polyfill-iconv.git",
|
||||||
|
"reference": "2c5729fd241b4b22f6e4b436bc3354a4f262df57"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/2c5729fd241b4b22f6e4b436bc3354a4f262df57",
|
||||||
|
"reference": "2c5729fd241b4b22f6e4b436bc3354a4f262df57",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.2"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"ext-iconv": "*"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-iconv": "For best performance"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"thanks": {
|
||||||
|
"url": "https://github.com/symfony/polyfill",
|
||||||
|
"name": "symfony/polyfill"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Iconv\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nicolas Grekas",
|
||||||
|
"email": "p@tchwork.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony polyfill for the Iconv extension",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"compatibility",
|
||||||
|
"iconv",
|
||||||
|
"polyfill",
|
||||||
|
"portable",
|
||||||
|
"shim"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/polyfill-iconv/tree/v1.37.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/nicolas-grekas",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2026-04-10T16:19:22+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill-intl-grapheme",
|
"name": "symfony/polyfill-intl-grapheme",
|
||||||
"version": "v1.38.1",
|
"version": "v1.38.1",
|
||||||
|
|||||||
Generated
+308
-308
File diff suppressed because it is too large.
Load diff
Binary file not shown.
Reference in new issue
Block a user