Update VideoScanAll

This commit is contained in:
Deon George 2019-12-16 20:37:48 +11:00
parent c176ba9c94
commit bcdbc1715e
2 changed files with 46 additions and 42 deletions

View File

@ -26,7 +26,7 @@ class PhotoScanAll extends Command
*
* @var string
*/
protected $description = 'Rescan Photos';
protected $description = 'Scan Photos';
/**
* Create a new command instance.

View File

@ -4,8 +4,9 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Log;
use App\Model\Video;
use Illuminate\Support\Facades\Log;
use App\Models\Video;
use App\Jobs\CatalogScan;
class VideoScanAll extends Command
@ -17,14 +18,15 @@ class VideoScanAll extends Command
*
* @var string
*/
protected $signature = 'video:scanall';
protected $signature = 'video:scanall'.
'{--scanned : Rescan Scanned Videos}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
protected $description = 'Scan Videos';
/**
* Create a new command instance.
@ -43,16 +45,18 @@ class VideoScanAll extends Command
*/
public function handle()
{
Video::NotScanned()->chunk(200,function ($data) {
foreach ($data as $o)
{
if ($o->remove) {
Log::warning(sprintf('Not scanning [%s], marked for removal',$o->id));
continue;
$o = ($this->option('scanned') ? Video::NotRemove() : Video::NotScanned());
$o->each(function ($item) {
if ($item->remove) {
Log::warning(sprintf('Not scanning [%s], marked for removal',$item->id));
return;
}
$this->dispatch((new CatalogScan($o))->onQueue('scan'));
}
Log::info(sprintf('%s: Rescanning [%s]',__METHOD__,$item->id));
$this->dispatch((new CatalogScan($item))->onQueue('scan'));
});
Log::info(sprintf('Processed [%s]',$o->count()));
}
}