wip grapper
This commit is contained in:
1 parent
dc76eb35ae
commit
db5ce95b30
14 files changed
+81
-109
No files matched your search
+14
-11
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore\Special;
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use ZipArchive;
|
||||
@@ -11,24 +11,27 @@ class ZipFolder
|
||||
{
|
||||
public static function create(string $day){
|
||||
|
||||
$zipFilePath = Special::$storage_path.'/'.$day.'.zip';
|
||||
$zipFilePath = storage_path('zip_sofascore_data').'/'.$day.'.zip';
|
||||
|
||||
Special::$source_path .= '/'.$day;
|
||||
$path = Sofascore::$grapper_path.$day;
|
||||
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
|
||||
|
||||
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(Special::$source_path));
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (!$file->isDir()) {
|
||||
$filePath = $file->getRealPath();
|
||||
$relativePath = substr($filePath, strlen(Special::$source_path) + 1);
|
||||
$zip->addFile($filePath, $relativePath);
|
||||
if(is_dir($path)){
|
||||
|
||||
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (!$file->isDir()) {
|
||||
$filePath = $file->getRealPath();
|
||||
$relativePath = substr($filePath, strlen($path) + 1);
|
||||
$zip->addFile($filePath, $relativePath);
|
||||
}
|
||||
}
|
||||
$zip->close();
|
||||
}
|
||||
$zip->close();
|
||||
} else {
|
||||
return response()->json(['error' => 'Failed to create ZIP archive'], 500);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user