wip
This commit is contained in:
1 parent
db051d6e32
commit
c8cf1edaf4
3 files changed
+40
-33
No files matched your search
@@ -33,18 +33,19 @@ class Grap extends Command
|
||||
self::$options['base_url'] = 'https://www.sofascore.com/';
|
||||
|
||||
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 .= ' 5 playeer/season'.PHP_EOL;
|
||||
$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 .= ' 5 make ecxel from folder' . PHP_EOL;
|
||||
$txt .= ' 5 playeer/season' . PHP_EOL;
|
||||
// $txt .= " 1\tPlayerPerSeason".PHP_EOL;
|
||||
// $txt .= " 1\tPlayerPerSeason".PHP_EOL;
|
||||
// $txt .= " 1\tPlayerPerSeason".PHP_EOL;
|
||||
@@ -52,7 +53,7 @@ class Grap extends Command
|
||||
Notice::note($txt, 'b', 1);
|
||||
}
|
||||
|
||||
Notice::note('Id '.self::$options['id'], 'bb');
|
||||
Notice::note('Id ' . self::$options['id'], 'bb');
|
||||
sleep(2);
|
||||
|
||||
switch (self::$options['id']) {
|
||||
@@ -70,6 +71,11 @@ class Grap extends Command
|
||||
|
||||
break;
|
||||
case 5:
|
||||
SetStorage::set(5);
|
||||
|
||||
MakeExcel::create();
|
||||
break;
|
||||
case 6:
|
||||
PlayerPerSeason::run();
|
||||
break;
|
||||
// case 2:
|
||||
|
||||
@@ -20,31 +20,30 @@ class SetStorage
|
||||
// must be connectet to task for activated ligas
|
||||
$task = SofaScoreTask::where('id', $task_id)->first();
|
||||
|
||||
$sofascore_data = storage_path('sofascore_data').'/';
|
||||
$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::$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';
|
||||
case 5:
|
||||
Grap::$storage = $sofascore_data;
|
||||
Grap::$folder = $folder;
|
||||
break;
|
||||
}
|
||||
} elseif ($folder) {
|
||||
@@ -53,7 +52,7 @@ class SetStorage
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ class MakeExcel
|
||||
$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 = ReadDir::get_tree(Grap::$storage.'/'.Grap::$folder);
|
||||
$files = ReadDir::get_tree(Grap::$storage . '/' . Grap::$folder);
|
||||
|
||||
$files = array_chunk(FileType::filter($files), self::$max);
|
||||
|
||||
@@ -49,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();
|
||||
@@ -62,18 +62,20 @@ class MakeExcel
|
||||
|
||||
$arr = explode(PHP_EOL, $json_string);
|
||||
$row = 0;
|
||||
foreach ($arr as $val) {
|
||||
foreach ($arr as $string) {
|
||||
$row++;
|
||||
$activeWorksheet->setCellValue([$column, $row], $val);
|
||||
$replacedString = preg_replace("/\\\\u([0-9abcdef]{4})/", "&#x$1;", $string);
|
||||
$utf8string = mb_convert_encoding($replacedString, 'UTF-8', 'HTML-ENTITIES');
|
||||
$activeWorksheet->setCellValue([$column, $row], $utf8string);
|
||||
}
|
||||
$column++;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user