|
|
|
@ -1,11 +1,16 @@ |
|
|
|
<?php |
|
|
|
namespace App\Services; |
|
|
|
use DateTime; |
|
|
|
use Log; |
|
|
|
use Symfony\Component\Finder\Finder; |
|
|
|
use App\Services\QueuedFfmpegService; |
|
|
|
|
|
|
|
class FileService { |
|
|
|
|
|
|
|
private $queuedFfmpegService; |
|
|
|
|
|
|
|
public function __construct() { |
|
|
|
$this->queuedFfmpegService = new QueuedFfmpegService(); |
|
|
|
} |
|
|
|
|
|
|
|
public function segmentFiles($baseDir) |
|
|
|
{ |
|
|
|
if (!is_dir($baseDir)) { |
|
|
|
@ -1192,13 +1197,16 @@ class FileService { |
|
|
|
} |
|
|
|
$files = scandir($dir); |
|
|
|
foreach ($files as $file) { |
|
|
|
if (skipDefaultPathAndFile($file)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
$currentItem = implode(DIRECTORY_SEPARATOR, [$dir, $file]); |
|
|
|
if (is_dir($currentItem)) { |
|
|
|
$this->deleteFilesForExtensions($currentItem, $extensions); |
|
|
|
} |
|
|
|
if (is_file($currentItem)) { |
|
|
|
$pathinfo = pathinfo($currentItem); |
|
|
|
if (in_array($pathinfo[PATHINFO_EXTENSION], $extensions)) { |
|
|
|
$pathInfo = pathinfo($currentItem); |
|
|
|
if (in_array($pathInfo[PATHINFO_EXTENSION], $extensions)) { |
|
|
|
dump("now delete file $currentItem"); |
|
|
|
unlink($currentItem); |
|
|
|
} |
|
|
|
@ -1214,6 +1222,9 @@ class FileService { |
|
|
|
} |
|
|
|
$files = scandir($dir); |
|
|
|
foreach ($files as $file) { |
|
|
|
if (skipDefaultPathAndFile($file)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
$currentItem = implode(DIRECTORY_SEPARATOR, [$dir, $file]); |
|
|
|
if (is_dir($currentItem)) { |
|
|
|
$this->renameFileExtensionToAnother($currentItem, $fromExtension, $toExtension); |
|
|
|
@ -1221,8 +1232,10 @@ class FileService { |
|
|
|
if (is_file($currentItem)) { |
|
|
|
$pathInfo = pathinfo($currentItem); |
|
|
|
if ($pathInfo[PATHINFO_EXTENSION] == $fromExtension) { |
|
|
|
dump("now rename file $currentItem"); |
|
|
|
rename($currentItem, str_replace($fromExtension, $toExtension, $currentItem)); |
|
|
|
$newFile = str_replace($fromExtension, $toExtension, $currentItem); |
|
|
|
dump("now rename file $currentItem to $newFile"); |
|
|
|
rename($currentItem, $newFile); |
|
|
|
$this->queuedFfmpegService->addToQueue($newFile); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|