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,55 +4,59 @@ 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
{
use DispatchesJobs;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'video:scanall';
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'video:scanall'.
'{--scanned : Rescan Scanned Videos}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Scan Videos';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
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;
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$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()));
}
}